Advertisement
Guest User

LaTeX Animation of space vector pwm

a guest
Apr 23rd, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Latex 48.96 KB | None | 0 0
  1. \documentclass[tikz,border=10pt]{standalone}
  2. \usepackage{ifthen}
  3. \usepackage{pgfplots}
  4. \usepackage{amsmath} % Required for \varPsi below
  5. \usepackage{tikz}
  6. \usepackage{animate}
  7. \usetikzlibrary{calc}
  8. \usepackage{etoolbox}
  9. \usepackage[europeanresistors,americaninductors,americanvoltage,smartlabels]{circuitikz}
  10.  
  11.  
  12. \ctikzset{bipoles/thickness=1}
  13. \ctikzset{bipoles/length=0.8cm}
  14. \ctikzset{bipoles/diode/height=.375}
  15. \ctikzset{bipoles/diode/width=.3}
  16. \ctikzset{tripoles/thyristor/height=.8}
  17. \ctikzset{tripoles/thyristor/width=1}
  18. \ctikzset{bipoles/vsourceam/height/.initial=.7}
  19. \ctikzset{bipoles/vsourceam/width/.initial=.7}
  20. \tikzstyle{every node}=[font=\small]
  21. \tikzstyle{every path}=[line width=0.8pt,line cap=round,line join=round]
  22. \usetikzlibrary{calc,quotes,babel,angles}
  23.  
  24.  
  25. \pgfplotsset{compat=1.9}
  26.  
  27. \usetikzlibrary{calc, intersections}
  28.  
  29. \newcommand{\gettikzxy}[3]{%
  30.   \tikz@scan@one@point\pgfutil@firstofone#1\relax
  31.   \edef#2{\the\pgf@x}%
  32.   \edef#3{\the\pgf@y}%
  33. }
  34.  
  35. \makeatletter
  36. %\newcommand*{\getlength}[1]{\strip@pt#1}
  37. % Or rounded back to `cm` (there will be some rounding errors!)
  38. \newcommand*{\getlength}[1]{\strip@pt\dimexpr0.035146\dimexpr#1\relax\relax}
  39.  
  40. \makeatother
  41.  
  42. \begin{document}
  43.     \foreach \angle in {1,5,...,360}{    %Create all the frames with different angle  (DEFAULT IS {1,2,...,360} - but that takes about 20min rendering time - testing: {0,45,90,135,180,225,270,315,360})
  44.        
  45.         \begin{tikzpicture}
  46.        
  47.        
  48.         %Definitions - These can be changed to create new figures%
  49.         %===========================================================
  50.         \pgfmathsetmacro \Vmax {1.5}; %Max phase voltage (in cm) (8/3 or 2.667 cm is default as that will create a 4 cm space vector)
  51.         \def \Angle {\angle}; %Angle with regards to phase A
  52.         \def \Osv {35}; %Angle of d-axis wrt space vector
  53.         \def \R {2.5}; %Magnitude of rotor flux in cm
  54.        
  55.        
  56.        
  57.         %Calculated variables. These should not be changed unless you know what you are doing%
  58.         %===========================================================
  59.         \pgfmathsetmacro \Vs {\Vmax * 1.5};  %Magnitude of space vector in cm
  60.         \pgfmathsetmacro \MaxLin {\Vs * cos{30}}; %Magnitude before overmodulation
  61.         \pgfmathsetmacro \Qmag {\Vs * sin{\Osv})}; %Magnitude of Q axis
  62.         \pgfmathsetmacro \Dmag {\Vs * cos{\Osv})}; %Magnitude of Q axis
  63.         \pgfmathsetmacro \Marker {\Angle/45)};
  64.         %\pgfmathsetmacro \Vmax {\Vs * 2/3}; %Max phase voltage (OLD)
  65.         \def \Axisheight {\Vmax *3};
  66.         \pgfmathsetmacro \Va {\Vmax * cos{(\Angle+0)}}; %Magnitude of phase A at angle \Angle
  67.         \pgfmathsetmacro \Vaa {\Va * cos{(\angle+0)}}; %Magnitude of phase A at angle \Angle
  68.         \pgfmathsetmacro \Vb {\Vmax * cos{(\Angle-120)}}; %Magnitude of phase B at angle \Angle
  69.         \pgfmathsetmacro \Vbb {\Vb * cos{(\angle-120)}}; %Magnitude of phase B at angle \Angle
  70.         \pgfmathsetmacro \Vc {\Vmax * cos{(\Angle-240)}}; %Magnitude of phase C at angle \Angle
  71.         \pgfmathsetmacro \Vcc {\Vc * cos{(\angle-240)}}; %Magnitude of phase C at angle \Angle
  72.         \pgfmathsetmacro \Radius {\Vmax}; %Radius of maximum line to line voltage output
  73.        
  74.        
  75.         %Locations%
  76.         %===========================================================
  77.         \def \OrigoX {-5 cm}; % If you want to move the circle relative to the wave forms (default -6cm)
  78.         \def \OrigoY {0 cm};
  79.         \coordinate (origo) at (\OrigoX,\OrigoY); %Center of top phasor diagram
  80.         \coordinate (phase_a) at (0:\Va cm); %Tip of phase A
  81.         \coordinate (phase_b) at (120:\Vb cm); %Tip of phase B
  82.         \coordinate (phase_c) at (240:\Vc cm) ; %Tip of phase C
  83.         \coordinate (Y) at (\OrigoX+\Vs cm ,\OrigoY+0); %Where to start the Hexagon
  84.        
  85.        
  86.         %Circle background rings%
  87.         %===========================================================
  88.         \node at (origo) [circle,thick,draw=black!80,fill=red!0, inner sep=0pt,minimum size=\Vs*2 cm] {}; %Top Circle with radius 128%
  89.    
  90.        
  91.         %Black guide lines with angle notation
  92.         \foreach \x in {30,60,...,360} {
  93.             \draw[-,color=black,dotted, thin] (origo)  -- ++(\x:\Vs cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
  94.         }
  95.        
  96.        
  97.        
  98.        
  99.         %=============================================================================================================
  100.         %Actual three phase phasors%
  101.         %=============================================================================================================
  102.        
  103.  
  104.         \node at (origo) [circle,thick,draw=black!80, inner sep=0pt,minimum size=\Vmax*2 cm] {}; %Circle with radius 100%
  105.         \draw[->,color=red, very thick] (origo)  -- ++(phase_a); %Phase A phasor
  106.         \draw[->,color=blue, very thick] (origo)  -- ++(phase_b); %Phase B phasor
  107.         \draw[->,color=green, very thick] (origo)  -- ++(phase_c); %Phase C phasor
  108.        
  109.         %SPACE VECTOR %
  110.         \draw[->,ultra thick,black] (origo) -- ++($(phase_a) + (phase_b) + (phase_c)$) coordinate(Vstip); %Space vector resultant
  111.         \pgfgetlastxy{\XCoord}{\YCoord}; % X and Y coordinates of Space vector tip
  112.        
  113.         %Find space vector angle
  114.         \pgfmathanglebetweenpoints{\pgfpointanchor{origo}{center}}{\pgfpointanchor{Vstip}{center}}
  115.         \let\PhaseBlack\pgfmathresult;
  116.        
  117.         \draw[->,color=blue, thin] (origo) ++(phase_a) -> ++(phase_b); %Resultant help lines
  118.         \draw[->,color=green, thin] (origo) ++(phase_a) ++(phase_b) -> ++(phase_c); %Resultant help lines
  119.  
  120.  
  121.    
  122.    
  123.    
  124.    
  125.    
  126.    
  127.    
  128.    
  129.     \coordinate (OrigoSV) at (-5,-5.5);
  130.     \pgfmathsetmacro{\SVradius}{\Vmax*1.5}
  131.     \draw[black, solid] (OrigoSV) circle (\SVradius);
  132.     \draw[-latex,black, very thick] (OrigoSV) --++ (\angle:2 cm);
  133.    
  134.     %Black guide lines with angle notation
  135. %   \foreach \x in {0,30,60,...,345} {
  136. %       \draw[-,color=black,dotted, thin] (OrigoSV)  -- ++(\x:\SVradius cm) node[label={[label distance=-0.18cm]\x: $\x^{\circ}$}] {};
  137. %   }
  138.    
  139.     %Phasor guide lines%
  140.     \draw[-latex, solid, very thin, dashed] (OrigoSV)  -- ++(0:\SVradius cm)  node [below, align=center, anchor=west]  {$ v_1 $ \\ $ 001 $};
  141.     \draw[-latex, solid, very  thin, dashed] (OrigoSV) -- ++(120:\SVradius cm)  node [above, align=center, anchor=east, yshift=0.3cm]  {$ v_2 $ \\ $ 010 $};
  142.     \draw[-latex, solid, very  thin, dashed] (OrigoSV)  -- ++(240:\SVradius cm)  node [below, align=center, anchor=north, xshift=-0.2cm]  {$ v_4 $ \\ $ 100 $};
  143.    
  144.     \draw[-latex,  solid, very  thin, dashed] (OrigoSV)  -- ++(0:-\SVradius cm) node [below, align=center, anchor=east]  {$ v_6 $ \\ $ 110 $};
  145.     \draw[-latex,  solid, very  thin, dashed] (OrigoSV) -- ++(120:-\SVradius cm)  node [above, align=center, anchor=north, xshift=0.2cm]  {$ v_5 $ \\ $ 101 $};
  146.     \draw[-latex,  solid, very  thin, dashed] (OrigoSV)  -- ++(240:-\SVradius cm) node [below, align=center, anchor=south, xshift=0.2cm]  {$ v_3 $ \\ $ 011 $};
  147.    
  148.    
  149.    
  150.    
  151.    
  152.    
  153.    
  154.    
  155.    
  156.    
  157.    
  158.    
  159.    
  160.    
  161.    
  162.    
  163.    
  164.    
  165.     % Definitions - These can be changed to create new figures
  166.     %===========================================================
  167.  
  168.     % Space vector data
  169.     %\def \Angle {45};      % Desired angle of the space vector
  170.     \def \modindex {1};     % Desired modulation index
  171.     \def \step {5};         % Higher number equals slower triangular wave (max value = 6). Even numbers please.
  172.    
  173.     % Figure variables
  174.     \def \sizex {12};       % Desired length of axes in cm
  175.     \def \sizey {2};        % Desired height of axes in cm
  176.     \def \vertspace {2}     % Desired distaance between axes in cm
  177.     \pgfmathsetmacro \bottom {\sizey * 2 + \vertspace*2.0}
  178.  
  179.    
  180.    
  181.  
  182.    
  183.     % Triangular wave
  184.     %================================================================================================================================================
  185.    
  186.     \pgfmathsetmacro \maxsigzags {\sizex-\step}; % Number of periods of triangular wave
  187.     \draw [name path=zigzag, ultra thick]
  188.     \foreach \x in {0,\step,...,\maxsigzags} {
  189.         (\x,1.5) -- ++(\step/2,-3) -- ++(\step/2,3) -- ++(\step/4,-1.5)
  190.     };
  191.  
  192.     \draw[black,-, thin] (5,2) --++ (0,-11.2);
  193.     \draw[black,-, thin] (10,2) --++ (0,-11.2);
  194.     \draw[<->, black, thick] (5,-9)--++(-5,0) node[midway, below]{$ T $};
  195.     \draw[<->, black, thick] (10,-9)--++(-5,0) node[midway, below]{$ T $};
  196.     \draw[black,-, thin] (2.5,2) --++ (0,-10.7);
  197.     \draw[<->, black, thick] (2.5,-8.5)--++(-2.5,0) node[midway, below]{ \scriptsize $ \frac{1}{2} T $} ;
  198.    
  199.    
  200.    
  201.    
  202.    
  203.    
  204.     % Contol signals
  205.     %================================================================================================================================================
  206.    
  207.     \pgfmathsetmacro \uctrl {\modindex * cos{(\Angle+0)}};
  208.     \pgfmathsetmacro \vctrl {\modindex * cos{(\Angle-120)}};
  209.     \pgfmathsetmacro \wctrl {\modindex * cos{(\Angle-240)}};
  210.    
  211.     \draw[black, very thin] (0,1) node [left] {$ 1 $} --++ (\sizex*0.85,0);
  212.     \draw[black, very thin] (0,-1) node [left] {$ -1 $} --++ (\sizex*0.85,0);
  213.  
  214.    
  215.    
  216.     % U switching
  217.     %================================================================================================================================================
  218.    
  219.     %U-LEG
  220.     \draw [red,thick, name path global=wave-1] (0,\uctrl) node [left, xshift=-0.25cm] {$v_{control,u}$} --++ (\sizex*0.85,0);
  221.    
  222.     \draw [draw=red,fill=red,  fill opacity=0.5,name intersections={of={wave-1} and zigzag, total=\n}]
  223.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,\n} {
  224.         \ifodd\i { }
  225.         \else
  226.             {
  227.                 (intersection-\lasti |- 0,-\vertspace*2) rectangle (intersection-\i |- 0,-\vertspace*2+1)
  228.             }
  229.         \fi
  230.     };
  231.  
  232.     \draw [draw=red!50, dashed, very thin,name intersections={of={wave-1} and zigzag, total=\n}]
  233.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,2} {
  234.         (intersection-\i) -- (intersection-\i|- 0,-\bottom*1.1)
  235.     };
  236.  
  237.     %Code to find the length of X
  238.     \draw [draw=red,thick ,name intersections={of={wave-1} and zigzag, total=\n}]
  239.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  240.     \pgfgetlastxy{\XCoordux}{\YCoordux};
  241.    
  242.     \draw [draw=red,thick ,name intersections={of={wave-1} and zigzag, total=\n}]
  243.     (intersection-2 |- 0,-\bottom*1.5) --++ (0,0);
  244.     \pgfgetlastxy {\XCoorduxx}{\YCoorduxx};
  245.     \pgfmathsetmacro {\xvalue}{\getlength{\XCoorduxx - \XCoordux}/7.4992};
  246.  
  247.     %Code to draw horizontal lines at bottom
  248. %   \draw [latex-latex,draw=red,thick ,name intersections={of={wave-1} and zigzag, total=\n}]
  249. %   \foreach \i [remember=\i as \lasti (initially 3)] in {1,...,\n} {
  250. %       \ifodd\i { }
  251. %       \else
  252. %       {
  253. %           (intersection-\lasti|- 0,-\bottom*1.1) -- (intersection-\i|- 0,-\bottom*1.1) node[midway, below]{$ U = \xvalue $}
  254. %       }
  255. %       \fi
  256. %   };
  257.  
  258.        
  259.        
  260.        
  261.     %V-LEG
  262.     \draw [blue,thick, name path global=wave-2] (0,\vctrl) node [left, xshift=-0.25cm] {$v_{control,v}$}--++ (\sizex*0.85,0);
  263.    
  264.     \draw [draw=blue,fill=blue,  fill opacity=0.5,name intersections={of={wave-2} and zigzag, total=\n}]
  265.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,\n} {
  266.         \ifodd\i { }
  267.         \else
  268.         {
  269.             (intersection-\lasti |- 0,-\vertspace*3) rectangle (intersection-\i |- 0,-\vertspace*3+1)
  270.         }
  271.         \fi
  272.     };
  273.    
  274.     \draw [draw=blue!50,  dashed, very thin,name intersections={of={wave-2} and zigzag, total=\n}]
  275.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,2} {
  276.         (intersection-\i) -- (intersection-\i|- 0,-\bottom*1.1)
  277.     };
  278.    
  279.    
  280.     %Code to find the length of Y
  281.     \draw [draw=red,thick ,name intersections={of={wave-2} and zigzag, total=\n}]
  282.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  283.     \pgfgetlastxy{\XCoordvx}{\YCoordvx};
  284.    
  285.     \draw [draw=red,thick ,name intersections={of={wave-2} and zigzag, total=\n}]
  286.     (intersection-2 |- 0,-\bottom*1.5) --++ (0,0);
  287.     \pgfgetlastxy {\XCoordvxx}{\YCoordvxx};
  288.     \pgfmathsetmacro {\yvalue}{\getlength{\XCoordvxx - \XCoordvx}/7.4992};
  289.    
  290.    
  291. %   \draw [latex-latex,draw=blue,thick ,name intersections={of={wave-2} and zigzag, total=\n}]
  292. %   \foreach \i [remember=\i as \lasti (initially 3)] in {1,...,\n} {
  293. %       \ifodd\i { }
  294. %       \else
  295. %       {
  296. %           (intersection-\lasti|- 0,-\bottom*1.05) -- (intersection-\i|- 0,-\bottom*1.05) node[midway, below]{$ V = \yvalue $}
  297. %       }
  298. %       \fi
  299. %   };
  300.  
  301.  
  302.  
  303.  
  304.     %W-LEG
  305.     \draw [green,thick, name path global=wave-3] (0,\wctrl) node [left, xshift=-0.25cm] {$v_{control,w}$} --++ (\sizex*0.85,0) ;
  306.    
  307.     \draw [draw=green,fill=green,  fill opacity=0.5,name intersections={of={wave-3} and zigzag, total=\n}]
  308.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,\n} {
  309.         \ifodd\i { }
  310.         \else
  311.         {
  312.             (intersection-\lasti |- 0,-\vertspace*4) rectangle (intersection-\i |- 0,-\vertspace*4+1)
  313.         }
  314.         \fi
  315.     };
  316.    
  317.     \draw [draw=green!50, dashed, very thin,name intersections={of={wave-3} and zigzag, total=\n}]
  318.     \foreach \i [remember=\i as \lasti (initially 1)] in {1,...,2} {
  319.         (intersection-\i) -- (intersection-\i|- 0,-\bottom*1.1)
  320.     };
  321.    
  322.    
  323.     %Code to find the length of Z
  324.     \draw [draw=red,thick ,name intersections={of={wave-3} and zigzag, total=\n}]
  325.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  326.     \pgfgetlastxy{\XCoordwx}{\YCoordwx};
  327.    
  328.     \draw [draw=red,thick ,name intersections={of={wave-3} and zigzag, total=\n}]
  329.     (intersection-2 |- 0,-\bottom*1.5) --++ (0,0);
  330.     \pgfgetlastxy {\XCoordwxx}{\YCoordwxx};
  331.     \pgfmathsetmacro {\zvalue}{\getlength{\XCoordwxx - \XCoordwx}/7.4992};
  332.    
  333.    
  334. %   \draw [latex-latex,draw=green,thick ,name intersections={of={wave-3} and zigzag, total=\n}]
  335. %   \foreach \i [remember=\i as \lasti (initially 3)] in {1,...,\n} {
  336. %       \ifodd\i { }
  337. %       \else
  338. %       {
  339. %           (intersection-\lasti|- 0,-\bottom*1.0) -- (intersection-\i|- 0,-\bottom*1.0) node[midway, below]{$ W = \zvalue $}
  340. %       }
  341. %       \fi
  342. %   };
  343.  
  344.  
  345.    
  346. %   \pgfmathsetmacro{\totalxyz}{\xvalue + \yvalue + \zvalue};
  347. %   \pgfmathsetmacro{\totaly}{(\yvalue - \zvalue) / (\xvalue - \zvalue+0.01)};
  348. %   \pgfmathsetmacro{\totalx}{(1-\totaly)};
  349.    
  350. %   \node at (2.8,-\bottom+0.5) {$ U + V + W = \totalxyz  $};
  351.    
  352.    
  353.    
  354.    
  355.    
  356.    
  357.        
  358.     %COORDINATES for v-values below axes
  359.     \draw [draw=red,thick ,name intersections={of={wave-1} and zigzag, total=\n}]
  360.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  361.     \pgfgetlastxy{\XCoordu}{\YCoordu};
  362.     %\node at (-1.5,-9.5) {\scriptsize $ U= \getlength{\XCoordu $}};
  363.     \coordinate (u) at (\XCoordu,-\bottom);
  364.    
  365.     \draw [draw=red,thick ,name intersections={of={wave-2} and zigzag, total=\n}]
  366.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  367.     \pgfgetlastxy{\XCoordv}{\YCoordv};
  368.     %\node at (-1.5,-10) {\scriptsize $ V= \getlength{\XCoordv $}};
  369.     \coordinate (v) at (\XCoordv,-\bottom);
  370.    
  371.     \draw [draw=red,thick ,name intersections={of={wave-3} and zigzag, total=\n}]
  372.     (intersection-1 |- 0,-\bottom*1.5) --++ (0,0);
  373.     \pgfgetlastxy{\XCoordw}{\YCoordw};
  374.     %\node at (-1.5,-10.5) {\scriptsize $ W= \getlength{\XCoordw $}};
  375.     \coordinate (w) at (\XCoordw,-\bottom);
  376.    
  377.    
  378.    
  379.    
  380.    
  381.  
  382.    
  383.    
  384.    
  385.    
  386.     %CALCULATIONS of the different sectors
  387.    
  388.            
  389.         \pgfmathparse{min(\getlength{\XCoordu},\getlength{\XCoordv}, \getlength{\XCoordw})};
  390.         \pgfmathsetmacro{\zerovectora}{(\pgfmathresult/2.5)*100}
  391.         \node[anchor=west] at (-2.5,-8) {$ v_0 = \pgfmathprintnumber[precision=2]{\zerovectora} ~ \% $};
  392.        
  393.         \pgfmathparse{max(\getlength{\XCoordu},\getlength{\XCoordv}, \getlength{\XCoordw})};
  394.         \pgfmathsetmacro{\zerovectorb}{((2.5 - \pgfmathresult )/2.5)*100}
  395.         \node[anchor=west] at (-2.5,-9.5    ) {$ v_7 =  \pgfmathprintnumber[precision=2]{\zerovectorb} ~ \% $};
  396.    
  397.    
  398.    
  399.    
  400.    
  401.    
  402.    
  403.    
  404.    
  405.     %SECTOR 1
  406.     \ifboolexpr{
  407.         test {\ifnumless{\Angle}{60}} and test{\ifnumgreater{\Angle}{0}} or test{\ifnumequal{\Angle}{0}}
  408.         }
  409.     {  
  410.         \ifthenelse{\Angle = 30}
  411.             {
  412.             \pgfmathsetmacro{\totaly}{(0.5)};
  413.             \pgfmathsetmacro{\totalx}{(0.5)};
  414.             }
  415.         {
  416.             \pgfmathsetmacro{\totaly}{(\yvalue - \zvalue) / (\xvalue - \zvalue+0.0001)};
  417.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  418.         }
  419.         \draw[-latex,red, very thick] (OrigoSV) --++ (0:2.25*\totalx cm);
  420.         \draw[-latex,green, very thick] (OrigoSV) --++ (60:2.25*\totaly cm);
  421.         \node[anchor=west] at (-2.5,-3) {$ s = 1  $};
  422.         \node[right, yshift=-0.2cm,red] at (u) {\small $ v_1 $};
  423.         \node[right, yshift=-0.2cm, green] at (v) {\small $ v_3 $};
  424.        
  425.        
  426.        
  427.        
  428.             %POWER electronics A
  429.        
  430.         \def \PEax {-10};
  431.         \def \PEay {-14.5};
  432.         \coordinate (origoPE1) at (\PEax,\PEay);
  433.         \def \DClink {4 cm};
  434.        
  435.         %PROGRESS bar
  436.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  437.        
  438.         \draw[white, fill=red!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  439.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_1 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  440.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  441.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_1 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  442.        
  443.        
  444.         \draw
  445.         % DC sources
  446.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  447.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  448.        
  449.         (LegA) ++ (2,0) coordinate (LegB)
  450.         (LegB) ++ (2,0) coordinate (LegC)
  451.        
  452.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  453.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  454.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  455.        
  456.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  457.         (SwA.out 2) to[short, -*] (LegA)
  458.         (SwA.out 1) to[short, -*, i>=$i_w$, current/distance=0.5, color=black] (LegAs)
  459.        
  460.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  461.         (SwB.out 2) to[short, -*] (LegB)
  462.         (SwB.out 1) to[short, -*, i>=$i_v$, current/distance=0.68] (LegBs)
  463.        
  464.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwC) {}
  465.         (SwC.out 1) to[short, -,color=red, i<=$i_u$,current/distance=0.5 ] (LegC)
  466.         (SwC.out 2) to[short, -,current/distance=0.5] (LegCs)
  467.        
  468.        
  469.         % Motor
  470.        
  471.         (SwA.in) -- ++(4.5,0)
  472.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  473.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  474.         to[R] ++(1.2,0) coordinate (Lright)
  475.         to[short] ++(0.5,0)
  476.         ++(0,-2) coordinate (motorend)
  477.        
  478.         (SwB.in) -- ++(2.5,0)
  479.         to[short, o-, i<=$i_v$, current/distance=0.5] ++(1,0)
  480.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  481.         to[R] ++(1.2,0) coordinate (Lright)
  482.         to[short, -*] ++(0.5,0)
  483.         ++(0,-2)
  484.        
  485.         (SwC.in)  -- ++(0.5,0)
  486.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  487.         to[L,v^=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  488.         to[R] ++(1.2,0) coordinate (Lright)
  489.         to[short] ++(0.5,0)
  490.         to[short] ++(0,-2);    
  491.        
  492.        
  493.         %POWER electronics B
  494.        
  495.         \def \PEbx {2};
  496.         \def \PEby {-14.5};
  497.         \coordinate (origoPE1) at (\PEbx,\PEby);
  498.         \def \DClink {4 cm};
  499.        
  500.         %PROGRESS bar
  501.        
  502.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  503.    
  504.         \draw[white, fill=green!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  505.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_3 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  506.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  507.         \node[anchor=west] at (-2.5,-9  ) {$ v_3 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  508.  
  509.        
  510.         \draw
  511.         % DC sources
  512.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  513.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  514.        
  515.         (LegA) ++ (2,0) coordinate (LegB)
  516.         (LegB) ++ (2,0) coordinate (LegC)
  517.        
  518.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  519.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  520.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  521.        
  522.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  523.         (SwA.out 2) to[short, -*] (LegA)
  524.         (SwA.out 1) to[short, -*, i>=$i_w$, current/distance=0.5, color=black] (LegAs)
  525.        
  526.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  527.         (SwB.out 1) to[short, -*,color=red, i<=$i_v$, current/distance=0.68] (LegB)
  528.         (SwB.out 2) to[short, -*,] (LegBs)
  529.        
  530.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwC) {}
  531.         (SwC.out 1) to[short, -,color=red, i<=$i_u$,current/distance=0.5 ] (LegC)
  532.         (SwC.out 2) to[short, -,current/distance=0.5] (LegCs)
  533.        
  534.        
  535.         % Motor
  536.        
  537.         (SwA.in) -- ++(4.5,0)
  538.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  539.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  540.         to[R] ++(1.2,0) coordinate (Lright)
  541.         to[short] ++(0.5,0)
  542.         ++(0,-2) coordinate (motorend)
  543.        
  544.         (SwB.in) -- ++(2.5,0)
  545.         to[short, o-, color=red,i>=$i_v$, current/distance=0.7] ++(1,0)
  546.         to[L,v^<=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  547.         to[R] ++(1.2,0) coordinate (Lright)
  548.         to[short, -*] ++(0.5,0)
  549.         ++(0,-2)
  550.        
  551.         (SwC.in)  -- ++(0.5,0)
  552.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  553.         to[L,v^=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  554.         to[R] ++(1.2,0) coordinate (Lright)
  555.         to[short] ++(0.5,0)
  556.         to[short] ++(0,-2);    
  557.        
  558.        
  559.        
  560.        
  561.        
  562.     }
  563.    
  564.     {}
  565.        
  566.    
  567.     %SECTOR 2
  568.     \ifboolexpr{
  569.         test {\ifnumless{\Angle}{120}} and test{\ifnumgreater{\Angle}{60}} or test{\ifnumequal{\Angle}{60}}
  570.     }
  571.     {  
  572.         \ifthenelse{\Angle = 90}
  573.         {
  574.             \pgfmathsetmacro{\totaly}{(0.5)};
  575.             \pgfmathsetmacro{\totalx}{(0.5)};
  576.         }
  577.         {
  578.             \pgfmathsetmacro{\totaly}{(\xvalue - \zvalue) / (\yvalue - \zvalue+0.0001)};
  579.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  580.         }
  581.         \draw[-latex,green, very thick] (OrigoSV) --++ (60:2.25*\totaly cm);
  582.         \draw[-latex,blue, very thick] (OrigoSV) --++ (120:2.25*\totalx cm);
  583.         \node[anchor=west] at (-2.5,-3) {$ s = 2  $};
  584.         \node[right, yshift=-0.2cm,blue] at (v) {\small $ v_2 $};
  585.         \node[right, yshift=-0.2cm,green] at (u) {\small $ v_3 $};
  586.        
  587.        
  588.             %POWER electronics A
  589.        
  590.         \def \PEax {-10};
  591.         \def \PEay {-14.5};
  592.         \coordinate (origoPE1) at (\PEax,\PEay);
  593.         \def \DClink {4 cm};
  594.        
  595.         %PROGRESS bar
  596.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  597.        
  598.         \draw[white, fill=blue!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  599.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_2 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  600.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  601.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_2 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  602.        
  603.        
  604.         \draw
  605.         % DC sources
  606.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  607.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  608.        
  609.         (LegA) ++ (2,0) coordinate (LegB)
  610.         (LegB) ++ (2,0) coordinate (LegC)
  611.        
  612.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  613.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  614.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  615.        
  616.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  617.         (SwA.out 2) to[short, -*] (LegA)
  618.         (SwA.out 1) to[short, -*, i>=$i_w$, current/distance=0.5, color=black] (LegAs)
  619.        
  620.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  621.         (SwB.out 1) to[short, -*,,color=red, i<=$i_u$,current/distance=0.5 ] (LegB)
  622.         (SwB.out 2) to[short, -*] (LegBs)
  623.        
  624.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180,  anchor=in, yscale=1](SwC) {}
  625.         (SwC.out 2) to[short, -] (LegC)
  626.         (SwC.out 1) to[short, -, i>=$i_v$, current/distance=0.77] (LegCs)
  627.        
  628.        
  629.         % Motor
  630.        
  631.         (SwA.in) -- ++(4.5,0)
  632.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  633.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  634.         to[R] ++(1.2,0) coordinate (Lright)
  635.         to[short] ++(0.5,0)
  636.         ++(0,-2) coordinate (motorend)
  637.        
  638.         (SwB.in) -- ++(2.5,0)
  639.         to[short, o-,color=red, i>=$i_v$, current/distance=0.5] ++(1,0)
  640.         to[L,v^=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  641.         to[R] ++(1.2,0) coordinate (Lright)
  642.         to[short, -*] ++(0.5,0)
  643.         ++(0,-2)
  644.        
  645.         (SwC.in)  -- ++(0.5,0)
  646.         to[short, o-, i<=$i_u$, current/distance=0.7] ++(1,0)
  647.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  648.         to[R] ++(1.2,0) coordinate (Lright)
  649.         to[short] ++(0.5,0)
  650.         to[short] ++(0,-2);      
  651.        
  652.        
  653.         %POWER electronics B
  654.        
  655.         \def \PEbx {2};
  656.         \def \PEby {-14.5};
  657.         \coordinate (origoPE1) at (\PEbx,\PEby);
  658.         \def \DClink {4 cm};
  659.        
  660.         %PROGRESS bar
  661.        
  662.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  663.        
  664.         \draw[white, fill=green!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  665.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_3 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  666.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  667.         \node[anchor=west] at (-2.5,-9  ) {$ v_3 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  668.        
  669.        
  670.         \draw
  671.         % DC sources
  672.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  673.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  674.        
  675.         (LegA) ++ (2,0) coordinate (LegB)
  676.         (LegB) ++ (2,0) coordinate (LegC)
  677.        
  678.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  679.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  680.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  681.        
  682.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  683.         (SwA.out 2) to[short, -*] (LegA)
  684.         (SwA.out 1) to[short, -*, i>=$i_w$, current/distance=0.5, color=black] (LegAs)
  685.        
  686.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  687.         (SwB.out 1) to[short, -*,color=red, i<=$i_v$, current/distance=0.68] (LegB)
  688.         (SwB.out 2) to[short, -*,] (LegBs)
  689.        
  690.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwC) {}
  691.         (SwC.out 1) to[short, -,color=red, i<=$i_u$,current/distance=0.5 ] (LegC)
  692.         (SwC.out 2) to[short, -,current/distance=0.5] (LegCs)
  693.        
  694.        
  695.         % Motor
  696.        
  697.         (SwA.in) -- ++(4.5,0)
  698.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  699.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  700.         to[R] ++(1.2,0) coordinate (Lright)
  701.         to[short] ++(0.5,0)
  702.         ++(0,-2) coordinate (motorend)
  703.        
  704.         (SwB.in) -- ++(2.5,0)
  705.         to[short, o-, color=red,i>=$i_v$, current/distance=0.7] ++(1,0)
  706.         to[L,v^<=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  707.         to[R] ++(1.2,0) coordinate (Lright)
  708.         to[short, -*] ++(0.5,0)
  709.         ++(0,-2)
  710.        
  711.         (SwC.in)  -- ++(0.5,0)
  712.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  713.         to[L,v^=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  714.         to[R] ++(1.2,0) coordinate (Lright)
  715.         to[short] ++(0.5,0)
  716.         to[short] ++(0,-2);    
  717.        
  718.        
  719.        
  720.        
  721.     }
  722.     {}
  723.    
  724.  
  725.        
  726.     %SECTOR 3
  727.     \ifboolexpr{
  728.         test {\ifnumless{\Angle}{180}} and test{\ifnumgreater{\Angle}{120}} or test{\ifnumequal{\Angle}{120}}
  729.     }
  730.     {  
  731.         \ifthenelse{\Angle = 150}
  732.         {
  733.             \pgfmathsetmacro{\totaly}{(0.5)};
  734.             \pgfmathsetmacro{\totalx}{(0.5)};
  735.         }
  736.         {
  737.             \pgfmathsetmacro{\totaly}{(\zvalue - \xvalue) / (\yvalue - \xvalue+0.0001)};
  738.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  739.         }
  740.         \draw[-latex,blue, very thick] (OrigoSV) --++ (120:2.25*\totalx cm);
  741.         \draw[-latex,red, very thick] (OrigoSV) --++ (180:2.25*\totaly cm);
  742.         \node[anchor=west] at (-2.5,-3) {$ s = 3  $};
  743.         \node[right, yshift=-0.2cm,blue] at (v) {\small $ v_2 $};
  744.         \node[right, yshift=-0.2cm,red] at (w) {\small $ v_6 $};
  745.        
  746.        
  747.             %POWER electronics A
  748.        
  749.         \def \PEax {-10};
  750.         \def \PEay {-14.5};
  751.         \coordinate (origoPE1) at (\PEax,\PEay);
  752.         \def \DClink {4 cm};
  753.        
  754.         %PROGRESS bar
  755.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  756.        
  757.         \draw[white, fill=blue!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  758.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_2 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  759.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  760.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_2 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  761.        
  762.        
  763.         \draw
  764.         % DC sources
  765.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  766.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  767.        
  768.         (LegA) ++ (2,0) coordinate (LegB)
  769.         (LegB) ++ (2,0) coordinate (LegC)
  770.        
  771.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  772.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  773.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  774.        
  775.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  776.         (SwA.out 2) to[short, -*] (LegA)
  777.         (SwA.out 1) to[short, -*, i>=$i_w$, current/distance=0.5, color=black] (LegAs)
  778.        
  779.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  780.         (SwB.out 1) to[short, -*,,color=red, i<=$i_u$,current/distance=0.5 ] (LegB)
  781.         (SwB.out 2) to[short, -*] (LegBs)
  782.        
  783.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180,  anchor=in, yscale=1](SwC) {}
  784.         (SwC.out 2) to[short, -] (LegC)
  785.         (SwC.out 1) to[short, -, i>=$i_v$, current/distance=0.77] (LegCs)
  786.        
  787.        
  788.         % Motor
  789.        
  790.         (SwA.in) -- ++(4.5,0)
  791.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  792.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  793.         to[R] ++(1.2,0) coordinate (Lright)
  794.         to[short] ++(0.5,0)
  795.         ++(0,-2) coordinate (motorend)
  796.        
  797.         (SwB.in) -- ++(2.5,0)
  798.         to[short, o-,color=red, i>=$i_v$, current/distance=0.5] ++(1,0)
  799.         to[L,v^=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  800.         to[R] ++(1.2,0) coordinate (Lright)
  801.         to[short, -*] ++(0.5,0)
  802.         ++(0,-2)
  803.        
  804.         (SwC.in)  -- ++(0.5,0)
  805.         to[short, o-, i<=$i_u$, current/distance=0.7] ++(1,0)
  806.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  807.         to[R] ++(1.2,0) coordinate (Lright)
  808.         to[short] ++(0.5,0)
  809.         to[short] ++(0,-2);      
  810.        
  811.        
  812.         %POWER electronics B
  813.        
  814.         \def \PEbx {2};
  815.         \def \PEby {-14.5};
  816.         \coordinate (origoPE1) at (\PEbx,\PEby);
  817.         \def \DClink {4 cm};
  818.        
  819.         %PROGRESS bar
  820.        
  821.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  822.        
  823.         \draw[white, fill=red!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  824.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_6 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  825.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  826.         \node[anchor=west] at (-2.5,-9  ) {$ v_6 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  827.        
  828.        
  829.         \draw
  830.         % DC sources
  831.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  832.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  833.        
  834.         (LegA) ++ (2,0) coordinate (LegB)
  835.         (LegB) ++ (2,0) coordinate (LegC)
  836.        
  837.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  838.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  839.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  840.        
  841.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  842.         (SwA.out 1) to[short, -*,color=red, i<=$i_w$, current/distance=0.5,] (LegA)
  843.         (SwA.out 2) to[short, -*, color=black] (LegAs)
  844.        
  845.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  846.         (SwB.out 1) to[short, -*,color=red, i<=$i_v$, current/distance=0.68] (LegB)
  847.         (SwB.out 2) to[short, -*,] (LegBs)
  848.        
  849.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180, anchor=in, yscale=1](SwC) {}
  850.         (SwC.out 2) to[short, -] (LegC)
  851.         (SwC.out 1) to[short, -, i>=$i_u$,current/distance=0.77] (LegCs)
  852.        
  853.        
  854.         % Motor
  855.        
  856.         (SwA.in) -- ++(4.5,0)
  857.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  858.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  859.         to[R] ++(1.2,0) coordinate (Lright)
  860.         to[short] ++(0.5,0)
  861.         ++(0,-2) coordinate (motorend)
  862.        
  863.         (SwB.in) -- ++(2.5,0)
  864.         to[short, o-, color=red,i>=$i_v$, current/distance=0.7] ++(1,0)
  865.         to[L,v^<=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  866.         to[R] ++(1.2,0) coordinate (Lright)
  867.         to[short, -*] ++(0.5,0)
  868.         ++(0,-2)
  869.        
  870.         (SwC.in)  -- ++(0.5,0)
  871.         to[short, o-, i<=$i_u$, current/distance=0.5] ++(1,0)
  872.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  873.         to[R] ++(1.2,0) coordinate (Lright)
  874.         to[short] ++(0.5,0)
  875.         to[short] ++(0,-2);    
  876.        
  877.     }
  878.     {}
  879.    
  880.  
  881.  
  882.     %SECTOR 4
  883.     \ifboolexpr{
  884.         test {\ifnumless{\Angle}{240}} and test{\ifnumgreater{\Angle}{180}} or test{\ifnumequal{\Angle}{180}}
  885.     }
  886.     {  
  887.         \ifthenelse{\Angle = 210}
  888.         {
  889.             \pgfmathsetmacro{\totaly}{(0.5)};
  890.             \pgfmathsetmacro{\totalx}{(0.5)};
  891.         }
  892.         {
  893.             \pgfmathsetmacro{\totaly}{(\yvalue - \xvalue) / (\zvalue - \xvalue+0.0001)};
  894.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  895.         }
  896.         \draw[-latex,red, very thick] (OrigoSV) --++ (180:2.25*\totaly cm);
  897.         \draw[-latex,green, very thick] (OrigoSV) --++ (240:2.25*\totalx cm);
  898.         \node[anchor=west] at (-2.5,-3) {$ s = 4  $};
  899.         \node[right, yshift=-0.2cm,green] at (w) {\small $ v_4 $};
  900.         \node[right, yshift=-0.2cm, red] at (v) {\small $ v_6 $};
  901.        
  902.             %POWER electronics A
  903.        
  904.         \def \PEax {-10};
  905.         \def \PEay {-14.5};
  906.         \coordinate (origoPE1) at (\PEax,\PEay);
  907.         \def \DClink {4 cm};
  908.        
  909.         %PROGRESS bar
  910.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  911.        
  912.         \draw[white, fill=green!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  913.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_4 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  914.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  915.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_4 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  916.        
  917.        
  918.         \draw
  919.         % DC sources
  920.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  921.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  922.        
  923.         (LegA) ++ (2,0) coordinate (LegB)
  924.         (LegB) ++ (2,0) coordinate (LegC)
  925.        
  926.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  927.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  928.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  929.        
  930.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  931.         (SwA.out 1) to[short, -*, i<=$i_w$, current/distance=0.5, color=red] (LegA)
  932.         (SwA.out 2) to[short, -*] (LegAs)
  933.        
  934.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  935.         (SwB.out 2) to[short, -*,] (LegB)
  936.         (SwB.out 1) to[short, -*,, i>=$i_u$,current/distance=0.68 ] (LegBs)
  937.        
  938.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180,  anchor=in, yscale=1](SwC) {}
  939.         (SwC.out 2) to[short, -] (LegC)
  940.         (SwC.out 1) to[short, -, i>=$i_v$, current/distance=0.77] (LegCs)
  941.        
  942.        
  943.         % Motor
  944.        
  945.         (SwA.in) -- ++(4.5,0)
  946.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  947.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  948.         to[R] ++(1.2,0) coordinate (Lright)
  949.         to[short] ++(0.5,0)
  950.         ++(0,-2) coordinate (motorend)
  951.        
  952.         (SwB.in) -- ++(2.5,0)
  953.         to[short, o-, i<=$i_v$, current/distance=0.5] ++(1,0)
  954.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  955.         to[R] ++(1.2,0) coordinate (Lright)
  956.         to[short, -*] ++(0.5,0)
  957.         ++(0,-2)
  958.        
  959.         (SwC.in)  -- ++(0.5,0)
  960.         to[short, o-, i<=$i_u$, current/distance=0.5] ++(1,0)
  961.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  962.         to[R] ++(1.2,0) coordinate (Lright)
  963.         to[short] ++(0.5,0)
  964.         to[short] ++(0,-2);      
  965.        
  966.        
  967.         %POWER electronics B
  968.        
  969.         \def \PEbx {2};
  970.         \def \PEby {-14.5};
  971.         \coordinate (origoPE1) at (\PEbx,\PEby);
  972.         \def \DClink {4 cm};
  973.        
  974.         %PROGRESS bar
  975.        
  976.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  977.        
  978.         \draw[white, fill=red!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  979.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_6 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  980.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  981.         \node[anchor=west] at (-2.5,-9  ) {$ v_6 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  982.        
  983.        
  984.         \draw
  985.         % DC sources
  986.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  987.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  988.        
  989.         (LegA) ++ (2,0) coordinate (LegB)
  990.         (LegB) ++ (2,0) coordinate (LegC)
  991.        
  992.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  993.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  994.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  995.        
  996.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  997.         (SwA.out 1) to[short, -*,color=red, i<=$i_w$, current/distance=0.5,] (LegA)
  998.         (SwA.out 2) to[short, -*, color=black] (LegAs)
  999.        
  1000.         (LegB) node[above,red]{\Large $ 1 $} ++(1.18,-2) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwB) {}
  1001.         (SwB.out 1) to[short, -*,color=red, i<=$i_v$, current/distance=0.68] (LegB)
  1002.         (SwB.out 2) to[short, -*,] (LegBs)
  1003.        
  1004.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180, anchor=in, yscale=1](SwC) {}
  1005.         (SwC.out 2) to[short, -] (LegC)
  1006.         (SwC.out 1) to[short, -, i>=$i_u$,current/distance=0.77] (LegCs)
  1007.        
  1008.        
  1009.         % Motor
  1010.        
  1011.         (SwA.in) -- ++(4.5,0)
  1012.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  1013.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  1014.         to[R] ++(1.2,0) coordinate (Lright)
  1015.         to[short] ++(0.5,0)
  1016.         ++(0,-2) coordinate (motorend)
  1017.        
  1018.         (SwB.in) -- ++(2.5,0)
  1019.         to[short, o-, color=red,i>=$i_v$, current/distance=0.7] ++(1,0)
  1020.         to[L,v^<=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  1021.         to[R] ++(1.2,0) coordinate (Lright)
  1022.         to[short, -*] ++(0.5,0)
  1023.         ++(0,-2)
  1024.        
  1025.         (SwC.in)  -- ++(0.5,0)
  1026.         to[short, o-, i<=$i_u$, current/distance=0.5] ++(1,0)
  1027.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  1028.         to[R] ++(1.2,0) coordinate (Lright)
  1029.         to[short] ++(0.5,0)
  1030.         to[short] ++(0,-2);  
  1031.        
  1032.     }
  1033.     {} 
  1034.    
  1035.     %SECTOR 5
  1036.     \ifboolexpr{
  1037.         test {\ifnumless{\Angle}{300}} and test{\ifnumgreater{\Angle}{240}} or test{\ifnumequal{\Angle}{240}}
  1038.     }
  1039.     {  
  1040.         \ifthenelse{\Angle = 270}
  1041.         {
  1042.             \pgfmathsetmacro{\totaly}{(0.5)};
  1043.             \pgfmathsetmacro{\totalx}{(0.5)};
  1044.         }
  1045.         {
  1046.             \pgfmathsetmacro{\totaly}{(\xvalue - \yvalue) / (\zvalue - \yvalue+0.0001)};
  1047.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  1048.         }
  1049.         \draw[-latex,green, very thick] (OrigoSV) --++ (240:2.25*\totalx cm);
  1050.         \draw[-latex,blue, very thick] (OrigoSV) --++ (300:2.25*\totaly cm);
  1051.         \node[anchor=west] at (-2.5,-3) {$ s = 5  $};
  1052.         \node[right, yshift=-0.2cm,green] at (w) {\small $ v_4 $};
  1053.         \node[right, yshift=-0.2cm, blue] at (u) {\small $ v_5 $};
  1054.        
  1055.        
  1056.             %POWER electronics A
  1057.        
  1058.         \def \PEax {-10};
  1059.         \def \PEay {-14.5};
  1060.         \coordinate (origoPE1) at (\PEax,\PEay);
  1061.         \def \DClink {4 cm};
  1062.        
  1063.         %PROGRESS bar
  1064.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  1065.        
  1066.         \draw[white, fill=green!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  1067.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_4 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  1068.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  1069.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_4 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  1070.        
  1071.        
  1072.         \draw
  1073.         % DC sources
  1074.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  1075.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  1076.        
  1077.         (LegA) ++ (2,0) coordinate (LegB)
  1078.         (LegB) ++ (2,0) coordinate (LegC)
  1079.        
  1080.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  1081.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  1082.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  1083.        
  1084.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  1085.         (SwA.out 1) to[short, -*, i<=$i_w$, current/distance=0.5, color=red] (LegA)
  1086.         (SwA.out 2) to[short, -*] (LegAs)
  1087.        
  1088.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  1089.         (SwB.out 2) to[short, -*,] (LegB)
  1090.         (SwB.out 1) to[short, -*,, i>=$i_u$,current/distance=0.68 ] (LegBs)
  1091.        
  1092.         (LegC) node[above]{\Large $ 0 $} ++(1.18,-1) node [spdt, rotate=180,  anchor=in, yscale=1](SwC) {}
  1093.         (SwC.out 2) to[short, -] (LegC)
  1094.         (SwC.out 1) to[short, -, i>=$i_v$, current/distance=0.77] (LegCs)
  1095.        
  1096.        
  1097.         % Motor
  1098.        
  1099.         (SwA.in) -- ++(4.5,0)
  1100.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  1101.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  1102.         to[R] ++(1.2,0) coordinate (Lright)
  1103.         to[short] ++(0.5,0)
  1104.         ++(0,-2) coordinate (motorend)
  1105.        
  1106.         (SwB.in) -- ++(2.5,0)
  1107.         to[short, o-, i<=$i_v$, current/distance=0.5] ++(1,0)
  1108.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  1109.         to[R] ++(1.2,0) coordinate (Lright)
  1110.         to[short, -*] ++(0.5,0)
  1111.         ++(0,-2)
  1112.        
  1113.         (SwC.in)  -- ++(0.5,0)
  1114.         to[short, o-, i<=$i_u$, current/distance=0.5] ++(1,0)
  1115.         to[L,v^>=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  1116.         to[R] ++(1.2,0) coordinate (Lright)
  1117.         to[short] ++(0.5,0)
  1118.         to[short] ++(0,-2);      
  1119.        
  1120.        
  1121.         %POWER electronics B
  1122.        
  1123.         \def \PEbx {2};
  1124.         \def \PEby {-14.5};
  1125.         \coordinate (origoPE1) at (\PEbx,\PEby);
  1126.         \def \DClink {4 cm};
  1127.        
  1128.         %PROGRESS bar
  1129.        
  1130.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  1131.        
  1132.         \draw[white, fill=blue!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  1133.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_5 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  1134.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  1135.         \node[anchor=west] at (-2.5,-9  ) {$ v_5 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  1136.        
  1137.        
  1138.         \draw
  1139.         % DC sources
  1140.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  1141.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  1142.        
  1143.         (LegA) ++ (2,0) coordinate (LegB)
  1144.         (LegB) ++ (2,0) coordinate (LegC)
  1145.        
  1146.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  1147.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  1148.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  1149.        
  1150.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  1151.         (SwA.out 1) to[short, -*,color=red, i<=$i_w$, current/distance=0.5,] (LegA)
  1152.         (SwA.out 2) to[short, -*, color=black] (LegAs)
  1153.        
  1154.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  1155.         (SwB.out 2) to[short, -*] (LegB)
  1156.         (SwB.out 1) to[short, -*,i>=$i_v$, current/distance=0.68] (LegBs)
  1157.        
  1158.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwC) {}
  1159.         (SwC.out 1) to[short, -, i<=$i_u$,current/distance=0.5, color=red] (LegC)
  1160.         (SwC.out 2) to[short, -] (LegCs)
  1161.        
  1162.        
  1163.         % Motor
  1164.        
  1165.         (SwA.in) -- ++(4.5,0)
  1166.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  1167.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  1168.         to[R] ++(1.2,0) coordinate (Lright)
  1169.         to[short] ++(0.5,0)
  1170.         ++(0,-2) coordinate (motorend)
  1171.        
  1172.         (SwB.in) -- ++(2.5,0)
  1173.         to[short, o-,i<=$i_v$, current/distance=0.5] ++(1,0)
  1174.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  1175.         to[R] ++(1.2,0) coordinate (Lright)
  1176.         to[short, -*] ++(0.5,0)
  1177.         ++(0,-2)
  1178.        
  1179.         (SwC.in)  -- ++(0.5,0)
  1180.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  1181.         to[L,v^<=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  1182.         to[R] ++(1.2,0) coordinate (Lright)
  1183.         to[short] ++(0.5,0)
  1184.         to[short] ++(0,-2);  
  1185.        
  1186.        
  1187.     }
  1188.     {} 
  1189.    
  1190.     %SECTOR 6
  1191.     \ifboolexpr{
  1192.         test {\ifnumless{\Angle}{361}} and test{\ifnumgreater{\Angle}{300}} or test{\ifnumequal{\Angle}{300}}
  1193.     }
  1194.     {  
  1195.         \ifthenelse{\Angle = 330}
  1196.         {
  1197.             \pgfmathsetmacro{\totaly}{(0.5)};
  1198.             \pgfmathsetmacro{\totalx}{(0.5)};
  1199.         }
  1200.         {
  1201.             \pgfmathsetmacro{\totaly}{(\zvalue - \yvalue) / (\xvalue - \yvalue+0.0001)};
  1202.             \pgfmathsetmacro{\totalx}{(1-\totaly)};
  1203.         }
  1204.         \draw[-latex,blue, very thick] (OrigoSV) --++ (300:2.25*\totaly cm);
  1205.         \draw[-latex,red, very thick] (OrigoSV) --++ (360:2.25*\totalx cm);
  1206.         \node[anchor=west] at (-2.5,-3) {$ s = 6  $};
  1207.         \node[right, yshift=-0.2cm,red] at (u) {\small $ v_1 $};
  1208.         \node[right, yshift=-0.2cm, blue] at (w) {\small $ v_5 $};
  1209.        
  1210.        
  1211.             %POWER electronics A
  1212.        
  1213.         \def \PEax {-10};
  1214.         \def \PEay {-14.5};
  1215.         \coordinate (origoPE1) at (\PEax,\PEay);
  1216.         \def \DClink {4 cm};
  1217.        
  1218.         %PROGRESS bar
  1219.         \pgfmathsetmacro{\xpercent}{\totalx*100}
  1220.        
  1221.         \draw[white, fill=red!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totalx,0.15);
  1222.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_1 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\xpercent} ~ \% $};
  1223.         \pgfmathsetmacro{\realvectora}{(100-\zerovectora-\zerovectorb)*\xpercent/100}
  1224.         \node[anchor=west] at (-2.5,-8.5    ) {$ v_1 = \pgfmathprintnumber[precision=1]{\realvectora} ~ \% $};
  1225.        
  1226.        
  1227.         \draw
  1228.         % DC sources
  1229.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  1230.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  1231.        
  1232.         (LegA) ++ (2,0) coordinate (LegB)
  1233.         (LegB) ++ (2,0) coordinate (LegC)
  1234.        
  1235.         (origoPE1) to (\PEax+1,\PEay) coordinate (LegAs)
  1236.         (origoPE1) to (\PEax+3,\PEay) coordinate (LegBs)
  1237.         (origoPE1) to (\PEax+5,\PEay) coordinate (LegCs)
  1238.        
  1239.         (LegA) node[above]{\Large $ 0 $} ++(1.18,-3) node [spdt, rotate=180, anchor=in, yscale=1](SwA) {}
  1240.         (SwA.out 2) to[short, -*] (LegA)
  1241.         (SwA.out 1) to[short, -*, i>=$i_w$] (LegAs)
  1242.        
  1243.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  1244.         (SwB.out 2) to[short, -*,] (LegB)
  1245.         (SwB.out 1) to[short, -*, i>=$i_v$,current/distance=0.68 ] (LegBs)
  1246.        
  1247.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red,  anchor=in, yscale=-1](SwC) {}
  1248.         (SwC.out 1) to[short, -,  i<=$i_u$, current/distance=0.5, color=red] (LegC)
  1249.         (SwC.out 2) to[short, -] (LegCs)
  1250.        
  1251.        
  1252.         % Motor
  1253.        
  1254.         (SwA.in) -- ++(4.5,0)
  1255.         to[short, o-, i<=$i_w$, current/distance=0.5] ++(1,0)
  1256.         to[L,v^>=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  1257.         to[R] ++(1.2,0) coordinate (Lright)
  1258.         to[short] ++(0.5,0)
  1259.         ++(0,-2) coordinate (motorend)
  1260.        
  1261.         (SwB.in) -- ++(2.5,0)
  1262.         to[short, o-, i<=$i_v$, current/distance=0.5] ++(1,0)
  1263.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  1264.         to[R] ++(1.2,0) coordinate (Lright)
  1265.         to[short, -*] ++(0.5,0)
  1266.         ++(0,-2)
  1267.        
  1268.         (SwC.in)  -- ++(0.5,0)
  1269.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  1270.         to[L,v^<=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  1271.         to[R] ++(1.2,0) coordinate (Lright)
  1272.         to[short] ++(0.5,0)
  1273.         to[short] ++(0,-2);      
  1274.        
  1275.        
  1276.         %POWER electronics B
  1277.        
  1278.         \def \PEbx {2};
  1279.         \def \PEby {-14.5};
  1280.         \coordinate (origoPE1) at (\PEbx,\PEby);
  1281.         \def \DClink {4 cm};
  1282.        
  1283.         %PROGRESS bar
  1284.        
  1285.         \pgfmathsetmacro{\ypercent}{\totaly*100}
  1286.        
  1287.         \draw[white, fill=blue!50] (origoPE1) ++ (0,4.6) rectangle++ (5*\totaly,0.15);
  1288.         \draw[black!80, very thin] (origoPE1) ++ (0,4.6) node[left]{\large $ v_5 $} rectangle++ (5,0.15) node[color=black!100,right]{\large $ \pgfmathprintnumber[precision=1]{\ypercent} ~ \% $};
  1289.         \pgfmathsetmacro{\realvectorb}{(100-\zerovectora-\zerovectorb)*\ypercent/100}
  1290.         \node[anchor=west] at (-2.5,-9  ) {$ v_5 = \pgfmathprintnumber[precision=1]{\realvectorb} ~ \% $};
  1291.        
  1292.        
  1293.         \draw
  1294.         % DC sources
  1295.         (origoPE1) to[C, l=C,  v^>=$ $] ++(0,4) coordinate (Vcc)
  1296.         -- ++(1,0) coordinate (LegA) -- ++(4,0)
  1297.        
  1298.         (LegA) ++ (2,0) coordinate (LegB)
  1299.         (LegB) ++ (2,0) coordinate (LegC)
  1300.        
  1301.         (origoPE1) to (\PEbx+1,\PEby) coordinate (LegAs)
  1302.         (origoPE1) to (\PEbx+3,\PEby) coordinate (LegBs)
  1303.         (origoPE1) to (\PEbx+5,\PEby) coordinate (LegCs)
  1304.        
  1305.         (LegA) node[above,red]{\Large $ 1 $} ++(1.18,-3) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwA) {}
  1306.         (SwA.out 1) to[short, -*,color=red, i<=$i_w$, current/distance=0.5,] (LegA)
  1307.         (SwA.out 2) to[short, -*, color=black] (LegAs)
  1308.        
  1309.         (LegB) node[above]{\Large $ 0 $} ++(1.18,-2) node [spdt, rotate=180, anchor=in, yscale=1](SwB) {}
  1310.         (SwB.out 2) to[short, -*] (LegB)
  1311.         (SwB.out 1) to[short, -*,i>=$i_v$, current/distance=0.68] (LegBs)
  1312.        
  1313.         (LegC) node[above,red]{\Large $ 1 $} ++(1.18,-1) node [spdt, rotate=180, color=red, anchor=in, yscale=-1](SwC) {}
  1314.         (SwC.out 1) to[short, -, i<=$i_u$,current/distance=0.5, color=red] (LegC)
  1315.         (SwC.out 2) to[short, -] (LegCs)
  1316.        
  1317.        
  1318.         % Motor
  1319.        
  1320.         (SwA.in) -- ++(4.5,0)
  1321.         to[short, o-,color=red, i>=$i_w$, current/distance=0.7] ++(1,0)
  1322.         to[L,v^<=\raisebox{1.0ex}{$v_w$}] ++(1.2,0)
  1323.         to[R] ++(1.2,0) coordinate (Lright)
  1324.         to[short] ++(0.5,0)
  1325.         ++(0,-2) coordinate (motorend)
  1326.        
  1327.         (SwB.in) -- ++(2.5,0)
  1328.         to[short, o-,i<=$i_v$, current/distance=0.5] ++(1,0)
  1329.         to[L,v^>=\raisebox{1.0ex}{$v_v$}] ++(1.2,0)
  1330.         to[R] ++(1.2,0) coordinate (Lright)
  1331.         to[short, -*] ++(0.5,0)
  1332.         ++(0,-2)
  1333.        
  1334.         (SwC.in)  -- ++(0.5,0)
  1335.         to[short, o-,color=red, i>=$i_u$, current/distance=0.7] ++(1,0)
  1336.         to[L,v^<=\raisebox{1.0ex}{$v_u$}] ++(1.2,0)
  1337.         to[R] ++(1.2,0) coordinate (Lright)
  1338.         to[short] ++(0.5,0)
  1339.         to[short] ++(0,-2);  
  1340.        
  1341.        
  1342.     }
  1343.     {} 
  1344.        
  1345.     \node[anchor=west] at (-2.5,-3.4) {$ \phi = \Angle^{\circ}  $};
  1346.     \node[anchor=west] at (-2.5,-3.8) {$ x = \totalx  $};
  1347.     \node[anchor=west] at (-2.5,-4.2) {$ y = \totaly  $};
  1348.  
  1349.    
  1350.    
  1351.    
  1352.    
  1353.    
  1354.    
  1355.    
  1356.    
  1357.    
  1358.  
  1359.    
  1360.  
  1361.  
  1362.         % Axes - Static axes for triangular wave and the three bridge legs
  1363.     %================================================================================================================================================
  1364.     \pgfmathsetmacro \gridx {\sizex - 0.1}; % Subtract a bit to avoid having a grid with a frame
  1365.     \pgfmathsetmacro \gridy {\sizey - 0.1}; % Subtract a bit to avoid having a grid with a frame
  1366.    
  1367.     % Axis for triangular wave
  1368.     %\draw[help lines, color=gray!30, dashed, very thin] (0,-\gridy) grid++ (\gridx,\gridy*2);
  1369.     \draw[->, color = gray!50] (0,0) node[left, color=black]{$ 0 $} --++(\sizex*0.95,0);
  1370.     \draw[->] (0,-\sizey)--++(0,\sizey*2) node[above]{$ m $};
  1371.    
  1372.     %Axis for leg U
  1373.     \draw[->] (0,-\vertspace*2) node[left]{}  --++(\sizex,0) node[right]{$t$};
  1374.     \draw[->] (0,-\vertspace*2)--++(0,\sizey/2) node[above]{$ U $};
  1375.    
  1376.     %Axis for leg V
  1377.     \draw[->] (0,-\vertspace*3) node[left]{}  --++(\sizex,0) node[right]{$t$};
  1378.     \draw[->] (0,-\vertspace*3)--++(0,\sizey/2) node[above]{$ V $};
  1379.    
  1380.     %Axis for leg W
  1381.     \draw[->] (0,-\vertspace*4) node[below, xshift=0.25cm]{$ v_0 $} node[left, below, xshift=2.25cm]{$ v_7 $}  --++(\sizex,0) node[right]{$t$};
  1382.     \draw[->] (0,-\vertspace*4)--++(0,\sizey/2) node[above]{$ W $};
  1383.    
  1384.    
  1385.     \end{tikzpicture}}
  1386.    
  1387.    
  1388. \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement