Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using circuitikz to create an electric circuit diagram. I'd like to draw a DC motor like this:

DC motor symbol

or this one:

IEC symbol for DC motor

It looks like there's no symbol for motors in circuitikz. I'm using \begin{circuitikz}[american]. How I draw those symbols?

share|improve this question
1  
I have a tutorial on the subject: elfsoft2000.com/projects/index.htm and I also am willing to help. Which of the above to you prefer? –  John Kormylo Sep 8 '13 at 19:52
add comment

1 Answer

The hard part was getting the M right side up.

\documentclass{article}
\usepackage[screen,nopanel]{pdfscreen}
\usepackage{circuitikz}

\margins{0.2cm}{0.2cm}{0.2cm}{0.2cm}
\screensize{3cm}{5cm}
\backgroundcolor{white}

% prepare to create bipoles

\makeatletter
\def\TikzBipolePath#1#2{\pgf@circ@bipole@path{#1}{#2}}
\def\CircDirection{\pgf@circ@direction}

\pgf@circ@Rlen = \pgfkeysvalueof{/tikz/circuitikz/bipoles/length}

\makeatother 

\newlength{\ResUp} \newlength{\ResDown}
\newlength{\ResLeft} \newlength{\ResRight}

% set default motor size

\ctikzset{bipoles/motor/height/.initial=.8}
\ctikzset{bipoles/motor/width/.initial=.8}

% create motor shape

\pgfcircdeclarebipole{}
 {\ctikzvalof{bipoles/motor/height}}
 {motor}
 {\ctikzvalof{bipoles/motor/height}}
 {\ctikzvalof{bipoles/motor/width}}
 {
    \pgfsetlinewidth{\ctikzvalof{bipoles/thickness}\pgfstartlinewidth}
    \pgfextractx{\ResRight}{\northeast}
    \pgfextracty{\ResUp}{\northeast}
    \pgfextractx{\ResLeft}{\southwest}
    \pgfextracty{\ResDown}{\southwest}

  \pgfpathmoveto{\pgfpoint{0.775\ResLeft}{0.2\ResDown}}
\pgfpathlineto{\pgfpoint{\ResLeft}{0.2\ResDown}}
  \pgfpathlineto{\pgfpoint{\ResLeft}{0.2\ResUp}}
  \pgfpathlineto{\pgfpoint{0.775\ResLeft}{0.2\ResUp}}
\pgfpathellipse{\pgfpointorigin}{\pgfpoint{0.8\ResRight}{0cm}}
    {\pgfpoint{0cm}{0.8\ResUp}}
  \pgfpathmoveto{\pgfpoint{0.775\ResRight}{0.2\ResDown}}
    \pgfpathlineto{\pgfpoint{\ResRight}{0.2\ResDown}}
  \pgfpathlineto{\pgfpoint{\ResRight}{0.2\ResUp}}
  \pgfpathlineto{\pgfpoint{0.775\ResRight}{0.2\ResUp}}
  \pgfusepath{draw} %draw motor
    \pgftext[rotate=-\CircDirection]{\textsf{M}}
 }

% create motorto-path style

\def\motorpath#1{\TikzBipolePath{motor}{#1}}
\tikzset{motor/.style = {\circuitikzbasekey, /tikz/to path=\motorpath, l=#1}}

% end of setup

\begin{document}

\begin{center}
\begin{circuitikz}
 \draw (0,0) to[motor, l=motor, o-*] (0,2);
\end{circuitikz}
\end{center}

\newpage
\begin{center}
\begin{circuitikz}
 \draw (0,0) to[motor, l=motor, o-*] (2,0);
\end{circuitikz}
\end{center}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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