如何在 circuitikz 中绘制直流电机

如何在 circuitikz 中绘制直流电机

我正在使用来circuitikz创建电路图。我想画一个这样的直流电机:

直流电动机符号
(来源:专家思维网

或者这个:

直流电机的 IEC 符号

看起来没有电机符号circuitikz。我正在使用\begin{circuitikz}[american]。我如何绘制这些符号?

答案1

另一种方法是修改现有的双端元素,然后circuitikz重新sV定义一个新的命令,\mymotor该命令可绘制所需的形状和形式。这里按照 OP 的要求定义了两个形状 (\mymotor, \mymotorB)。

\newcommand{\mymotor}[2] % #1 = name , #2 = rotation angle
{\draw[thick,rotate=#2] (#1) circle (10pt)
 node[]{$\mathsf M$} 
++(-12pt,3pt)--++(0,-6pt) --++(2.5pt,0) ++(-2.8pt,6pt)-- ++(2.5pt,0pt);
\draw[thick,rotate=#2] (#1) ++(12pt,3pt)--++(0,-6pt) --++(-2.5pt,0) 
++(2.8pt,6pt)-- ++(-2.5pt,0pt);
}

在此处输入图片描述

代码:

\documentclass[border=20pt]{standalone}  
\usepackage[american,siunitx]{circuitikz}
\usetikzlibrary{arrows,shapes,calc,positioning}

\newcommand{\mymotor}[2] % #1 = name , #2 = rotation angle
{\draw[thick,rotate=#2] (#1) circle (10pt)
 node[]{$\mathsf M$} 
++(-12pt,3pt)--++(0,-6pt) --++(2.5pt,0) ++(-2.8pt,6pt)-- ++(2.5pt,0pt);
\draw[thick,rotate=#2] (#1) ++(12pt,3pt)--++(0,-6pt) --++(-2.5pt,0) ++(2.8pt,6pt)-- ++(-2.5pt,0pt);
}

\newcommand{\mymotorB}[2] % #1 = name 
{\draw[thick] (#1) circle (12pt)
node[above=-3pt]{$\mathsf M$} ++(-8pt,-3pt)--++(15pt,0);
\draw[thick,dashed] (#1) ++(-8pt,-5pt)--++(15pt,0);
}

\begin{document}

\begin{circuitikz}
\draw (0,2) to[L, l_=$L$, o-*] (2,2) to[sV, color=white, name=M1] (3.5,2) to[short,*-] (5,2);
\mymotor{M1}{0}
\draw (0,0) to[short, o-*] (2,0) to[short, -*] (3.5,0) to[short] (5,0);
\draw (2,2) to[C=$C$] (2,0);
\draw (3.5,2) to[R=$R$] (3.5,0);
\draw (5,2) to[sV, color=white, name=M2] (5,0);
\mymotor{M2}{90}
%
\draw (2,3) to[sV, color=white, name=M3] (3.5,3);
\mymotorB{M3}

\draw (6,2) to[sV, color=white, name=M4] (6,0);
\mymotorB{M4}

\end{circuitikz}

\end{document}

答案2

困难的部分是让 M 正面朝上。

\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}

相关内容