如何在乳胶中模拟逻辑电路?

如何在乳胶中模拟逻辑电路?

我必须模拟 JK 触发器的工作。使用 circuitikz 分别绘制每个门然后进行模拟非常麻烦,因为我以后必须制作复杂的电路。

在网上搜索后我发现了这个解决方案: 如何将矢量图形嵌入到 LaTeX 文档中

即在proteus中画出电路,然后以svg格式导出,然后使用pdf_latex格式添加到latex文档中。

但是,有没有办法使用可以导出到乳胶的库或工具来模拟电路,而不是手动逐帧进行?

编辑:https://drive.google.com/open?id=0Bzi4BkL3Q2szUHBYMHNlM2Zzb2s 这包含一个带有 SR 闩锁模拟的幻灯片。我想做类似的事情

这是我设法做到的。线条没有对齐,电路应该在页面的右侧,我也不知道该怎么做。

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Madrid}
\usepackage[american]{circuitikz}
\usepackage{tikz}


\begin{document}
\maketitle

\begin{frame}{SIMULATION}
   \begin{circuitikz}

 \draw
(20,10) node[nand port](mynand1){}
(20,12) node[nand port](mynand2){}
(23,10) node[nand port](mynand3){}
(23,12) node[nand port](mynand4){}

(mynand1.out) -- (mynand3.in 1)
(mynand2.out) -- (mynand4.in 2);
\end{circuitikz} 
\end{frame}

\end{document}

答案1

这里尝试通过一个允许对引脚进行着色的自定义门,我没有使用 beamer 类来制作动画,但是仍然会生成一个 PDF 输出,可以使用 imagemagic 转换器进行动画处理,在我的情况下,我在 arara 中有一个规则,允许我自动创建 gif 并在浏览器中将其可视化。

结果: 在此处输入图片描述

WIP 模块:

% arara: pdflatex: {synctex: yes, action: nonstopmode}
% arara: animate: {density: 200, delay: 100, other: -background white -alpha remove}
% arara: showanimate
\documentclass[tikz]{beamer}
\usetheme{Madrid}
\usepackage[american]{circuitikz}
\usepackage{tikz}
\usepackage{xcolor}
\definecolor{HIGH}{HTML}{ff0000}
\definecolor{LOW}{HTML}{0000ff}
\definecolor{SET}{HTML}{009900}
\definecolor{RESET}{HTML}{996600}
\definecolor{NC}{HTML}{000000}
\definecolor{INVALID}{HTML}{FE8637}
\usetikzlibrary{positioning}
\begin{document}

