TikZ Circuits

このページではレポートで使用したtikzで書いた回路図を共有します.統一感がない書き方なのは悪しからず.
必要なパッケージは適宜インポートしてください.

半加算機

半加算機
\begin{tikzpicture}[circuit logic US, scale=1.7]
      \draw (4,1) node[and gate] (and1) {};
      \draw (and1)+(0,1) node[xor gate] (xor1) {};
      \draw (xor1.input 1) to ++(-0.70,0) node [branch] {} |- (and1.input 1);
      \draw (xor1.input 2) to ++(-0.35,0) node [branch] {} |- (and1.input 2);
      \draw (xor1.input 1) -- ++(-1,0) node [left]{$A$};
      \draw (xor1.input 2) -- ++(-1,0) node [left]{$B$};
      \draw (xor1.output) -- ++(1,0) node [right]{$S$};
      \draw (and1.output) -- ($($(xor1.output)+(1,0)$)!(and1.output)!($(xor1.output)+(1,1)$)$) node [right]{$C_{out}$};
    \end{tikzpicture}

全加算機

全加算機
\begin{tikzpicture}[circuit logic US, scale=1.7]
      % Half adder 2
      \draw (4,1) node[xor gate] (xor2) {};
      \draw (xor2)+(0,1) node[and gate] (and2) {};

      % Half adder 1
      \draw (and2.input 1)+(-2,0) node[xor gate] (xor1) {};
      \draw (xor1)+(0,1) node[and gate] (and1) {};

      % Carry
      \draw ($0.5*(and1)+0.5*(and2)+(3,0)$) node[or gate] (or) {};

      % connection between AND1 and XOR1
      \draw (and1.input 1) to ++(-0.70,0) node [branch] {} |- (xor1.input 1);
      \draw (and1.input 2) to ++(-0.35,0) node [branch] {} |- (xor1.input 2);

      % connection between HA1 and HA2
      \draw (xor1.output) -- (and2.input 1);

      % connection between AND1 and XOR1
      \draw (xor1.output)  to ++( 0.70,0) node [branch] {} |- (xor2.input 1);
      \draw (xor2.input 2) to ++(-0.35,0) node [branch] {} |- (and2.input 2);

      % connection between AND1,2 and OR
      \draw (or.input 2) -- ++(-0.4,0) |- (and2.output);
      \draw (or.input 1) -- ++(-0.4,0) |- (and1.output);

      % outputs
      \draw (or.output) -- ++(1,0) node[right] (output) {$C_{out}$};
      \draw (xor2.output) -- ($($(or.output)+(1,0)$)!(xor2.output)!($(or.output)+(1,1)$)$) node[right] {$S$};

      % inputs
      \draw (xor2.input 2) -- ($(0,1)!(xor2.input 2)!(0,0)$) node[left] {$C_{in}$};
      \draw (and1.input 1) -- ($(0,1)!(and1.input 1)!(0,0)$) node[left] {$A$};
      \draw (and1.input 2) -- ($(0,1)!(and1.input 2)!(0,0)$) node[left] {$B$};
    \end{tikzpicture}

反転増幅回路

反転増幅回路
\begin{circuitikz}
\draw
  (2.5,-0.785) node[op amp] (opamp) {}
  (-2,{-0.3}) node[left] {$v_{in}$} to[short, o-] (-1.5,{-0.3})
  (-1.5,{-0.3}) to[european resistor=$R_s$] (0.5,{-0.3}) node[circle,fill,inner sep=1.2pt] {}  % ● at R_s junction
  (0.5,{-0.3}) -- (opamp.-)
   (0.5,{-0.3}) node[below] {$\varepsilon$}
  (opamp.+) -- ++(0,-0.8) node[ground] {}
  (opamp.out) to[short, -o] ++(1,0) node[right] {$v_{out}$}
  (0.5,{-0.3}) -- ++(0,1.5) coordinate (feedback)
  (feedback) to[european resistor=$R_f$] ($(opamp.out)!(feedback)!(opamp.out|-0,0)$) node[circle,fill,inner sep=1.2pt, yshift = -56pt] {} -- (opamp.out);  % ● at R_f junction

% Rsの下に破線の矢印を追加
\draw[dashed, ->] (-1.5,-0.8) -- (0.5,-0.8) node[midway, below] {$i_s$};

% Rfの入力から出力のx座標に破線の矢印を変更し,y座標を0.5下にずらす
\draw[dashed, ->] ($(feedback)+(0.5,-0.5)$) -- ($($(opamp.out)!(feedback)!(opamp.out|-0,0)$)+(-0.5,-0.5)$) node[midway, below] {$i_f$};
\end{circuitikz}

非反転増幅回路

非反転増幅回路
\begin{circuitikz}
\draw
  (0,0) node[op amp] (opamp) {}
  % 入力 v_in
  (opamp.+) to[short,-o] ++(-1,0) node[left] {$v_{in}$}
  % 負入力フィードバック点
  (opamp.-) -- ++(0,1) coordinate(feedback) node[circle,fill,inner sep=1.2pt] {}  % ● を追加
  % 下側抵抗 R_s を接地
  (feedback) to[european resistor,l^=$R_s$] ++(-2,0) node[ground] {}
  % フィードバック抵抗 R_f を出力端子へ(直角接続)
  (feedback) to[european resistor=$R_f$] ++(2.38,0) coordinate(tmp)
  (tmp) |- (opamp.out) coordinate(feedbackR) node[circle,fill,inner sep=1.2pt] {}  % ● at hinge
  % 出力端子
  (opamp.out) to[short,-o] ++(1,0) node[right] {$v_{out}$}
;
\end{circuitikz}