CircuiTikZ - リングオシレーター

CircuiTikZ - リングオシレーター

リング発振器、つまりリング内の奇数個の論理インバータを描画したいと考えています。インバータに対応するリングをうまく配置するのに非常に苦労しています。添付の​​コードを参照してください。これを実現する方法について何か提案はありますか?

    \begin{center}\begin{circuitikz}
\draw
    (0,3) node[not port,rotate=-360] (mynot1) {}
    (2.2,1.4) node[not port,rotate=-72] (mynot2) {}
    (2,-1.4) node[not port,rotate=-144] (mynot3) {}
    (-2,-2) node[not port,rotate=-206] (mynot4) {}
    (-2.2,1.4) node[not port,rotate=-288] (mynot5) {}
    (mynot1.out) to[bend left] (mynot2.in)
    (mynot2.out) to[bend left] (mynot3.in)
    (mynot3.out) to[bend left] (mynot4.in)
    (mynot4.out) to[bend left] (mynot5.in)
    (mynot5.out) to[bend left] (mynot1.in);
    \end{circuitikz} \end{center}

ここに画像の説明を入力してください

答え1

極座標を使用するのも 1 つの方法です。

\documentclass[margin=5pt]{standalone}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}
        \draw (  -0:3) node[not port,rotate= -90] (mynot1) {}
              ( -72:3) node[not port,rotate=-162] (mynot2) {}
              (-144:3) node[not port,rotate=-234] (mynot3) {}
              (-216:3) node[not port,rotate=-306] (mynot4) {}
              (-288:3) node[not port,rotate=-378] (mynot5) {}
              (mynot1.out) to[bend left] (mynot2.in)
              (mynot2.out) to[bend left] (mynot3.in)
              (mynot3.out) to[bend left] (mynot4.in)
              (mynot4.out) to[bend left] (mynot5.in)
              (mynot5.out) to[bend left] (mynot1.in);
    \end{circuitikz}
\end{document}

出力

ループ マクロを使用すると\foreach、コードの繰り返しを回避できます。

\ドキュメントクラス

\documentclass[margin=5pt][margin=5pt]{standalone}
\usepackage{circuitikz}

\begin{document}
    \begin{circuitikz}
        \foreach \i in {0,...,4} {
            \draw (-\i * 72:3) node[not port,rotate=-90 - \i * 72] (mynot\i) {};
        }
        \foreach[remember=\i as \j (initially 4)] \i in {0,...,4} {
            \draw (mynot\j.out) to[bend left] (mynot\i.in);
        }
    \end{circuitikz}
\end{document}

完全な円を得るのはより困難です。 1 つの問題は、circutikznot gate ノードに既に直線セグメントが含まれており、これを簡単に取り除くことができないことです。

pgfこのゲートを使用するように設定しておらず、のライブラリの not ゲートと交換する用意がある場合circuits.logic.US、状況は少し簡単になります。唯一の問題は、このノードのアンカーが実際にはと のアンカーcenterの中央にないため、すべての入力と出力が実際に同じ円上にあることを確認するために、さらにいくつかのトリックが必要になることです。inputoutput

このため、まずは測定可能な偽のノードを描画し、各ノードの正しい座標を計算します。その後、数学を使用して、ゲートを接続する各アークの正しい角度と半径を計算します。

\documentclass[margin=5pt]{standalone}
\usepackage{circuitikz}
\usetikzlibrary{circuits.logic.US}

\begin{document}
    \begin{circuitikz}[not/.style={circuit logic US,not gate}]
        \newcommand\radius{2}
        \newcommand\ngates{5}

        % draw a hidden not gate so we can measure the distance between its input and output
        \begin{pgfinterruptboundingbox}
            \node[not,anchor=input,transform canvas={scale=0}] at (0, \radius) (dummynot) {};
        \end{pgfinterruptboundingbox}

        \foreach \i in {1,...,\ngates} {
            \draw let \p0 = (dummynot.output) in        % \x0 is now the "length" of the node, \y0 is the radius
                  (-\i * 360 / \ngates:\y0)             % this is the position on the circle
                  ++(-90 - \i * 360 / \ngates:-\x0 / 2) % this is the offset that makes the input and output lie at the same distance from the center
                  node[not,anchor=input,rotate=-90 - \i * 360 / \ngates] (mynot\i) {};
        }
        \foreach \i in {1,...,\ngates} {
            \draw let \p0 = (mynot\i.output),
                      \p1 = (mynot\i.input),
                      \p2 = (dummynot.output) in
                  (\p0) arc[start angle={atan2(\y0, \x0)},delta angle={2 * atan2(\x2 / 2, \y2) - 360 / \ngates},radius={veclen(\p0)}];
        }
    \end{circuitikz}
\end{document}

5つのゲート 11 ゲート 4つのゲート 2つのゲート 1 ゲート

関連情報