\foreach \C/\S/\R/\NS/\NR/\Q/\NQ/\STAT/\vC/\vS/\vR/\vNS/\vNR/\vQ/\vNQ in {
        LOW/LOW/LOW/HIGH/HIGH/NC/NC/No Change/0/0/0/1/1/Q_0/\overline{Q_0},
        LOW/LOW/HIGH/HIGH/HIGH/NC/NC/No Change/0/0/1/1/1/Q_0/\overline{Q_0},
        LOW/HIGH/LOW/HIGH/HIGH/NC/NC/No Change/0/1/0/1/1/Q_0/\overline{Q_0},
        LOW/HIGH/HIGH/HIGH/HIGH/NC/NC/No Change/0/1/1/1/1/Q_0/\overline{Q_0},
        HIGH/LOW/LOW/HIGH/HIGH/NC/NC/No Change/1/0/0/1/1/Q_0/\overline{Q_0},
        HIGH/LOW/HIGH/HIGH/LOW/RESET/SET/Reset/1/0/1/1/0/0/1,
        HIGH/LOW/HIGH/HIGH/LOW/RESET/SET/Reset/1/0/1/1/0/0/1,
        HIGH/HIGH/LOW/LOW/HIGH/SET/RESET/Set/1/1/0/0/1/1/0,
        HIGH/HIGH/LOW/LOW/HIGH/SET/RESET/Set/1/1/0/0/1/1/0,
        HIGH/HIGH/HIGH/LOW/LOW/INVALID/INVALID/Invalid/1/0/0/0/0/Q/Q',
        HIGH/HIGH/HIGH/LOW/LOW/INVALID/INVALID/Invalid/1/0/0/0/0/Q/Q'}{
\begin{frame}
\begin{tikzpicture}
\def\NAND(#1)#2[#3][#4][#5]{%CUSTOME NAND GATE TO ANIMATE PINS
    \begin{scope}[shift={(#1)}]
    % Draw the pins
    \draw[#3,line width=1pt] (-0.5,0.25) -- +(-0.25,0) coordinate (#2 IN1); % Pin 1 IN1
    \draw[#4,line width=1pt] (-0.5,-0.25) -- +(-0.25,0) coordinate (#2 IN2); % Pin 2 IN2
    \draw[#5,line width=1pt] (0.7,0) -- ++(0.25,0) coordinate (#2 OUT); % Pin 3 OUT
    \draw[#5,line width=1pt] (0.6,0) circle (2.5pt); % Pin 2 IN2
    % Draw the Discrete component body ANSI Symbol
    \draw[fill=blue!10,line width=1pt]
        (-0.5,0) |- ++ (0.5,0.5) arc (90:-90:0.5) -| cycle; % The body of IC
    % Label and component identifier.
    \draw[blue] (0,0) node []{\small\sf U-#2}; % IC LABEL
    \draw[blue] (0,0.7) node [align=center]{\sf\tiny NAND GATE}; % IC LABEL

  \end{scope}
}
\node[\Q, draw, anchor=west] at (3.5,-1.5) {\scriptsize\sf STATE: \STAT};
\NAND(0,0){1}[\S][\C][\NS];
\NAND(3,-0.25){2}[\NS][\NQ][\Q];
\NAND(0,-3){3}[\C][\R][\NR];
\NAND(3,-2.75){4}[\Q][\NR][\NQ];

%LOGIC C WIRE
\draw[color=\C,line width=1pt](-2,-1.5)
    node [anchor=south]{\sf C=\vC}
    to [short,o-*] ++(1,0) node(C1){} |- (1 IN2)
    (C1.center) |- (3 IN1);

%LOGIC S WIRE
\draw[color=\S,line width=1pt](1 IN1)
    to [short,-o] ++(-1.25,0) node [anchor=south]{\sf S=\vS};

%LOGIC NEG-S WIRE
\draw[color=\NS,line width=1pt](1 OUT)
    node [anchor=south]{$\mathsf{\overline{S}={\vNS}}$}--(2 IN1);

%LOGIC R WIRE
\draw[color=\R,line width=1pt](3 IN2)
    to [short,-o] ++(-1.25,0) node [anchor=south]{\sf R=\vR};

%LOGIC NEG-R WIRE
\draw[color=\NR,line width=1pt](3 OUT)
    node [anchor=south]{$\mathsf{\overline{R}={\vNR}}$}--(4 IN2);

%LOGIC Q WIRE
\draw[color=\Q,line width=1pt](2 OUT)
    to [short,-*] ++(0.5,0) coordinate (Q)
    to [short,-o]++(1,0)node [anchor=west]{$\mathsf{Q=\vQ}$}
    (4 IN1) -|++(-0.25,0.5) -- (Q |- 2 IN2) -- (Q);

%LOGIC NEG-Q WIRE
\draw[color=\NQ,line width=1pt](4 OUT)
    to [short,-*] ++(0.5,0) coordinate (NQ)
    to [short,-o]++(1,0)node [anchor=west]{$\mathsf{\overline{Q}={\vNQ}}$}
    (2 IN2) -|++(-0.25,-0.25) -- (NQ |- 4 IN1) -- (NQ);

\end{tikzpicture}
\end{frame}}
\end{document}

答案2

使用范围您仍然需要复制和粘贴,但不必每次都重命名节点。

\documentclass{beamer}
\usepackage[utf8]{inputenc}
\usetheme{Madrid}
\usepackage[american]{circuitikz}
\usepackage{tikz}


\begin{document}
\maketitle

\begin{frame}{SIMULATION}
   \begin{circuitikz}

\begin{scope}[yshift=0cm]
 \draw
   (0,0) node[nand port](mynand1){}
   (3,0) node[nand port](mynand2){}
   (mynand1.out) -- (mynand2.in 1);
\end{scope}
\begin{scope}[yshift=2cm]
 \draw
   (0,0) node[nand port](mynand1){}
   (3,0) node[nand port](mynand2){}
   (mynand1.out) -- (mynand2.in 2);
\end{scope}

\end{circuitikz} 
\end{frame}

\end{document}

相关内容