# Inverting Op Amp – Negative Feedback

\documentclass[border=3pt]{standalone}

% Circuits
\usepackage[european,s traightvoltages, RPvoltages, americanresistor, americaninductors]{circuitikz}
\tikzset{every picture/.style={line width=0.2mm}}

% Notation
\usepackage{amsmath}

% Tikz Library
\usetikzlibrary{calc}

% Bipoles Specifications
\ctikzset{bipoles/thickness=1.2, label distance=1mm, voltage shift = 1}

% Arrows Above Compenents
% Source: https://tex.stackexchange.com/questions/574576/circuitikz-straight-voltage-arrows-with-fixed-length
\newcommand{\fixedvlen}[3][0.4cm]{% [semilength]{node}{label}
% get the center of the standard arrow
\coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
% draw an arrow of a fixed size around that center and on the same line
\draw[-{Triangle[round,open]}] ($(#2-Vcenter)!#1!(#2-Vfrom)$) -- ($(#2-Vcenter)!#1!(#2-Vto)$);
% position the label as it where if standard voltages were used
\node[ anchor=\ctikzgetanchor{#2}{Vlab}] at (#2-Vlab) {#3};
}
\newcommand{\fixedvlendashed}[3][0.75cm]{% [semilength]{node}{label}
% get the center of the standard arrow
\coordinate (#2-Vcenter) at ($(#2-Vfrom)!0.5!(#2-Vto)$);
% draw an arrow of a fixed size around that center and on the same line
\draw[dashed,-{Triangle[round,open]}] ($(#2-Vcenter)!#1!(#2-Vfrom)$) -- ($(#2-Vcenter)!#1!(#2-Vto)$);
% position the label as it where if standard voltages were used
\node[ anchor=\ctikzgetanchor{#2}{Vlab}] at (#2-Vlab) {#3};
}

\begin{document}

\begin{circuitikz}
%		%Grid
%		\def\length{6}
%		\draw[thin, dotted] (-\length,-\length) grid (\length,\length);
%		\foreach \i in {1,...,\length}
%		{
%			\node at (\i,-2ex) {\i};
%			\node at (-\i,-2ex) {-\i};
%		}
%		\foreach \i in {1,...,\length}
%		{
%			\node at (-2ex,\i) {\i};
%			\node at (-2ex,-\i) {-\i};
%		}
%		\node at (-2ex,-2ex) {0};

%Circuit
\node[op amp] at (0,0) (opamp) {};
\node[ground] at (-4.69,-2.4) (ground) {};
\draw (opamp.-) to[R, l_=$R_1$, v^>, name=R1] ++(-3.5,0) to[sV, l_=$v_\text{IN}$, i<_=$i_1$] ++(0,-2.6) -- (ground);
\draw (opamp.+) -- ++(-0.46,0) -- ++(0,-1.4) to[short,-*] ++(-3.04,0);
\draw ($(opamp.-)+(-0.45,0)$) to[short, *-] ++(0,2.3) to[R, l_=$R_2$, i>=$i_2$, v^<, name=R2] ++(3.3,0) to[short,-*] ++(0,-2.8);
\draw (opamp.out) to[short,-*] ++(1.5,0) node[shift={(0.6,0)}] {$v_\text{O}$};
\draw[-latex] (opamp.up) -- ++(0,0.5) node[above] {$V_+$};
\draw[-latex] (opamp.down) -- ++(0,-0.5) node[below] {$V_-$};
\draw[-{Triangle[round]}] ($(opamp.-)+(-0.15,0)$) -- +(+0.2,0) node[below] {\scriptsize$i_-$};
\draw[-{Triangle[round]}] ($(opamp.+)+(-0.15,0)$) -- +(+0.2,0) node[above] {\scriptsize$i_+$};

%Voltage
\fixedvlen[0.4]{R1}{$V_{R_1}$};
\fixedvlen[0.4]{R2}{$V_{R_2}$};

%Nodes
\node[shift={(0,0.3)}] at (opamp.-) {\scriptsize$v_-$};
\node[shift={(0,-0.4)}] at (opamp.+) {\scriptsize$v_+$};

\end{circuitikz}

\end{document}