4

Hello this is my first TikZ code:

\documentclass[]{article}
\usepackage{rotating}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}

\tikzstyle{pinstyle} = [pin edge={to-,thin,black}]

\tikzset{
    block/.style = {draw, rectangle,
        minimum height=1cm,
        minimum width=2cm},
    input/.style = {coordinate,node distance=1cm},
    output/.style = {coordinate,node distance=4cm},
    arrow/.style={draw, -latex,node distance=2cm},
    pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
    sum/.style = {draw, circle, node distance=1cm},
gain/.style = {regular polygon, regular polygon sides=3,
          draw, fill=white, text width=1em,
          inner sep=1mm, outer sep=0mm,
          shape border rotate=-90}
}
\begin{document}


\begin{sidewaysfigure}
\centering
        \begin{tikzpicture}[auto, node distance=1cm,>=latex']

        %DEFINIZIONE BLOCCHI
        \node [input, name=input] {};
        \node [sum, right=of input] (position_sum) {};
        \node [block, right=of position_sum] (position_controller) {$C_{pos}(s)$};
    \node [sum, right=of position_controller] (speed_sum) {};
        \node [block, right=of speed_sum] (speed_controller) {$C_{vel}(s)$};
    \node [sum, right=of speed_controller] (current_sum) {};
        \node [block, right=of current_sum] (current_controller) {$C_{corr}(s)$};
        \node [block, right=of current_controller] (azionamento) {$Azionamento$};
        \node [gain, right= of azionamento] (Kt) {$K_{t}$};
     \node [sum, right=of Kt, pin={[pinstyle]above:$-C_{R}(s)$},
node distance=3cm] (torque_sum) {};
         \node [block, right=of torque_sum] (system) {$\frac{1}{sJ+f}$};
         \node [block, right=of system] (integrator) {$\frac{1}{s}$};
         \node [gain, right= of integrator] (tau) {$\tau$};
    \node [output, right=of tau] (output) {};
        \node at ($(speed_controller)!0.5!(system)+(0,-2)$) [block] (speed_feedback) {Trasduttore di velocit\`a};

        %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
        \draw [draw,->] (input) -- node {$\theta_{M}^{DES}(s)$} (position_sum);
        \draw [->] (position_sum) --  node {$E_{p}(s)$}(position_controller);
        \draw [->] (position_controller) -- node {$\omega_{M}^{DES}(s)$}(speed_sum);
        \draw [->] (speed_sum) -- node {$E_{v}(s)$}(speed_controller);
        \draw [->] (speed_controller) -- node {$I^{DES}(s)$}(current_sum);
          \draw [->] (current_sum) -- (current_controller);
    \draw [->] (current_controller) -- (azionamento);
            \draw [->] (azionamento) -- node  [name=current]{$I(s)$}(Kt);
            \draw [->] (Kt) -- node {$C_{M}(s)$}(torque_sum);
            \draw [->] (torque_sum) -- (system);
     \draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}(integrator);
    \draw [->] (integrator) -- node [name=motor_position] {$\theta_{M}(s)$}(tau);
        \draw [->] (tau) -- node [name=tetaload] {$\theta_{C}(s)$}(output);

        %DEFINIZIONE COLLEGAMENTI FEEDBACK
        \draw [->] (current) -- ++ (0,-2) -| node [pos=0.99] {$-$} (current_sum);
        \draw [->] (motor_position) -- ++ (0,-6) -| node [pos=0.99] {$-$} (position_sum);
        \draw [->] (motor_speed)  |- (speed_feedback) ;
        \draw [->] (speed_feedback)  -| node[pos=0.99] {$-$} (speed_sum);
\end{tikzpicture}  

    \caption{Anello di controllo di un asse elettro-meccanico con accoppiamento rigido}
    \label{fig:full_control_loop_rigido}
\end{sidewaysfigure}

\end{document}

The resulting control loop looks like: Full loop

So I don't know how to solve the following problems:

  1. The image at the top is cut (I can't see the last part of my control loop, exactly the integra, tau and output nodes);
  2. The unitary "current feedback" got a superposition with the Trasduttore di velocità (speed_feedback);
  3. Some variables wrote above the arrows goes in superposition with some blocks;
  4. I had to use the \begin{sidewaysfigure} since my figure got fully "cut" if i use the \begin{figure}.

I am asking for solution of these four problems (or at least 1,2,3) since I am really a newbie with TikZ. Thank you!

4

Well, your diagram is simply too large for the page. If you tweak the distance between the nodes, reduce the fontsize and inner sep of the gain nodes, and remove the minimum width of the block nodes, you can make the rotated version fit in the page at least, though it's still wider than the text area, so you get an overfull hbox warning.

An alternative might be to lay it out vertically instead of horizontally, in which case it fits nicely.

enter image description here

\documentclass{article}
\usepackage{rotating}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\usetikzlibrary{arrows,calc,positioning}

\tikzset{
    pinstyle/.style={pin edge={to-,thin,black}},
    block/.style = {draw, rectangle,
        minimum height=1cm,
     %   minimum width=2cm
     },
    input/.style = {coordinate,node distance=1cm},
    output/.style = {coordinate,node distance=4cm},
    arrow/.style={draw, -latex,node distance=2cm},
    pinstyle/.style = {pin edge={latex-, black,node distance=2cm}},
    sum/.style = {draw, circle, node distance=1cm},
gain/.style = {regular polygon, regular polygon sides=3,
          draw, fill=white, text width=1em,
          inner sep=0mm, outer sep=0mm,
          shape border rotate=-90}
}
\begin{document}


\begin{sidewaysfigure}
\centering
        \begin{tikzpicture}[auto,>=latex',every node/.append style={font=\scriptsize}]

        %DEFINIZIONE BLOCCHI
        \node [input, name=input] {};
        \node [sum, right=of input] (position_sum) {};
        \node [block, right=of position_sum] (position_controller) {$C_{\mathrm{pos}}(s)$};
        \node [sum, right=15mm of position_controller] (speed_sum) {};
        \node [block, right=of speed_sum] (speed_controller) {$C_{\mathrm{vel}}(s)$};
        \node [sum, right=of speed_controller] (current_sum) {};
        \node [block, right=5mm of current_sum] (current_controller) {$C_{\mathrm{corr}}(s)$};
        \node [block, right=5mm of current_controller] (azionamento) {Azionamento};
        \node [gain, right= of azionamento] (Kt) {$K_{t}$};
        \node [sum, right=of Kt, pin={[pinstyle]above:$-C_{R}(s)$},
               node distance=3cm] (torque_sum) {};
        \node [block, right=5mm of torque_sum] (system) {$\frac{1}{sJ+f}$};
        \node [block, right=of system] (integrator) {$\frac{1}{s}$};
        \node [gain, right= of integrator] (tau) {$\tau$};
        \node [output, right=1cm of tau] (output) {};
        \node at ($(speed_controller)!0.5!(system)+(0,-2.5)$) [block] (speed_feedback) {Trasduttore di velocit\`a};

        %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
        \draw [->] (input) -- node {$\theta_{M}^{\mathrm{DES}}(s)$} (position_sum);
        \draw [->] (position_sum) --  node {$E_{p}(s)$}(position_controller);
        \draw [->] (position_controller) -- node {$\omega_{M}^{\mathrm{DES}}(s)$}(speed_sum);
        \draw [->] (speed_sum) -- node {$E_{v}(s)$}(speed_controller);
        \draw [->] (speed_controller) -- node {$I^{\mathrm{DES}}(s)$}(current_sum);
        \draw [->] (current_sum) -- (current_controller);
        \draw [->] (current_controller) -- (azionamento);
        \draw [->] (azionamento) -- node  [name=current]{$I(s)$}(Kt);
        \draw [->] (Kt) -- node {$C_{M}(s)$}(torque_sum);
        \draw [->] (torque_sum) -- (system);
        \draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}(integrator);
        \draw [->] (integrator) -- node [name=motor_position] {$\theta_{M}(s)$}(tau);
        \draw [->] (tau) -- node [name=tetaload] {$\theta_{C}(s)$}(output);

        %DEFINIZIONE COLLEGAMENTI FEEDBACK
        \draw [->] (current) -- ++ (0,-1.5) -| node [pos=0.99] {$-$} (current_sum);
        \draw [->] (motor_position) -- ++ (0,-4) -| node [pos=0.99] {$-$} (position_sum);
        \draw [->] (motor_speed)  |- (speed_feedback) ;
        \draw [->] (speed_feedback)  -| node[pos=0.99] {$-$} (speed_sum);
\end{tikzpicture}  

   \caption{Anello di controllo di un asse elettro-meccanico con accoppiamento rigido}
   \label{fig:full_control_loop_rigido}
\end{sidewaysfigure}
\begin{figure}
\centering
        \begin{tikzpicture}[node distance=5mm, auto,>=latex',every node/.append style={font=\scriptsize},block/.append style={minimum width=2cm}]

        %DEFINIZIONE BLOCCHI
        \node [input, name=input] {};
        \node [sum, below=of input] (position_sum) {};
        \node [block, below=of position_sum] (position_controller) {$C_{\mathrm{pos}}(s)$};
        \node [sum, below=of position_controller] (speed_sum) {};
        \node [block, below=of speed_sum] (speed_controller) {$C_{\mathrm{vel}}(s)$};
        \node [sum, below=of speed_controller] (current_sum) {};
        \node [block, below=of current_sum] (current_controller) {$C_{\mathrm{corr}}(s)$};
        \node [block, below=of current_controller] (azionamento) {Azionamento};
        \node [gain, below= of azionamento] (Kt) {$K_{t}$};
        \node [sum, below=of Kt, pin={[pinstyle]left:$-C_{R}(s)$}] (torque_sum) {};
        \node [block, below=3mm of torque_sum] (system) {$\frac{1}{sJ+f}$};
        \node [block, below=of system] (integrator) {$\frac{1}{s}$};
        \node [gain, below=of integrator] (tau) {$\tau$};
        \node [output, below=1cm of tau] (output) {};
        \node at ($(speed_controller)!0.5!(system)+(4,0)$) [block] (speed_feedback) {Trasduttore di velocit\`a};

        %DEFINIZIONE COLLEGAMENTI IN CATENA DIRETTA
        \draw [->] (input) -- node {$\theta_{M}^{\mathrm{DES}}(s)$} (position_sum);
        \draw [->] (position_sum) --  node {$E_{p}(s)$}(position_controller);
        \draw [->] (position_controller) -- node {$\omega_{M}^{\mathrm{DES}}(s)$}(speed_sum);
        \draw [->] (speed_sum) -- node {$E_{v}(s)$}(speed_controller);
        \draw [->] (speed_controller) -- node {$I^{\mathrm{DES}}(s)$}(current_sum);
        \draw [->] (current_sum) -- (current_controller);
        \draw [->] (current_controller) -- (azionamento);
        \draw [->] (azionamento) -- node  [name=current]{$I(s)$}(Kt);
        \draw [->] (Kt) -- node {$C_{M}(s)$}(torque_sum);
        \draw [->] (torque_sum) -- (system);
        \draw [->] (system) -- node [name=motor_speed] {$s\theta_{M}(s)$}(integrator);
        \draw [->] (integrator) -- node [name=motor_position] {$\theta_{M}(s)$}(tau);
        \draw [->] (tau) -- node [name=tetaload] {$\theta_{C}(s)$}(output);

        %DEFINIZIONE COLLEGAMENTI FEEDBACK
        \draw [->] (current) -- ++ (1.5,0) |- node [pos=0.99] {$-$} (current_sum);
        \draw [->] (motor_position) -- ++ (7,0) |- node [pos=0.99] {$-$} (position_sum);
        \draw [->] (motor_speed)  -| (speed_feedback) ;
        \draw [->] (speed_feedback)  |- node[pos=0.99] {$-$} (speed_sum);
\end{tikzpicture}  

   \caption{Anello di controllo di un asse elettro-meccanico con accoppiamento rigido}
   \label{fig:full_control_loop_rigido}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.