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

극좌표를 사용하는 것이 한 가지 방법이 될 것입니다.

\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

\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}

완벽한 원을 얻는 것이 더 어렵습니다. 한 가지 문제는 circutikz게이트가 아닌 노드에 쉽게 제거할 수 없는 직선 세그먼트가 이미 포함되어 있다는 것입니다.

이 게이트를 사용하도록 설정되지 않았고 pgf님의 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개

관련 정보