How can I represent a IC using circuitikz?

I'm thinking of something like this:

example

I checked the whole manual and searched this information on google, but found nothing. It's hard to believe that no one ever needed this before...

One simple example of a document with regular components would be this:

\documentclass{article}
\usepackage[symbols]{circuitikz}
\usepackage{tikz}
\begin{document}

\begin{circuitikz} \draw
 (0,0) to[C, l=$10\micro\farad$] (0,2) -- (0,3)
  to[R, l=$2.2\kilo\ohm$] (4,3) -- (4,2)
  to[L, l=$12\milli\henry$, i=$i_1$] (4,0) -- (0,0)
 (4,2) to[D*, *-*] (2,0) to [D*, -*] (0,2)
  to[R, l=$1\kilo\ohm$] (2,2)   to[cV, v=$0.3\kilo\ohm i_1$] (4,2)
 (2,0) to[I, i=$1\milli\ampere$:15, -*] (2,2)
;
\end{circuitikz}

\end{document}

However, I could find any way to include a IC image.

  • 1
    @AndréWagner your example produces errors; please fix it. – Gonzalo Medina Jul 26 '12 at 23:23
  • No, you're not the first to ever do this. I once did something like this with TikZ' circuit, but nothing automatic, just a general definition with TikZ commands and nodes for convineant connecting, e.g. \draw (IC1.out) -- (IC2.trig) – Tom Bombadil Jul 27 '12 at 4:36
  • @percusse Do you have any examples of such rectangles+labels? – André Wagner Jul 27 '12 at 12:03

As far as I can tell, circuiTikZ generates basic bipole devices, some tripoles (thyristors, triacs, pots), quadripoles (transformers), basic two input opamps, multiport logic gates, but no IC type devices. You can, however, use tikz commands, lines, rectangular shapes, and nodes to approximate what you want. Here is an example for the picture of the IC 555 monostable timer that you posted.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{fit} % positioning, calc libraries may also be useful
\usepackage[siunitx,european,american]{circuitikz}

\begin{document}

% set basic rectangular shape of IC
\tikzstyle{icdev}=[draw, text width=6em, minimum height=8em]

\begin{tikzpicture}[every node/.style = {font = \footnotesize},european]
    \draw (0,4) node[left]{$V_{cc}$}  % from top Vcc to bottom Gnd
        to[short,o-] (0.8,4)
        to[/tikz/circuitikz/bipoles/length=0.7cm,R] (0.8,2) % set bipole device size
        to[/tikz/circuitikz/bipoles/length=0.7cm,C] (0.8,1.8) -- (0.8,0)
        to[short,-o] (0,0) node[left]{GND}
    ;
    \node (digichip) [icdev,xshift=3cm,yshift=2cm] {};  % position IC device body
% top terminal lines/pins - 4 RESET, 8 Vcc
    \path [draw](0.8,4) -| (2.5,3.4) node[below]{RESET} node[above left]{4};
    \path [draw](2.5,4) -| (3.5,3.4) node[below]{$V_{cc}$} node[above left] {8};
% bottom terminal lines/pins - 1 GND, 5 CTRL
    \path [draw](0.8,0) -| (2.5,0.6) node[above]{GND} node[below left]{1};
    \path [draw](2.5,0) -- (3.5,0)
        to[/tikz/circuitikz/bipoles/length=0.7cm,C](3.5,0.6)  
        node[above]{CTRL} node[below left]{5}; % C = 10nf
% leftside terminal lines/pins - 7 DIS, 6 THR, 2 TRG
    \draw (0.8,2.5) -- (1.83,2.5) node[right]{DIS} node[above left]{7}
        (1.2,2.5) |- (1.83,2) node[right]{THR} node[above left]{6}
        (1.1,1.5) -- (1.83,1.5) node[right]{TRG} node[above left]{2};
% rightside terminal line/pin - 3 out
    \draw (4.17,2) node[left]{Out} -- (4.8,2) node[above left]{3};
\end{tikzpicture}

\end{document}

enter image description here

It is actually believable since coming up with a new shape in TikZ is not that straightforward. Because IC types are too diverse, there is no practical way to include all of them hence usually skipped. Instead they are often made up of straightforward rectangles+labels on the connections. You can reanchor a rectangle shape which is relatively easy or you can just use labels.

A very very pragmatic demonstration is

\documentclass{article}
\usepackage{circuitikz,siunitx}
\begin{document}

\begin{circuitikz} 
\draw  (0,0) to[C, l=$\SI{10}{\micro\farad}$] 
       (0,2) --
       (0,3) to[R, l=$\SI{2.2}{\kilo\ohm}$] 
       (4,3) -- 
       (4,2) to[L, l=$\SI{12}{\milli\henry}$, i=$i_1$] 
       (4,0) -- 
       (0,0)
       (4,2) to[D*, *-*] 
       (2,0) to [D*, -*] 
       (0,2) to[R, l=$\SI{1}{\kilo\ohm}$] 
       (2,2) to[cV, v=$\SI{0.3}{\kilo\ohm} i_1$] 
       (4,2)
       (2,0) to[I, i=$\SI1{\milli\ampere}$:15, -*] 
       (2,2) 
    ;
\node[draw,label={[below=5mm]90:IC$1$},label={[right=8mm]180:IC$2$},minimum size=1.5cm] (ic) at (7,1){};
\draw (4,3) -| 
      (ic.90) 
      (ic.180) -|  
      (5,2) --
      (4,2)
;
\end{circuitikz}

\end{document}

enter image description here

First, use pbox package to show multiple-lines labels.

