Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[pgf] [tikz] Circuits help needed

523 views
Skip to first unread message

Joel C. Salomon

unread,
Aug 24, 2011, 7:31:24 PM8/24/11
to
I'm trying to learn the TikZ Circuits library by replicating
<http://en.wikipedia.org/wiki/File:Sallen-Key_Lowpass_General.svg>.
I've gotten this far:

% !TEX TS-program = pdflatex
\documentclass{minimal}
% Sallen-Key two-pole lowpass filter

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}

\begin{document}
\begin{tikzpicture}[circuit ee IEC]
\draw (-4,0) node[left]{$v_\mathrm{in}$}
to [resistor={info={$R_1$}}] (-2,0) node[below]{$a$}
to [resistor={info={$R_2$}}] (0,0) node[above]{$b$};
\draw (-2,0) -- (-2,1)
to [capacitor={info={$C_1$}}] (2.5,1)
-- (2.5,-.25);
\draw (0,0) to [capacitor={info'={$C_2$}}] (0,-2)
to [ground] (0,-2.5);
\draw (0,0) -- (1,0) node[right]{$+$};
\draw (2.25,-.25) -- (2.25,-1) -- (.75,-1) -- (.75,-.5)
-- (1,-.5) node[right]{$-$};
\draw (2,-.25) -- (2.75,-.25) node[right]{$v_\mathrm{out}$};
\end{tikzpicture}
\end{document}

The most obvious missing bit is the op-amp, but I'm also not sure how to
get the filled and hollow circles at the circuit nodes of interest. Any
help?

Thanks,
--Joel

Zarko F. Cucej

unread,
Aug 25, 2011, 3:54:38 PM8/25/11
to

try the following:

% !TEX TS-program = pdflatex
\documentclass{minimal}
% Sallen-Key two-pole lowpass filter

\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC,shapes}

\begin{document}
\begin{tikzpicture}[circuit ee IEC,
T/.style = {isosceles triangle, isosceles triangle apex angle=60,
draw, minimum size=10mm, anchor=141},
]
\draw (-4,0)
to[contact={at start,fill=white,info=left:$v_\mathrm{in}$},


resistor={info={$R_1$}}] (-2,0) node[below]{$a$}
to [resistor={info={$R_2$}}] (0,0) node[above]{$b$};
\draw (-2,0) -- (-2,1)
to [capacitor={info={$C_1$}}] (2.5,1)
-- (2.5,-.25);
\draw (0,0) to [capacitor={info'={$C_2$}}] (0,-2)
to [ground] (0,-2.5);

\draw (0,0) -- (1,0) node[name=A,right]{$+$};


\draw (2.25,-.25) -- (2.25,-1) -- (.75,-1) -- (.75,-.5)
-- (1,-.5) node[right]{$-$};

\node[T=2] at (A.west) {};
\draw (2,-.25) to[contact={at
end,fill=white,info=right:$v_\mathrm{out}$}] (2.75,-.25);
\end{tikzpicture}
\end{document}

op-amp has quit rude approach and its positioning in your picture is
not elegant ...

regards, Zarko

Gabriel Cormier

unread,
Aug 26, 2011, 8:02:26 AM8/26/11
to
My post (yesterday) seems to have gotten lost... here's how I do it,
using the circuitikz package. It may not be the best way, though...

\documentclass{article}

\usepackage[american]{circuitikz}
\usetikzlibrary{positioning}

\begin{document}

\begin{circuitikz}[line width=1pt]
\draw (0,0) node[op amp,yscale=-1] (opamp) {};
\node [left=0.8cm of opamp.+] (p1) {};
\node [left=1.5cm of p1] (p2) {};
\node [left=1.5cm of p2] (p3) {};
\node [below=1.5cm of p1] (p4) {};
\node [left=0.2cm of opamp.-,coordinate] (m1) {};
\node [above = 1cm of p2] (f1) {};
\node [right=4cm of f1,coordinate] (f2) {};
\node [right = 0.5cm of opamp.out,coordinate] (f3) {};
\node [right=1.0cm of opamp.out] (vo) {};
\node [right=0.2cm of opamp.out,coordinate] (o1) {};
\node [below=1.2cm of o1,coordinate] (o2) {};
%%% Draw connections
\draw (p4) node[ground] {} to[C=$C_2$] (p1) to[short] (opamp.+);
\draw (p3) node[left] {$v_{in}$} to[R=$R_1$,o-] (p2)
to[R=$R_2$,*-*] (p1);
\draw (p2) to[short] (f1) to[C=$C_1$] (f2) -| (f3)
node[circle,fill=black,scale=0.3,draw] {};
\draw (opamp.out) to[short,-o] (vo) node[right] {$v_{out}$};
\draw (opamp.-) to[short] (m1) |- (o2) to[short,-*] (o1);
\end{circuitikz}
\end{document}

Zarko F. Cucej

unread,
Aug 26, 2011, 9:47:06 AM8/26/11
to
On 26.8.2011 14:02, Gabriel Cormier wrote:
> My post (yesterday) seems to have gotten lost... here's how I do it,
> using the circuitikz package. It may not be the best way, though...
>
[...]

circuitikz package is good package with more rich library than
tikz/circuits (in 2.1, for eventual improvements in a newest CVS version
I don't know). using it you should consider, that in some cases it can
clash with tikz, tikz/circuits.

regards, Zarko

Joel C. Salomon

unread,
Aug 26, 2011, 1:58:43 PM8/26/11
to
On 08/26/2011 08:02 AM, Gabriel Cormier wrote:
> My post (yesterday) seems to have gotten lost... here's how I do it,
> using the circuitikz package. It may not be the best way, though...

Thanks, Gabriel & Zarko. I've adapted Gabriel's code thus:

\documentclass{article}

\usepackage[american]{circuitikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{circuitikz}[on grid]
\node (vi) [label=left:$v_\mathrm{in}$] {};
\node (a) [right=2 of vi] [label=below:$a$] {};
\node (b) [right=2 of a] [label=above:$b$] {};
\node[ground] (gnd) [below=2 of b] {};
\node[op amp] (oa) [right=2 of b, yshift=-5mm, yscale=-1] {};
\node (vo) [right=0.6 of oa.out] [label=right:$v_\mathrm{out}$] {};

\node (ff) [right=0.25 of oa.out] {};
\node (a') [above=1.2 of a] {};

\draw (vi) to[R=$R_1$, o-] (a)
to[R=$R_2$] (b)
to[short] (oa.+);
\draw (a) to[short, *-] (a')
to[C=$C_1$] (a' -| ff)
to[short, -*] (ff);
\draw (b) to[C, l_=$C_2$, *-] (gnd);
\draw (oa.out) to[short, -o] (vo);
\draw (oa.out) to[short, *-] +(0, -1.35)
to[short] +(0,0) -| (oa.-);
\end{circuitikz}
\end{document}

I tried to avoid defining nodes (a') and (ff), but couldn't figure that
out. Also, looking closely I see that the "yshift=-5mm" is *slightly*
excessive but I can't tell by how much. (The slope is visible at 16x
magnification, or as a slight fuzziness in the (b)--(oa.+) line at
display resolution.)

Thanks for your help,
--Joel

0 new messages