Guest User

Untitled

a guest
Jun 18th, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %
  3. % Welcome to Overleaf --- just edit your LaTeX on the left,
  4. % and we'll compile it for you on the right. If you give
  5. % someone the link to this page, they can edit at the same
  6. % time. See the help menu above for more info. Enjoy!
  7. %
  8. % Note: you can export the pdf to see the result at full
  9. % resolution.
  10.  
  11. %
  12.  
  13. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  14.  
  15. %& -shell-escape
  16.  
  17. % Create a Bode plot using Papanicola Robert's package bodegraph:
  18.  
  19. % http://www.sciences-indus-cpge.apinc.org/Bode-Black-et-Nyquist-avec-
  20. Tikz
  21.  
  22. % Author: Dazhi Jiang
  23.  
  24. documentclass[10pt]{article}
  25.  
  26. %%%<
  27.  
  28. usepackage{verbatim}
  29.  
  30. usepackage[active,tightpage]{preview}
  31.  
  32. %PreviewEnvironment{tikzpicture}
  33.  
  34. setlengthPreviewBorder{5pt}%
  35.  
  36. %%%>
  37.  
  38.  
  39.  
  40. begin{comment}
  41.  
  42. :Title: Bode plot
  43.  
  44. :Author: Dazhi Jiang
  45.  
  46. :Tags: Bodegraph, PGF CVS, Signal Processing, Node positionning,
  47. Plotting
  48.  
  49.  
  50. This tikz example display two bode plots.
  51.  
  52. It requires the bodegraph_ package and GNUPLOT.
  53.  
  54.  
  55. .. _bodegraph: http://www.sciences-indus-cpge.apinc.org/Bode-Black-et- Nyquist-avec-Tikz
  56.  
  57. end{comment}
  58.  
  59. usepackage{amsmath,amssymb}
  60.  
  61. usepackage{tikz}
  62. usepackage{bodegraph}
  63.  
  64. usetikzlibrary{intersections}
  65. usetikzlibrary{calc}
  66. usetikzlibrary{positioning}
  67.  
  68.  
  69. begin{document}
  70.  
  71. % Define the layers to draw the diagram
  72. pgfdeclarelayer{background}
  73. pgfdeclarelayer{foreground}
  74. pgfsetlayers{background,main,foreground}
  75.  
  76. begin{preview}
  77. begin{tikzpicture}[>=latex',
  78. ref lines/.style={thin, blue!60},
  79. ref points/.style={circle, black, opacity=0.7, fill, minimum size= 3pt, inner sep=0},
  80. every node/.style={font=small},
  81. bode lines/.style={very thick, blue},
  82. Gclabel/.style={text=blue},
  83. xscale=12/3]
  84.  
  85. begin{scope}[yscale=4/110]
  86. UnitedB
  87. semilog{-1}{2}{-50}{60}
  88.  
  89. % Bode plot (magnitude) for the original system, 4/(s/(1+2s)).
  90. % Asymptotic line
  91. BodeAmp[ref lines, red!60]{-1:1.35}{POAmpAsymp{4}{2.0}+IntAmp{1}}
  92. % Bode plot
  93. BodeAmp[bode lines, red, name path=Gomagnitude]{-1:1.35}{POAmp{4} {2.0}+IntAmp{1}}
  94.  
  95. % Bode plot (magnitude) for the compensated system, 4(1+s)/(s^2/(1+0.1s)).
  96. % Asymptotic line
  97. BodeAmp[ref lines]{-1:2}{APAmpAsymp{4}{0.1}{10}+2*IntAmp{1}}
  98. % Bode plot
  99. BodeAmp[bode lines, name path=magnitude]
  100. {-1:2}{APAmp{4}{0.1}{10}+2*IntAmp{1}}
  101.  
  102. % Reference line, (0dB)
  103. draw [name path=unitygain, ref lines] (-1,0) -- (2,0);
  104.  
  105. % Crossover frequency of the original system
  106. path [name intersections={of=magnitude and unitygain, by={a,b}}]
  107. (a) circle (2pt)
  108. (b) circle (2pt);
  109. node (coref) [ref points, label={[blue]below left:$omega_c$}]
  110. at (a,b) {};
  111.  
  112. % Crossover frequency of the compensated system
  113. path [name intersections={of=Gomagnitude and unitygain, by=Gocrossover}];
  114. node (Gocoref) [ref points, label={[red]below:$omega_{co}$}]
  115. at (Gocrossover) {};
  116.  
  117. % Labels for the original system (open-loop)
  118. node [Gclabel, text=red] at (-0.7, 15) {$-20$dB/dec};
  119. node [Gclabel, text=red] at (0.5, -30) {$-40$dB/dec};
  120. node (KG) [Gclabel, red!60, text=red, draw]
  121. at (-0.5, -30) {$KG(s)=dfrac{4}{s(1+2s)}$};
  122. draw (KG.east) edge [->, shorten >=1pt, thick, red, bend right=1.5]
  123. (0.4, -10);
  124.  
  125. % Labels for the compensated system (open-loop)
  126. node [ref points, label={[blue]below left:$omega_2$}] at (0, 0) {};
  127. node [ref points, label={[blue]below right:$omega_3$}] at (1, 0) {};
  128. node [Gclabel] at (-0.4, 40) {$-40$dB/dec};
  129. node [Gclabel] at (0.5, 10) {$-20$dB/dec};
  130. node [Gclabel] at (1.6, -20) {$-40$dB/dec};
  131. node (KDG) [Gclabel, blue!60, text=blue, draw]
  132. at (1.4, 40) {$KD(s)G(s)=dfrac{4(1+s)}{s^2(1+0.1s)}$};
  133. draw (KDG.west) edge [->, shorten >=1pt, thick, blue, bend right=1.5]
  134. (0.17, 10);
  135.  
  136. % Axes label
  137. node [below=6pt] at (0.5,-50) {Frequency, $omega$};
  138. node [rotate=90] at (-1.25,5) {Magnitude, $20log(|G(text{j} omega)|)$};
  139.  
  140.  
  141. end{scope}
  142.  
  143. begin{scope}[yshift=-3.5cm,yscale=4/180]
  144. UniteDegre
  145. OrdBode{30}
  146. semilog{-1}{2}{-180}{0}
  147.  
  148. % Bode plot (magnitude) for the compensated system, 4(1+s)/(s^2 /(1+0.1s)).
  149. % Asymptotic line
  150. BodeArg[ref lines]{-1:2}{APArgAsymp{4}{0.1}{10}+2*IntArg{1}}
  151. % Bode plot
  152. BodeArg[bode lines, name path=phase]{-1:2}{APArg{4}{0.1}{10}+2* IntArg{1}}
  153.  
  154. % Phase margin of the original system
  155. path [name path=Gowcref] (Gocrossover) -- ++(0,-330);
  156. path [name intersections={of=Gophase and Gowcref, by=Gophasemargin}];
  157. node (Gopmref) [ref points] at (Gophasemargin) {};
  158. draw [ref lines, red!60, densely dotted] (Gocoref.south) -- (Gopmref.north);
  159. draw [ref lines, <->, red] let p1=(Gophasemargin)
  160. in
  161. (Gopmref.south) -- node[left, Gclabel, text=red] {$text{PM}_o$} (x1,-180);
  162.  
  163. % Phase margin of the compensated system
  164. path[name path=wcref] (crossover) -- ++(0,-300);
  165. path [name intersections={of=phase and wcref, by=phasemargin}];
  166. node (pmref) [ref points] at (phasemargin) {};
  167. draw [ref lines, densely dotted] (coref.south) -- (pmref.north);
  168. draw [ref lines, <->, blue] let p1=(phasemargin)
  169. in
  170. (pmref.south) -- node[left, Gclabel] {PM} (x1,-180);
  171.  
  172. % System Labels
  173. node (KGphase) [Gclabel, red!60, text=red, draw]
  174. at (-0.5, -40) {$KG(s)=dfrac{4}{s(1+2s)}$};
  175. draw[->, shorten >=1pt, thick, red]
  176. (KGphase.south) .. controls +(down:30) and +(0.1,10) .. (-0.65, -114);
  177.  
  178. node (KDGphase) [Gclabel, blue!60, text=blue, draw]
  179. at (1.4, -40) {$KD(s)G(s)=dfrac{4(1+s)}{s^2(1+0.1s)}$};
  180. draw[->, shorten >=1pt, thick, blue]
  181. (KDGphase.south) .. controls +(down:40) and +(0.1,30) .. (1.1, -146);
  182.  
  183. % Axes label
  184. node [below=6pt] at (0.5, -180) {Frequency, $omega$};
  185. node [rotate=90] at (-1.25, -90) {Phase, $angle G(text{j}omega)$};
  186. end{scope}
  187.  
  188. % Background
  189. begin{pgfonlayer}{background}
  190. path (-1.4cm,2.8cm) node (tl) {};
  191. path (2.3cm, -8.4cm) node (br) {};
  192.  
  193. path[fill=brown!20] (tl) rectangle (br);
  194. end{pgfonlayer}
  195.  
  196. end{tikzpicture}
  197. end{preview}
  198. end{document}
Add Comment
Please, Sign In to add comment