\usepackage{pbox}
\newcommand{\ctikzlabel}[2]{\pbox{\textwidth}{#1\\#2}} % multiple-lines labels

Then use relsize package to change font size and define a style named pin.

\usepackage{relsize}
\tikzset{
    pin/.style = {font = \relsize{-2}} % pin font size
}
\ctikzset{
    bipoles/length = 2em, % bipole size
    font = \relsize{-1}, % default font size
}

Use relative positions to locate ICs, like (5.5,2) in the example. You can connect pins with other components by using (u1 con), (u1 tri) and so on.

\begin{circuitikz}
% U1 NE555
\draw [thick] (5.5,2) coordinate (u1) rectangle ++(2,3); % shape
\draw [pin] (u1) ++ (0,0.5) coordinate (u1 con)
    node[right]{CON}
    node[above left]{5}; % CON
\draw [pin] (u1) ++ (0,1) coordinate (u1 tri)
    node[right]{TRI}
    node[above left]{2}; % TRI
\draw [pin] (u1) ++ (0,1.5) coordinate (u1 thr)
    node[right]{THR}
    node[above left]{6}; % THR
\draw [pin] (u1) ++ (0,2) coordinate (u1 dis)
    node[right]{DIS}
    node[above left]{7}; % DIS
\draw [pin] (u1) ++ (0,2.5) coordinate (u1 rst) 
    node[right]{RST}
    node[above left]{4}; % RST
\draw [pin] (u1) ++ (1,3) coordinate (u1 vcc)
    node[below]{VCC}
    node[above left]{8}; % VCC
\draw [pin] (u1) ++ (1,0) coordinate (u1 gnd)
    node[above]{GND}
    node[below left]{1}; % GND
\draw [pin] (u1) ++ (2,2.5) coordinate (u1 out)
    node[left]{OUT}
    node[above right]{3}; % OUT
\draw (u1) ++ (2,0)
    node[right]{\ctikzlabel{$U_1$}{NE555}}; % NE555P

% U1 NE555 Pins
\draw (u1 con) -- ++ (-1,0); % CON
\draw (u1 tri) -- ++ (-1,0); % TRI
\draw (u1 thr) -- ++ (-1,0); % THR
\draw (u1 dis) -- ++ (-1,0); % DIS
\draw (u1 rst) -- ++ (-1,0); % RST
\draw (u1 vcc) -- ++ (0,1); % VCC
\draw (u1 gnd) -- ++ (0,-1); % GND
\draw (u1 out) -- ++ (1,0); % OUT
\end{circuitikz}

NE555 Example

As a necromancer, here is a code based on the implementation of henri menke, it is possible to create any schematic that we want, and work as if it were a component.

RESULT:

enter image description here

MWE:

% By J. Leon V.  coded based on the BSD, MIT, Beerware licences.
\documentclass[border=20pt]{standalone}
\usepackage{tikz} 
\usepackage{siunitx}
\renewcommand*\familydefault{\sfdefault} % Serif Font
\usepackage[european]{circuitikz} % Paquete especializado en circuitos eléctricos.

\begin{document}
\ctikzset{bipoles/length=1cm} % Controls bipoles scale

\begin{tikzpicture}[
        %Global Config
        font=\small
    ]

%You can create an smart objet like Henry Menke in this post http://www.texample.net/tikz/examples/4-bit-counter/
% Variables: 1: Position 2: ID.
 \def\TIMER555(#1)#2{%
  \begin{scope}[shift={(#1)}]
    \draw[fill=blue!10] (-1.5,-2) rectangle (1.5,2); % The body of IC
    % Label and component identifier.
    \draw[blue] (2,2.5) node []{\large \bf U - #2}; % IC LABEL
    \draw[blue] (0,0.5) node [align=center]{\large NE-555\\TIMER}; % IC LABEL
    % Draw the pins
    % Some that you have to learn about label nodes, draw lines, and name coordinates in Tikz
    \draw (0.9,-2) node [above]{GND} -- +(0,-0.5) node [anchor=-45]{1} coordinate (#2 GND); % Pin 1 GND
    \draw (-1.5,-1.5) node [right]{TRG} -- +(-0.5,0) node [anchor=-135]{2} coordinate (#2 TRG); % Pin 2 TRG
    \draw (1.5,0) node [left]{OUT} -- +(0.5,0) node [anchor=-45]{3} coordinate (#2 OUT); % Pin 3 OUT  
    \draw (0.9,2) node [below]{RESET} -- +(0,0.5) node [anchor=45]{4} coordinate (#2 RESET); % Pin 4 RESET
    \draw (0,-2) node [above]{CTRL} -- +(0,-0.5) node [anchor=-45]{5} coordinate (#2 CTRL); % Pin 5 CTRL
    \draw (-1.5,-.5) node [right]{THR} -- +(-0.5,0) node [anchor=-135]{6} coordinate (#2 THR); % Pin 6 THR
    \draw (-1.5,1.5) node [right]{DIS} -- +(-0.5,0) node [anchor=-135]{7} coordinate (#2 DIS); % Pin 7 DIS
    \draw (0,2) node [below]{$\mathsf{V_{CC}}$} -- +(0,0.5) node [anchor=45]{8} coordinate (#2 VCC); % Pin 8 VCC
  \end{scope}
}

% Start drawing the circuit: Example "Dee-Dah" Siren

% Place the IC's in position
\TIMER555(0,0){1}

%Place polarization nodes:
\draw (-4.5,3.5) node[ocirc] (VCC){} node[left]{$\mathsf{V_{CC}}$};
\draw (-4.5,-4) node[ocirc] (GND){} node[left]{GND};

% Connect U-1
\draw(VCC) % Start point
    to [short, o-] ++(1,0) coordinate (NOD1) % Use auxiliar coordinate (NOD1)
    to [R, l^=R,*-*] (1 DIS -| NOD1) % to the point in the intersection between NOD1 and 1 DIS
    to [eC,l^=C,*-] ++(0,-2)
    to [short] (GND -| NOD1)
    to [short] (GND);

\draw(1 VCC) to [short, -*] (1 VCC |- NOD1);
\draw(1 RESET) to [short] (1 RESET |- NOD1) to [short] (NOD1);
\draw(1 DIS) to [short, -*] (1 DIS -| NOD1);
\draw(1 THR) to [short] ++ (-0.5,0) coordinate (NOD2) to [short,-*] (1 DIS -| NOD2);
\draw(1 CTRL) to [eC,l_=0.01nF, -*] (1 CTRL |- GND);
\draw(1 GND) to [short] (1 GND |- GND) to [short] (GND -| NOD1);

%Place input/output nodes
\draw[color=blue,line width=2] (1 TRG) to [short] ++(-0.55,0) node[ocirc] (TRG){} node[below]{Trigger};
\draw[color=red,line width=2] (1 OUT) to [short] ++(0.55,0) node[ocirc](OUT){} node[below]{Out};



\end{tikzpicture}
\end{document}

PSD:

A MORE ELABORATE EXAMPLE HERE FOR THE RESULT BELOW:

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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