[Tex/LaTex] connections with circuitikz

circuitikznode-connections

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

Best Answer

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}