Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass[tikz,border=10pt]{standalone}
- \usepackage{pgfplots}
- \usepackage{amsmath} % Required for \varPsi below
- \usepackage{tikz}
- \usetikzlibrary{calc}
- \pgfplotsset{compat=1.9}
- \newcommand{\gettikzxy}[3]{%
- \tikz@scan@one@point\pgfutil@firstofone#1\relax
- \edef#2{\the\pgf@x}%
- \edef#3{\the\pgf@y}%
- }
- \begin{document}
- \begin{tikzpicture}
- %Definitions - These can be changed to create new figures%
- %===========================================================
- \def \Vs {4}; %Magnitude of space vector in cm
- \def \Angle {100}; %Angle with regards to phase A
- \def \Osv {35}; %Angle of d-axis wrt space vector
- \def \R {2.5}; %Magnitude of rotor flux in cm
- %Calculated variables. These should not be changed unless you know what you are doing%
- %===========================================================
- \pgfmathsetmacro \MaxLin {\Vs * cos{30}}; %Magnitude before overmodulation
- \pgfmathsetmacro \Qmag {\Vs * sin{\Osv})}; %Magnitude of Q axis
- \pgfmathsetmacro \Dmag {\Vs * cos{\Osv})}; %Magnitude of Q axis
- \pgfmathsetmacro \Marker {\Angle/45)};
- \pgfmathsetmacro \Vmax {\Vs * 2/3}; %Max phase voltage
- \def \Axisheight {\Vmax *3};
- \pgfmathsetmacro \Va {\Vmax * sin{(\Angle+0)}}; %Magnitude of phase A at angle \Angle
- \pgfmathsetmacro \Vb {\Vmax * sin{(\Angle+120)}}; %Magnitude of phase B at angle \Angle
- \pgfmathsetmacro \Vc {\Vmax * sin{(\Angle+240)}}; %Magnitude of phase C at angle \Angle
- \pgfmathsetmacro \Radius {\Vmax}; %Radius of maximum line to line voltage output
- %Locations%
- %===========================================================
- \def \OrigoX {-6 cm}; % If you want to move the circle relative to the wave forms (default -5cm)
- \def \OrigoY {0 cm};
- \def \OrigoYb {-12 cm};
- \def \OrigoYc {-24 cm};
- \coordinate (origo) at (\OrigoX,\OrigoY); %Center of top phasor diagram
- \coordinate (origob) at (\OrigoX,\OrigoYb); %Center of center phasor diagram
- \coordinate (origoc) at (\OrigoX,\OrigoYc); %Center of bottom phasor diagram
- \coordinate (phase_a) at (0:\Va cm); %Tip of phase A
- \coordinate (phase_b) at (120:\Vb cm); %Tip of phase B
- \coordinate (phase_c) at (240:\Vc cm) ; %Tip of phase C
- \coordinate (Y) at (\OrigoX+\Vs cm ,\OrigoY+0); %Where to start the Hexagon
- %Circle background rings%
- %===========================================================
- \node at (origo) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Top Circle with radius 128%
- \node at (origob) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Center Circle with radius 128%
- \node at (origoc) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Center Circle with radius 128%
- %Left axis to top circle
- \draw[<->] (2.05*\OrigoX,-1.1*\Vs cm) -- (2.05*\OrigoX,1.1*\Vs cm) node[anchor=south, distance=0.2cm]{$I$};
- \draw [color=black,dotted](\OrigoX,\Vs cm)--(2.1*\OrigoX,\Vs cm) node[anchor=east, distance=0.5cm] {$\frac{4}{\pi}I_{max} - 127,32\%$};
- \draw [color=red,dotted] (\OrigoX,\MaxLin cm) -- (2.1*\OrigoX,\MaxLin cm) node[anchor=east, distance=0.5cm] {$\frac{2}{\sqrt{3}}I_{max} - 115,47\%$};
- \draw [color=black,dotted](\OrigoX,\Vmax cm) -- (2.1*\OrigoX,\Vmax cm) node[anchor=east] {$I_{max} - 100,00\%$};
- \draw [color=black,dotted](\OrigoX,0 cm) -- (2.1*\OrigoX,0 cm) node[anchor=east] {$0\%$};
- %Hexagon Framing around phasors%
- %===========================================================
- \draw[-, color=black!50,thin,dashed] (Y) -- ++(120:\Vs cm) -- ++(180:\Vs cm) -- ++(240:\Vs cm) -- ++(300:\Vs cm) -- ++(360:\Vs cm) -- ++(60:\Vs cm); % Six step hexagon
- \node at (origo) [circle,draw=red!80, inner sep=0pt,minimum size=\MaxLin*2 cm, dashed] {}; %Circle with radius 115%
- %Black guide lines with angle notation
- \foreach \x in {45,90,...,360} {
- \draw[-,color=black,dotted, thin] (origo) -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
- } \foreach \x in {45,90,...,360} {
- \draw[-,color=black,dotted, thin] (origob) -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
- } \foreach \x in {45,90,...,360} {
- \draw[-,color=black,dotted, thin] (origoc) -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
- }
- %=============================================================================================================
- %Actual three phase phasors%
- %=============================================================================================================
- \node at (origo) [circle,thick,draw=black!80, inner sep=0pt,minimum size=\Vmax*2 cm] {}; %Circle with radius 100%
- \draw[->,color=red, very thick] (origo) -- ++(phase_a); %Phase A phasor
- \draw[->,color=blue, very thick] (origo) -- ++(phase_b); %Phase B phasor
- \draw[->,color=green, very thick] (origo) -- ++(phase_c); %Phase C phasor
- \draw[color=red,thick,smooth,domain=0:8] plot(\x,{\Vmax * sin(\x*45)}); % Phase A
- \draw[color=blue,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+120)}); %Phase B
- \draw[color=green,thick,,smooth,domain=0:8] plot(\x,{\Vmax * sin((\x*45)+240)}); % Phase C
- \draw[color=red,dashed] (\Marker,\Va) -- (-0.3,\Va) node[anchor=east] {$i_a$};; %A phase line to Y-axis
- \draw[color=blue,dashed] (\Marker,\Vb)-- (-0.3,\Vb) node[anchor=east] {$i_b$};; %B phase line to Y-axis
- \draw[color=green,dashed] (\Marker,\Vc)-- (-0.3,\Vc) node[anchor=east] {$i_c$};; %C phase line to Y-axis
- %SPACE VECTOR %
- \draw[->,ultra thick,black] (origo) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstip); %Space vector resultant
- \pgfgetlastxy{\XCoord}{\YCoord}; % X and Y coordinates of Space vector tip
- %Find space vector angle
- \pgfmathanglebetweenpoints{\pgfpointanchor{origo}{center}}{\pgfpointanchor{Vstip}{center}}
- \let\PhaseBlack\pgfmathresult;
- %Phasor guide lines%
- \draw[-,color=red, dashed] (origo) -- ++(0:\Vmax cm) node[anchor=west] {\large $i_a$};
- \draw[-,color=blue, dashed] (origo) -- ++(120:\Vmax cm) node[anchor=south] {\large $i_b$};
- \draw[-,color=green, dashed] (origo) -- ++(240:\Vmax cm) node[anchor=north] {\large $i_c$};
- \draw[-,color=red, dashed] (origo) -- ++(0:-\Vmax cm) node[anchor=east] {$-i_a$};
- \draw[-,color=blue, dashed] (origo) -- ++(120:-\Vmax cm) node[anchor=north] {$-i_b$};
- \draw[-,color=green, dashed] (origo) -- ++(240:-\Vmax cm) node[anchor=south] {$-i_c$};
- \draw[->,color=blue, thin] (origo) ++(phase_a) -> ++(phase_b); %Resultant help lines
- \draw[->,color=green, thin] (origo) ++(phase_a) ++(phase_b) -> ++(phase_c); %Resultant help lines
- \draw[color=gray] (\OrigoX,\Vmax) -- (9,\Vmax) ; %X axis TOP inner
- \draw[color=gray] (\OrigoX,-\Vmax) -- (9,-\Vmax) ; %X axis bottom inner
- %% Rotor Flux Vector%
- %\coordinate (rfluxtip) at (\PhaseBlack-\Osv:\R); %Tip of rotor flux
- %\draw[->,color=gray] (origo) -- ++(rfluxtip) node[label={[label distance=-0.18cm]\PhaseBlack-\Osv: $\lambda_r$}] {}; %Rotor Flux Phasor
- %Wave form
- \draw[->, color=black] (0,0) -- (9,0) node[anchor=west] {$\theta$}; %X axis
- \draw[->, color=black] (0,-\Vs) -- (0,\Vs) node[anchor=south] {$i$}; %Y axis
- %\draw[help lines] (0,-\Vs) grid (9 ,\Vs); %Grid
- %X Axis tick marks
- \foreach \x in {1, 2,...,8} {
- \pgfmathsetmacro \tick {\x * 45};
- \draw (\x cm,1pt) -- (\x cm,-1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
- }
- %Marker to illustrate angle position over wave forms
- \draw[color=black] (\Marker cm, \Vs cm) -- (\Marker cm, -\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
- %Top and bottom border, extending to circle top and and bottom
- \draw[color=gray] (\OrigoX,\Vs) -- (9,\Vs) ; %X axis TOP outer
- \draw[color=gray] (\OrigoX,-\Vs) -- (9,-\Vs) ; %X axis bottom outer
- %=============================================================================================================
- %Alpha and Beta Phasors
- %=============================================================================================================
- %SPACE VECTOR %
- \draw[->,ultra thick,black] (origob) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstipb); %Space vector resultant
- \pgfgetlastxy{\XCoordb}{\YCoordb}; % X and Y coordinates of Space vector tip
- %Find space vector angle
- \pgfmathanglebetweenpoints{\pgfpointanchor{origob}{center}}{\pgfpointanchor{Vstipb}{center}}
- \let\PhaseBlackb\pgfmathresult;
- %Green Axis system rotated to rotor angle
- \draw[-,color=green] (\OrigoX,\OrigoYb-\Vs cm) -- ++(90:2*\Vs cm);
- \draw[-,color=green] (\OrigoX+\Vs cm,\OrigoYb) -- ++(0:-2*\Vs cm);
- \draw[->,color=orange, thin, dashed] (\OrigoX, \YCoordb) -> (Vstipb); %Alpha help Line
- \draw[->,color=violet, thin, dashed] (\XCoordb, \OrigoYb) -> (Vstipb); %Beta help Line
- \draw[->,color=orange, very thick] (origob) -- ++(0,\YCoordb-\OrigoYb) node[anchor=north east] {\large $i_\alpha$}; %Phase alpha phasor
- \draw[->,color=violet, very thick] (origob) -- ++(\XCoordb-\OrigoX,0) node[anchor=north] {\large $i_\beta$}; %Phase beta phasor
- \coordinate (origobb) at (0,\OrigoYb); %Center of center phasor diagram
- \draw[color=orange,thick,smooth,domain=0:8, shift=(origobb)] plot(\x,{\Vs * sin((\x*45)+90)}); % Alpha
- \draw[color=violet,thick,smooth,domain=0:8, shift=(origobb)] plot(\x,{\Vs * sin((\x*45)+0)}); % Beta
- \draw[color=orange,dashed] (\Marker,\YCoordb)-- (-0.3,\YCoordb) node[anchor=east] {$i_\alpha$};; %Alpha line to alpha-axis
- \draw[color=violet,dashed] (\Marker,\XCoordb-\OrigoX+\OrigoYb)-- (-0.3,\XCoordb-\OrigoX+\OrigoYb) node[anchor=east] {$i_\beta$};; %Beta line to beta-axis
- %Wave form
- \draw[->, color=black] (0,\OrigoYb) -- (9,\OrigoYb) node[anchor=west] {$\theta$}; %X axis middle
- \draw[->, color=black] (0,\OrigoYb-\Vs cm) -- (0,\OrigoYb+\Vs cm) node[anchor=south] {$i$}; %Y axis middle
- \draw[help lines] (0,\OrigoYb-\Vs cm) grid (9 ,\OrigoYb+\Vs cm); %Grid middle
- %X Axis tick marks
- \foreach \x in {1, 2,...,8} {
- \pgfmathsetmacro \tick {\x * 45};
- \draw (\x cm,\OrigoYb-1pt) -- (\x cm,\OrigoYb+1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
- }
- %Marker to illustrate angle position over wave forms
- \draw[color=black] (\Marker cm,\OrigoYb+\Vs cm) -- (\Marker cm, \OrigoYb-\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
- %Top and bottom border, extending to circle top and and bottom
- \draw[color=gray] (\OrigoX,\OrigoYb+\Vs cm) -- (9,\OrigoYb+\Vs cm) ; %X axis TOP outer
- \draw[color=gray] (\OrigoX,\OrigoYb-\Vs cm) -- (9,\OrigoYb-\Vs cm) ; %X axis bottom outer
- %=============================================================================================================
- %%D and Q Phasors%
- %=============================================================================================================
- %Space Vector
- \draw[->,ultra thick,black] (origoc) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstipc); %Space vector resultant
- \pgfgetlastxy{\XCoordc}{\YCoordc}; % X and Y coordinates of Space vector tip
- %Find space vector angle
- \pgfmathanglebetweenpoints{\pgfpointanchor{origoc}{center}}{\pgfpointanchor{Vstipc}{center}}
- \let\PhaseBlackc\pgfmathresult;
- \coordinate (d1c) at (\PhaseBlackc-\Osv:\Vs cm) ; %Tip of d axis
- \coordinate (d2c) at (\PhaseBlackc-\Osv:-\Vs cm) ; %Tip of d axis
- \coordinate (q1c) at (\PhaseBlackc-\Osv+90:\Vs cm) ; %Tip of q axis
- \coordinate (q2c) at (\PhaseBlackc-\Osv+90:-\Vs cm) ; %Tip of q axis
- \coordinate (d3c) at (\PhaseBlackc-\Osv+90:\Qmag) ; %Tip of d
- \coordinate (q3c) at (\PhaseBlackc-\Osv:\Dmag) ; %Tip of q
- \draw[->,color=orange, thin, dashed] (origoc) -- ++(d3c) -> (Vstipc); %Q help Line
- \draw[->,color=violet, thin, dashed] (origoc) -- ++(q3c) -> (Vstipc); %Q help Line
- \draw[-,color=green, thin] (origoc) -- ++(d1c); %D axis help line
- \draw[-,color=green, thin] (origoc) -- ++(d2c); %D axis help line
- \draw[-,color=green, thin] (origoc) -- ++(q1c); %Q axis help line
- \draw[-,color=green, thin] (origoc) -- ++(q2c); %Q axis help line
- \draw[->,color=orange, very thick] (origoc) -- ++(d3c) node {\large $i_q$}; %D phasor
- \draw[->,color=violet, very thick] (origoc) -- ++(q3c) node {\large $i_d$}; %Q phasor
- \coordinate (origocc) at (0,\OrigoYc); %Center of center phasor diagram
- \draw[color=orange,thick,,smooth,domain=0:8, shift=(origocc)] plot(\x,{\Qmag}); % Q
- \draw[color=violet,thick,,smooth,domain=0:8, shift=(origocc)] plot(\x,{\Dmag}); % D
- \draw[color=orange,dashed] (0,\OrigoYc+\Qmag cm)-- (-0.3,\OrigoYc+\Qmag cm) node[anchor=east] {$i_q$}; %d line to y axis
- \draw[color=violet,dashed] (0,\OrigoYc+\Dmag cm)-- (-0.3,\OrigoYc+\Dmag cm) node[anchor=east] {$i_d$}; %q line to y axis
- %% Rotor Flux Vector%
- \coordinate (rfluxtipc) at (\PhaseBlackc-\Osv:\R); %Tip of rotor flux
- \draw[->,color=gray] (origoc) -- ++(rfluxtipc) node[label={[label distance=-0.18cm]\PhaseBlack-\Osv: $\lambda_r$}] {}; %Bottom Rotor Flux Phasor
- %WAVE FORM%
- \draw[->, color=black] (0,\OrigoYc) -- (9,\OrigoYc) node[anchor=west] {$\theta$}; %X axis bottom
- \draw[->, color=black] (0,\OrigoYc-\Vs cm) -- (0,\OrigoYc+\Vs cm) node[anchor=south] {$i$}; %Y axis bottom
- \draw[help lines] (0,\OrigoYc-\Vs cm) grid (9 ,\OrigoYc+\Vs cm); %Grid middle
- %X Axis tick marks
- \foreach \x in {1, 2,...,8} {
- \pgfmathsetmacro \tick {\x * 45};
- \draw (\x cm,\OrigoYc-1pt) -- (\x cm,\OrigoYc+1pt) node[anchor=north] {\small\pgfmathprintnumber[fixed, precision=10]{\tick}$^{\circ}$};
- }
- %Marker to illustrate angle position over wave forms
- \draw[color=black] (\Marker cm,\OrigoYc+\Vs cm) -- (\Marker cm, \OrigoYc-\Vs cm) node[anchor=north,align=center]{Current \\ position: \\ $\Angle^{\circ}$};
- %Top and bottom border, extending to circle top and and bottom
- \draw[color=gray] (\OrigoX,\OrigoYc+\Vs cm) -- (9,\OrigoYc+\Vs cm) ; %X axis TOP outer
- \draw[color=gray] (\OrigoX,\OrigoYc-\Vs cm) -- (9,\OrigoYc-\Vs cm) ; %X axis bottom outer
- \end{tikzpicture}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement