如何添加電阻並添加可變電壓源?

如何添加電阻並添加可變電壓源?

我目前正在嘗試製作這個電路,但每次我做任何事情都會發出刺耳的聲音。我要加的那個是紅色的。

在此輸入影像描述

這是程式碼和結果

在此輸入影像描述

   \begin{document}
    \begin{circuitikz}
    \node[op amp, noinv input up] at (0,0) (opamp) {};
    \node[ground] at (-4.69,-5.5) (ground) {};
    \draw (opamp.-) -- ++(-1.15,0) -- ++(0,-2) to[R, l_=$R_1$] ++(0,-2.5) to[short,-*] ++(-2.35,0);
    \draw (opamp.+)(-3,0)to[R, l_=$R_1$] -- ++(-3.5,0) to[V, l_=$v_\text{IN}$,] ++(0,-3) -- (ground);
    \draw (1.66,0) to[short,*-] ++(0,-2.5) to[R, l^=$R_2$, -*] ++(-4,0);
    \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_-$};

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

    \end{circuitikz}
    \end{document}

答案1

您的主要錯誤是忽略從 LaTeX 收到的錯誤:

wth.tex|8 error| Package tikz Error: (, +, coordinate, pic, or node expected.
wth.tex|8 error| Package pgf Error: No shape named `' is known.
...

與 LaTeX 幾乎總是一樣,只有第一個錯誤是真正相關的,另一個錯誤可能只是與試圖超越發現的錯誤的誤解有關。

有問題的行是

\draw (opamp.+)(-3,0)to[R, l_=$R_1$] -- ++(-3.5,0)  [...]

錯誤非常明顯:您需要在 a 之後有一個節點/座標,to而您有一個--

將該行更改為

 \draw (opamp.+) to[R, l_=$R_1$]  ++(-3.5,0) to[V, l_=$v_\text{IN}$,] ++(0,-3) -- (ground); 

你有:

在此輸入影像描述

現在,作為由@Jasper Habicht 建議,您可以透過向生成器新增名稱並使用此處顯示的方法

完整的例子是:

\documentclass[border=10pt]{standalone}
\usepackage[siunitx, RPvoltages]{circuitikz}
\begin{document}
\begin{tikzpicture}[]
    \node[op amp, noinv input up] at (0,0) (opamp) {};
    \node[ground] at (-4.69,-5.5) (ground) {};
    \draw (opamp.-) -- ++(-1.15,0) -- ++(0,-2) to[R, l_=$R_1$] ++(0,-2.5) to[short,-*] ++(-2.35,0);
    \draw (opamp.+) to[R, l_=$R_1$]  ++(-3.5,0) to[V, l_=$v_\text{IN}$, name=myV] ++(0,-3) -- (ground);
    \draw (1.66,0) to[short,*-] ++(0,-2.5) to[R, l^=$R_2$, -*] ++(-4,0);
    \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_-$};

    \node[shift={(0,-0.3)}] at (opamp.-) {\scriptsize$v_-$};
    \node[shift={(0,+0.3)}] at (opamp.+) {\scriptsize$v_+$};
    \ctikztunablearrow{1}{1.25}{150}{myV}
\end{tikzpicture}
\end{document}

導致

在此輸入影像描述

PS:(看到了嗎?現在答案更有用,因為您知道錯誤來自哪裡!並且您有一個“最小工作示例”的示例,您應該始終將其添加到您的問題中)

答案2

除了具有電源電壓的運算放大器之外,該方案寫在一個\draw循環中:

\documentclass[margin=3mm]{standalone}
\usepackage{amsmath}
\DeclareMathOperator{\IN}{\textsc{in}}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}[american]
\node[op amp, noinv input up]  (oa) {};
    \draw[-stealth] (oa.up)     --  ++  (0,+0.5) node[above] {$V_{+}$};
    \draw[-stealth] (oa.down)   --  ++  (0,-0.5) node[below] {$V_{-}$};
\draw
    (oa.-)  node[below] {\scriptsize $v_-$}
                -|  ++  (-0.5,-1.5) coordinate (aux)
                to [R, a=$R_1$, *-]    ++  (0,-2)
                to [short,-*]   ++  (-3,0)   node (gnd) [ground] {}
                to [V=$V_{\IN}$, name=V]    (gnd |- oa.+) %
                to [R=$R_1$]    ++  (3,0)  -- (oa.+) 
            node[above] {\scriptsize $v_+$} 
    (oa.out)    to [short,]  (oa.out |- aux)
                to [R=$R_2$]    (aux)
    (oa.out)    to [short, -o]  ++  (0.5,0) node[right] {$v_o$}
    ;
    \ctikztunablearrow[thick]{1}{1.2}{-30}{V}
    \end{circuitikz}
\end{document}

相關內容