4

I'm writing a thesis for the school where I go at and I need to draw the following Op-Amps configurations:

  1. inverting configuration
  2. non-inverting configuration
  3. differential configuration
  4. inverting adder amplifier
  5. non-inverting adder amplifier

So far I only have been able to draw the first configuration with the following code:

\begin{circuitikz}
\draw (0, 0) node[op amp] (opamp) {}
      (opamp.-) to[short,-*] ++(-1, 0) coordinate(A)
      (opamp.+) -| ++(-1,-1) node[ground](B){}
      (opamp.out) to[short,*-o] ++(1, 0) coordinate(C)
      (A) to[R,l_=$R_1$,-o] ++(-2, 0) -- ++(-1, 0) coordinate(D) to [V<=$v_1$] (D |- B) node[ground]{}
      (A) |- ++(1,1) coordinate[yshift=1ex] (L1) to[R=$R_2$] ++(2,0) -| (opamp.out) to[short,-o] ++(1,0)
;
\end{circuitikz}

And this is the result I got: enter image description here

Can someone help me with the code of the other configurations maintaining the same style as the one I got?

Thanks in advance! Samuel.

5
  • 1
    Welcome! Your code seems ok (I would have centered R2 on the branch, but that's a matter of style). Where are the problem in adapting it to the other configurations? That should be quite straightforward. I think you should write a much more specific question. Start drawing the non-inverting amp, for example, and if you get stuck, post what you have and why you got stuck and we'll help. (Also, consider that probably the majority of people here has not electronic background).
    – Rmano
    Commented May 14, 2021 at 9:48
  • Hi! @Rmano and thank you for your quick answer! The problem I'm having is that I'm a complete beginner LaTeX-wise and the code above comes from having reverse-engineered a code that I found online and because of this I'm not able to start drawing a diagram from 0. Commented May 14, 2021 at 9:55
  • 1
    So maybe you should ask that somebody explains the code to you, not "please do it for me" the rest of configurations. I humbly suggest you read the first couple of tutorials in the circuitikz manual...
    – Rmano
    Commented May 14, 2021 at 10:02
  • @Rmano ok that's great! Thank you! Commented May 14, 2021 at 10:15
  • IIRC, the only changes between the configurations have to do with connecting to the + or - inputs. The feedback always goes to -. Commented May 14, 2021 at 16:16

1 Answer 1

7

OK. Let me copy here what will be a new tutorial I added to the manual. You can find it on the circuitikz page (in the PDF you'll also find a suggestion on how to re-use the shape).

Tutorial: A non-inverting op-amp amplifier

Let's now try to draw a non-inverting amplifier based on op-amps; the canonical implementation can be, for example, this one from ''electronics tutorials''. Obviously, the style and form of drawing a circuit is often a matter of personal tastes and, maybe even more important, of the details you are focusing on; drawing a non-inverting amplifier will be different if you are drawing it to explain how it works or if you are simply using it in a more complex circuit, assuming its operation well known by the reader. Anyway, the final objective is to have a circuit like the one below, drawn so that it is easy to reuse.

enter image description here

We have to start the drawing from a generic point. Given that the idea is to have a reusable block, instead of positioning the op-amp and build around it, we will start from the input ''pole'':

\begin{circuitikz}[]
    \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
    node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
    ;
\end{circuitikz}

enter image description here

In this snippet, notice that the only absolute coordinate is the first one; that will enable us to ''copy and paste'' the circuit in several places, or create a macro for it. We position a text node above it, and then draw a wire with a pole to a relative (1,0) coordinate: in other words, we move 1 unit to the right drawing a short-circuit, which is the same as a wire. The usage of to[short...] simplifies the position of the pole, but notice that we could have also written:

\draw (0,0) node[above]{$v_i$} node[ocirc]{} -- ++(1,0) ...

with the same result.

The second step is to position the op-amp. We can check the manual and see the component's description:

enter image description here

where we notice the type of the component (it is a node-type component, so we have to use node to position it) and the available ''anchors'': points we can use to position the shape or to connect to. Not all the anchors are explicitly printed in the description box; you should read further in the manual and you'll see a ''component anchors'' section with the relevant information.

Anyway, the op-amp must be connected with the + anchor to our input wire, so we say anchor=+ in the option lists; this shifts the whole element so that the named anchor will lie at the current position of the path. Moreover, normally the shape has the inverting input on the bottom side, and we want it the other way around, so we use also noinv input up in the keys defining the node. We could also have flipped the shape with yscale=-1, but in this case, we should have considered the effects on anchors and on the text; see section mirroring and flipping in the manual.

Now we can draw the resistors; let's start with R1. We will draw it going down vertically from the - anchor — we have named the node OA so that will be OA.-. We will need to connect the R2 also, so we do the following:

  • draw a wire going down, and mark a point where we want the feedback resistor to connect;
  • then draw R1 and finally
  • draw the ground node.
\begin{circuitikz}[scale=0.8, transform shape]
    \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
    node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
    (OA.-) -- ++(0,-1) coordinate(FB)
    to[R=$R_1$] ++(0,-2) node[ground]{}
    ;
\end{circuitikz}

enter image description here

We only miss the feedback resistor now. We will use orthogonal coordinates, writing:

\draw (FB) to[R=$R_2$] (FB -| OA.out) -- (OA.out);

The meaning is the following:

  • move the current point to the coordinate named FB;
  • put a resistor, with label R2, from here to...
  • the coordinates which is on the horizontal of FB and on the vertical of OA.out: the -| coordinate operation is quite mnemonic;
  • the continue drawing to OA.out.

You can use a separate \draw command or just continue the path you were writing; the choice is just personal preference, but be warned that it can affect the drawing of poles (see section ''poles (also called nodes)'' in the manual about this if you notice strange things).

Finally, we add the output and a couple of poles:

\begin{circuitikz}[scale=0.8, transform shape]
    \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
    node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
    (OA.-) -- ++(0,-1) coordinate(FB)
    to[R=$R_1$] ++(0,-2) node[ground]{}
    (FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
    to [short, *-o] ++(1,0) node[above]{$v_o$}
    ;
\end{circuitikz}

enter image description here

The last step to obtain the final look is to add a bit of styling. We want the op-amp filled with a light cyan color, and we prefer to have the label aligned with the left side of the device:

\ctikzset{amplifiers/fill=cyan!20, component text=left}
\begin{circuitikz}[scale=0.8, transform shape]
    \draw (0,0) node[above]{$v_i$} to[short, o-] ++(1,0)
    node[op amp, noinv input up, anchor=+](OA){\texttt{OA1}}
    (OA.-) -- ++(0,-1) coordinate(FB)
    to[R=$R_1$] ++(0,-2) node[ground]{}
    (FB) to[R=$R_2$, *-] (FB -| OA.out) -- (OA.out)
    to [short, *-o] ++(1,0) node[above]{$v_o$}
    ;
\end{circuitikz}

enter image description here

The \ctikzset command choosing the style is better placed in the preamble, though. Style should be coherent for all the document body, so avoiding stating it for every circuit is normally the best strategy.

5
  • 1
    Wow, thank you for this very clear and complete starting guide! I really appreciate your help Commented May 14, 2021 at 17:37
  • @SamuelAlborghetti thanks! Please remember to check here what to do when you have an answer: tex.stackexchange.com/help/someone-answers
    – Rmano
    Commented May 14, 2021 at 17:39
  • You may consider to add such tutorials to your package documentation at some of the next package version :-). Of course +1!
    – Zarko
    Commented May 15, 2021 at 19:02
  • @Zarko it is already in --- if you follow the link at the start of the post you can see it in the new manual! Thanks!
    – Rmano
    Commented May 15, 2021 at 21:48
  • Supper! That means I have to update my circuitikz installation in few next days :-). Electronic version is really amazing!
    – Zarko
    Commented May 15, 2021 at 22:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .