How can I invert the poles of an OP-AMP in circuitikz?

You can use yscale=-1:

\documentclass{article}
\usepackage{circuitikz}

\begin{document}

\begin{circuitikz} 
  \draw (0,0) node[op amp] (opamp1) {}
  (opamp1.+) node[left ] {$v_+$}
  (opamp1.-) node[left ] {$v_-$};
  \draw (3,0) node[op amp,yscale=-1] (opamp2) {}
  (opamp2.+) node[left ] {$v_+$}
  (opamp2.-) node[left ] {$v_-$};
\end{circuitikz}

\end{document}

enter image description here


If you want just to switch + and -, you have to modify the definition of the op amp. What I have done is to add an option noinv up (and the corresponding noinv down, in the case you want to reset a style) that switches the inverting and no inverting input letting the other anchors where they are.

Additionaly, I added anchors in up and in down for the input that is "up" and "down" independently from the new option.

The code is the one between \makeatletter and \makeatother. The code need the latest version of circuitikz (you can find it at github) due to unfathomable reasons; probably if you want to stick with your version you need to copy your definition of the op amp and replicate the changes I did (marked in the code between %%% RG: marks). It seems long and complex, but basically is a minimal change of the original code...

PS: I have prepared a pull request for the tikzcircuit github code with this and more things...

Result:

enter image description here

Code:

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, oldvoltagedirection]{circuitikzgit}
% needs the latest version of circuitikz, see github (dunno why) 
% \usepackage[siunitx]{circuitikz}
%
\makeatletter
%%% RG: added the option and the code to switch
\newif\ifpgf@circuit@oa@plusup\pgf@circuit@oa@plusupfalse
\pgfkeys{/tikz/noinv up/.add code={}{\pgf@circuit@oa@plusuptrue}}
\ctikzset{noinv up/.add code={}{\pgf@circuit@oa@plusuptrue}}
\pgfkeys{/tikz/noinv down/.add code={}{\pgf@circuit@oa@plusupfalse}}
\ctikzset{noinv down/.add code={}{\pgf@circuit@oa@plusupfalse}}
%%% RG stop 
\pgfdeclareshape{op amp}
{
    \anchor{center}{\pgfpointorigin}
    \savedanchor\northwest{%
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen
        \pgf@y=.5\pgf@y
        \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen
        \pgf@x=.5\pgf@x
    }
    \anchor{south}{
        \northwest
        \pgf@y=-\pgf@y
        \pgf@x=0pt
    }
    \anchor{north}{
        \northwest
        \pgf@x=0pt
    }
    \savedanchor\left{%
        \pgf@y=0pt
    }
    \anchor{leftedge}
    {\left
        \pgf@x = \pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@x
    }
    %%% RG: added the fixed anchors
    \savedanchor\inOneFixed{%
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen
        \pgf@y=.5\pgf@y
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@y
        \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen
        \pgf@x=.5\pgf@x
    }
    \anchor{in up}{
        \inOneFixed
    }
    \anchor{in down}{
        \inOneFixed
        \pgf@y=-\pgf@y
    }
    %%% RG stop 
    \savedanchor\inOne{%
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen
        \pgf@y=.5\pgf@y
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@y
        \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen
        \pgf@x=.5\pgf@x
        %%% RG: added the conditional flip
        \ifpgf@circuit@oa@plusup\pgf@y=-\pgf@y\fi
        %%% RG stop 
    }
    \anchor{-}{
        \inOne
    }
    \anchor{+}{
        \inOne
        \pgf@y=-\pgf@y
    }
    \savedanchor\up{%
        \pgf@y=\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/height}\pgf@circ@Rlen
        \pgf@y=.5\pgf@y
        \pgf@x=-\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/width}\pgf@circ@Rlen
        \pgf@x=.5\pgf@x
        \pgf@circ@res@up = \pgf@y
        \pgf@circ@res@right = -\pgf@x
        \pgf@circ@res@left = \pgf@x
        \pgfpointlineattime{
            \pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/up pos}}{
            \pgfpoint{
            \pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
        {\pgf@circ@res@up}}
        {\pgfpoint{.7\pgf@circ@res@right}{0pt}}
    }
    \anchor{up}{
        \up
    }
    \anchor{down}{
        \up
        \pgf@y=-\pgf@y
    }
    \anchor{out}{
        \northwest
        \pgf@y=0pt
        \pgf@x=-\pgf@x
    }
    \anchor{west}{
        \left
    }
    \anchor{east}{
        \left
        \pgf@x=-\pgf@x
    }

    \backgroundpath{
        \pgfsetcolor{\pgfkeysvalueof{/tikz/circuitikz/color}}


        \northwest
        \pgf@circ@res@up = \pgf@y
        \pgf@circ@res@down = -\pgf@y
        \pgf@circ@res@right = -\pgf@x
        \pgf@circ@res@left = \pgf@x

        \pgfpathmoveto{\pgfpoint
            {\pgf@circ@res@left}
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint
            {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}}
        %%% RG: added the conditional for printing labels + and -
    \pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@up}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} \ifpgf@circuit@oa@plusup$+$\else$-$\fi}
    %%% RG stop

        \pgfpathmoveto{\pgfpoint
            {\pgf@circ@res@left}
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}}
        \pgfpathlineto{\pgfpoint
            {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}
        {\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}}
        %%% RG: added the conditional for printing labels + and -
    \pgftext[left, at=\pgfpoint{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/port width}\pgf@circ@res@left}{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/input height}\pgf@circ@res@down}]{\pgfkeysvalueof{/tikz/circuitikz/tripoles/op amp/font} \ifpgf@circuit@oa@plusup$-$\else$+$\fi}
    %%% RG stop

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@right}{0pt}}
        \pgfpathlineto{\pgfpoint{.7\pgf@circ@res@right}{0pt}}
        \pgfsetrectcap
        \pgfusepath{draw}


        \pgfscope
        \pgfsetlinewidth{\pgfkeysvalueof{/tikz/circuitikz/tripoles/thickness}\pgflinewidth}
        \pgftransformxshift{.7\pgf@circ@res@left}
        \pgf@circ@res@step=\pgf@circ@res@right
        \advance\pgf@circ@res@step by -\pgf@circ@res@left
        \pgf@circ@res@step=.7\pgf@circ@res@step

        \pgfpathmoveto{\pgfpoint{\pgf@circ@res@step}{0pt}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@up}}
        \pgfpathlineto{\pgfpoint{0pt}{\pgf@circ@res@down}}
        \pgfpathclose
        \pgfusepath{draw}
        \endpgfscope



    }
}
\makeatother
\def\coord(#1){coordinate(#1)}
\def\coord(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]75:#1}](#1){}}
\def\coordd(#1){node[circle, red, draw, inner sep=1pt,pin={[red, overlay, inner sep=0.5pt, font=\tiny, pin distance=0.1cm, pin edge={red, overlay,}]-145:#1}](#1){}}
\ctikzset{tripoles/mos style/arrows, bipoles/thickness=1, }
\begin{document}
\begin{circuitikz}[ american, ]
    %
    \draw[cyan, dotted] (-2,-2) grid (2,5);
    \node at (0,0) [op amp](OA1){};
    \node at (OA1.up) [vcc]{};
    \node at (OA1.down) [vee]{};
    \foreach \a in {+,-,up,down,out} \path (OA1.\a) \coord(\a);
    \foreach \a in {in up, in down} \path (OA1.\a) \coordd(\a);
    \node at (0,3) [op amp, noinv up](OA2){};
    \node at (OA2.up) [vcc]{};
    \node at (OA2.down) [vee]{};
    \foreach \a in {+,-,up,down,out} \path (OA2.\a) \coord(\a);
    \foreach \a in {in up, in down} \path (OA2.\a) \coordd(\a);
\end{circuitikz}
\end{document}

Tags:

Circuitikz