1

I'm trying to create a diagram from motor controller consisting of a microcontroller and its peripherals.

1) How to get the red dot on the line with circuitikz. 2) Draw current arrow below the resistor with Im at the right.

Kindly look at the diagram below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shadows,backgrounds, calc, fit}
\usepackage{amsmath,bm,times}
\usepackage[european]{circuitikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}

\tikzstyle{peripheral} = [draw, fill=blue!10, rectangle, minimum height=3em,
text width=6em, align = flush center, rounded corners, thick, drop shadow]

\tikzstyle{micro} = [draw, fill=green!10, rectangle, minimum height=7em, minimum
width = 8em, rounded corners, thick, drop shadow] 

\tikzstyle{motor} = [draw, fill=yellow!10, circle, radius=2cm, thick, drop shadow] 
\tikzstyle{motorConnector} = [draw, fill=black, rectangle, draw=black, inner sep=1mm];

\tikzstyle{line1} = [draw, thick, ->, shorten >= 1pt, >=stealth']
\tikzstyle{line2} = [draw, thick, <->, shorten >= 1pt, shorten <=1pt, >=stealth'] 
\tikzstyle{line3} = [draw, thick, shorten >=1pt]
\tikzstyle{line4} = [draw, line width=5pt , shorten >=1pt]

%beginning tikz
\begin{tikzpicture} [auto, node distance = 1cm, >=latex', background
  rectangle/.style= {fill=yellow!10, draw=blue!15, rounded corners=1ex}, show
  background rectangle, circuitikz]

 \matrix [column sep = 1cm, row sep = 0.5cm] at (0,0)
 {
   \node [peripheral] (timer) {Timers}; &
   \node [peripheral] (rtc) {RTC}; &
   \node [peripheral] (watchdog) {Watch Dog}; &\\
   %row 2
   \node [peripheral] (comm) {Serial \\Interface}; &
   \node [micro] (cpu) {CPU}; &
   \node [peripheral] (dac) {DAC}; &\\
   %row 3
   \node [peripheral] (pwm) {PWM Timer}; &
   \node [peripheral] (adc) {ADC}; & 
   \node [peripheral] (qdec) {Quadrature \\ Decoder}; &\\
   %row5
   \node [peripheral, yshift=-1.5cm] {Motor Driver};&
   \node {};&
   \node {};&\\
   %row6
   \node {};&
   \node [xshift = -1cm, motor] (motor) {Motor};&\\
   \node {};&\\
 };

 \node [draw=black, inner sep= 0.75cm, fit={(timer) (qdec) (pwm)}, rounded
 corners=1ex, thick, fill=black!20, opacity=0.1]  (motorController) {};
 \node [yshift = -0.30cm, thick] at (motorController.north) {\large$Motor Controller$};

 \node [motorConnector] at (motor.north) (connector1) {};
 \node [motorConnector] at (motor.south) (connector2) {};

 \draw (connector2.south) to [R=$R_I$] +(0,-3)
       [red, *-] {($(connector2.south) + (0,-0.5)$) -| (adc.south)} ;


 \node [ground] at ($(connector2.south) + (0,-3)$) {};

\end{tikzpicture}
\end{document}

motor controller

3

This is a possible solution where modification are near the end of this code.

enter image description here

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,shadows,backgrounds, calc, fit}
\usepackage{amsmath,bm,times}
\usepackage[european]{circuitikz}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%

\begin{document}

\tikzstyle{peripheral} = [draw, fill=blue!10, rectangle, minimum height=3em,
text width=6em, align = flush center, rounded corners, thick, drop shadow]

\tikzstyle{micro} = [draw, fill=green!10, rectangle, minimum height=7em, minimum
width = 8em, rounded corners, thick, drop shadow] 

\tikzstyle{motor} = [draw, fill=yellow!10, circle, radius=2cm, thick, drop shadow] 
\tikzstyle{motorConnector} = [draw, fill=black, rectangle, draw=black, inner sep=1mm];

\tikzstyle{line1} = [draw, thick, ->, shorten >= 1pt, >=stealth']
\tikzstyle{line2} = [draw, thick, <->, shorten >= 1pt, shorten <=1pt, >=stealth'] 
\tikzstyle{line3} = [draw, thick, shorten >=1pt]
\tikzstyle{line4} = [draw, line width=5pt , shorten >=1pt]

%beginning tikz
\begin{tikzpicture} [auto, node distance = 1cm, >=latex', background
  rectangle/.style= {fill=yellow!10, draw=blue!15, rounded corners=1ex}, show
  background rectangle, circuitikz]

 \matrix [column sep = 1cm, row sep = 0.5cm] at (0,0)
 {
   \node [peripheral] (timer) {Timers}; &
   \node [peripheral] (rtc) {RTC}; &
   \node [peripheral] (watchdog) {Watch Dog}; &\\
   %row 2
   \node [peripheral] (comm) {Serial \\Interface}; &
   \node [micro] (cpu) {CPU}; &
   \node [peripheral] (dac) {DAC}; &\\
   %row 3
   \node [peripheral] (pwm) {PWM Timer}; &
   \node [peripheral] (adc) {ADC}; & 
   \node [peripheral] (qdec) {Quadrature \\ Decoder}; &\\
   %row5
   \node [peripheral, yshift=-1.5cm] {Motor Driver};&
   \node {};&
   \node {};&\\
   %row6
   \node {};&
   \node [xshift = -1cm, motor] (motor) {Motor};&\\
   \node {};&\\
 };

 \node [draw=black, inner sep= 0.75cm, fit={(timer) (qdec) (pwm)}, rounded
 corners=1ex, thick, fill=black!20, opacity=0.1]  (motorController) {};
 \node [yshift = -0.30cm, thick] at (motorController.north) {\large$Motor Controller$};

 \node [motorConnector] at (motor.north) (connector1) {};
 \node [motorConnector] at (motor.south) (connector2) {};

 %%%-- some modification starts here

 \draw (connector2.south) to [R=$R_I$] +(0,-3)
{($(connector2.south) + (0,-0.5)$) -| (adc.south)} 
      [red,*-] {($(connector2.south) + (0,-0.46)$)};     %< -- the red node
\node [ground] at ($(connector2.south) + (0,-3)$) {};
\draw[red,->] ($(connector2.south)+(0,-2.2)$) to [] +(0,-0.5)node[right]{$I=1mA$}; %<--the current arrow
\end{tikzpicture}
\end{document}
  • Could you please explain me, \draw[red,->] ($(connector2.south)+(0,-2.2)$) to [] +(0,-0.5)node[right]{$I=1mA$}; especially [] +(0,-0.5). – raman Feb 17 '14 at 19:41
  • Yes, it means `starting from ($(connector2.south)+(0,-2.2)$) which is the lower edge of R1 box, draw a line downward 0.5cm, and put a node having a text of 1mA. – Jesse Feb 17 '14 at 19:46
  • to [option] +(0,-0.5) -- to [option] is similar to edge[option] in syntax structure. The + in +(x,y) means add (x,y) (here (0,-0.5) means vertically downward 0.5cm due to -) to the previous point and take it as the end point because a line with an arrow is drawn in red. In you case the previous point is the coordinate ($ ...... $) right before to[]. – Jesse Feb 17 '14 at 19:52
  • I was wondering why the picture is not center aligned though I have used align center at \begin{tikzpicture}. Any suggestions? – raman Feb 19 '14 at 10:56
  • @raman-- I am not sure I understand your problem, because I don't see align center in the OP. However, my wild guess is that you want to move the MotorController box to the center (a little bit to the right). If this is true, then add xshift=0.5cm to the [option] of node of MotorController, which is right below the \matrix node. – Jesse Feb 19 '14 at 12:08

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.