20

How can I create a new component and include it in CircuiTikZ? For example a 4 bit adder?

3 Answers 3

18

There is an easy way. Use an existing component as a base, such as to[generic,color=white,n=myname] and draw anything you want in the space.

\newcommand{\speaker}[2] % #1 = name from to[generic,n=#1], #2 = rotation angle
{\draw[thick,rotate=#2] (#1) +(.2,.25) -- +(.7,.75) -- +(.7,-.75) -- +(.2,-.25);}
\begin{circuitikz}
\draw (0,2) to[C, l_=$C$, o-*] (2,2) to[short, -*] (3.5,2) to[short] (5,2);
\draw (0,0) to[short, o-*] (2,0) to[short, -*] (3.5,0) to[short] (5,0);
\draw (2,2) to[L=$L$] (2,0);
\draw (3.5,2) to[R=$R$] (3.5,0);
\draw (5,2) to[generic, n=S1](5,0);
\speaker{S1}{0}
\end{circuitikz}

enter image description here

I have improved on my technique since then, as explained in the following tutorials.

http://www.elfsoft2000.com/projects/speaker.pdf

http://www.elfsoft2000.com/projects/multipole.pdf

http://www.elfsoft2000.com/projects/bipole.pdf

1
  • I just want to note that \speaker{S1}(0} should be \speaker{S1}{0}, but it won't let me do a single character edit. Great example!
    – ackey
    Mar 2, 2014 at 4:30
16

Components in CircuiTikz are defined in the pgfcirc*poles.sty files via pretty much low-level pgf commands. You can either

  1. try looking at the *sty files, in particular pgfcirctripoles.sty there most ports are defined, and cut&paste your way to a new component. If you manage to code it, please send it to me so I can add it for everyone to use :)
  2. send me a PNG of how you want the adder to look, and wait for me to code it ^^ I have a few requests in queue, and it is time I updated the package afterall...
3
  • 2
    I don’t understand anything in the .sty files :( Couldn’t you make a Tutorial ? Thanks for your help, your package is very nice !
    – Calixte
    May 28, 2011 at 21:09
  • Would it be possible to add Darlington transistor? I do have some experience with PGF commands, but I was completely lost reading the style file.
    – Pygmalion
    Apr 5, 2021 at 16:41
5

Just an update: notice that in version 0.9.0

  1. there is a loudspeaker component, and
  2. there is an (admittedly short) part about how to add components in the manual.

Unfortunately, to add components you should have a bit of knowledge of the pgf basic layer (part IX of the TikZ-PGF manual).

example circuit for 0.9.9

1
  • I like necromancer badges! BTW, there is a mux-demux component since 1.0 that can be used to create adders, ALUs, etc...
    – Rmano
    Jun 6, 2020 at 10:49

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.