我需要幫忙用 Circuitikz 畫這個電路

我需要幫忙用 Circuitikz 畫這個電路

我是 Circuitikz 的新手。因此,我需要一些幫助來繪製實驗室報告的小電路。如果有人幫助我,我將非常感激。這是電路:

在此輸入影像描述

我設法做到了這一點:

\begin{circuitikz}
    % Variable Voltage Source
    \draw (0,0) to[american voltage source, v=$V_s$] (0,3);
    
    % Draw node
    \node at (1,3) [circle, draw, fill=black, inner sep=0pt, minimum size=3pt] {};
    
    % Connect to node
    \draw (0,3) to[short] (1,3);

    % Open circuit
    \draw (1,4) -- (2,3) to[short, *-*] (2,3);
    
    % Ammeter
    \draw (2,3) -- (2.5,3) to[ammeter, l=A] (4,3) -- (5,3);
    
    \draw (5,3) -- (5,0);
      
    \draw (0,0) to[short] (0,-2);

    \draw (0,-2) to[voltmeter] (5,-2);

    \draw (5,0) to[short] (5,-2);

    \draw (0,0) to[lamp, *-*] (5,0);
\end{circuitikz}

這是輸出:

在此輸入影像描述

這個可以嗎?或可以改進嗎?

答案1

我將使用這段程式碼:如果您仔細閱讀手冊教學部分中的範例,您將看到使用相對座標、命名座標以及垂直「技巧」-|和 的優點|-

\documentclass[border=2mm]{standalone}
% always select a type of voltage orientation
\usepackage[RPvoltages]{circuitikz}
\begin{document}
\begin{circuitikz}
    % Variable Voltage Source
    % you are using an american symbol with european (arrow) voltage notation, without
    % specifying a direction style. Avoid the horrible double marking of the voltage
    % better use relative movements, name the generator for future reference
    \draw (0,0) coordinate(start)
        to[american voltage source, l=$V_s$, name=vv] ++(0,2)
        % continue the drawing with the switch:
        |- ++(1,1) to[nos=L, *-*] ++(1,0)
        % Ammeter: the newer rmeterwa symbol is, in my opinion, better
        to[rmeterwa, t=A] ++(3,0)
        % move to the same vertical position than start
        coordinate(upper left) -- (upper left |- start)
        % close with the lamp
        coordinate(start lamp) to [lamp, *-*] (start);
    % using one path gives better "corner" junctions, as above.
    % now add the voltmeter
    \draw (start) -- ++(0,-2) coordinate(start v)
        to[rmeterwa, t=V] (start v -| start lamp) -- (start lamp);
    % add a tunable arrow to the generator, to show it's variable
    \ctikztunablearrow[color=gray]{2}{1.2}{-30}{vv}
\end{circuitikz}
\end{document}

在此輸入影像描述

電路中的所有數字都是相對的,然後用命名座標進行連接。因此,如果您認為繪圖太寬,您可以將++(3,0)電流表變更為++(2,0)

在此輸入影像描述

而不觸及程式碼的任何其他部分。

相關內容