Thanks for the fast replay.
I create more space between the switches. I added the current arrow, but is to close on the capacitor, how can i shift in the middle?
Code: Select all
\documentclass{article}
\usepackage{circuitikz}
\newcommand*\mpf[2]{% as in`my part format'
\ensuremath{\mathrm{#1}_{#2}}%
}%\mpf{type}{number}
\newcommand*\mcf[1]{\mpf{C}{#1}}% shortcut for C..
\newcommand*\msf[1]{\mpf{S}{#1}}% shortcut for S..
\begin{document}
\begin{circuitikz}[straight voltages]
% ground:
\draw (0,0) node[sground] (gnd) {};
% By going upwards, the labels are set to the left of their components
\draw (gnd) to [short, *-] ++(-2,0) % junction at (gnd), then straight line to left
coordinate (gndleft)
++(0,1.5) %space for S5
coordinate(s4s5) % as (lower) connecting point for C1
++ (0,1.5) %space for S4
coordinate (outleft)
-- ++(1.5,0) coordinate (out)
to [short,i=${2q/3}$, -o] ++(0,-1) node[below]{$V_{\mathrm{out}}$};
\draw (gnd) -- ++(1.5,0)
coordinate (gndright)
++ (0,1.5) %space for S7
coordinate (s6s7) % as (lower) connecting point for C2
++ (0,1.5) %space for S6
coordinate (outright)
-- (out)
++ (0,1.5) % space for S3
coordinate (s2s3) % as (upper) connecting point for C1
++ (0,1.5) %space for S2
coordinate (s1s2) % as (upper) connecting point for C2
++ (0,1.5) %space for S1
coordinate (in)
to [short, -o] ++(0,0.25) node[above]{$V_{\mathrm{in}}$};
\draw [black!20] %subdued switches:
(gndleft) to [nos, l=\msf{5}, a=2] (s4s5)
(s6s7) to [nos, l=\msf{6}, a=2] (outright)
(out) to [nos, l=\msf{3}, a=2] (s2s3)
(s1s2) to [nos, l=\msf{1}, a=2] (in);
\draw %closed switches:
(s4s5) to [short, l=\msf{4}, a=1, *-] (outleft)
(gndright) to [short, l=\msf{7}, a=1, -*] (s6s7)
(s2s3) to [short, l=\msf{2}, a=1, *-*] (s1s2);
\draw (out) to [short, *-] ++ (0,0);
\draw (s4s5) -- ++(-1.5,0)
-- ++(0,1) %by using this upwards line, C1 will be placed left of S3,
%i.e., C1 won't be too close to S4, hence the voltage can be put to its right
to [C, l=\mcf{1}, v=$\frac{V_{\mathrm{in}}}{3}$] ++ (0,1) %C1
|- (s2s3);
\draw (s6s7) -- ++(1.5,0) -- ++(0,1) %same vertical position for C2 as for C1
to [C, l=\mcf{2},i_>=$q/3$, v=$\frac{2 V_{\mathrm{in}}}{3}$] ++ (0,1) %C2
|- (s1s2);% lets the upper connecting point of C2 connect perpendicular
%to the junction between S1 and S2---first up, then left in this case
\end{circuitikz}
\end{document}
here the other code:
Code: Select all
\begin{circuitikz}[american] %increase the thickness of the line
%Grid for initial drawing.
%Comment next three lines once typesetting finished
\def\figHt{7};
\def\figWd{10};
\draw[step=0.5,very thin, black!20] (-0.5,-1) grid (\figWd,\figHt);
\foreach \x in {0,...,\figWd} {\node [anchor=north] at (\x,-1) {\x};}
\foreach \y in {-1,...,\figHt} {\node [anchor=east] at (-0.5,\y) {\y};}
%Instantiation of components
\draw (1,1) to[C,l^=$C_1$,-] (1,3);
\draw (9,4) to[C,l^=$C_2$] (9,1);
%interconnections
\draw (5,5.5) to[short, -o] (5,6) node[anchor=east]{$V_{in}$};
\draw (5,6) to[nos,l_=$S_1$,color=gray,-](5,4);
\draw (5,4) to[nos,l_=$S_2$,color=gray,-](5,3);
\draw (5,4) to [short,i_<=$q/3$,*-] (9,4);
\draw (5,3) to [short,i_>=$q/3$,*-] (1,3);
\draw (5,3) to[nos,l_=$S_3$,color=gray,-*](5,2);
\draw (3,2) -- (7,2);
\draw (3,2) to[nos,l_=$S_4$,color=gray,-*](3,1);
\draw (1,1) to [short,-*] (3,1);
\draw (3,1) to [nos,l_=$S_5$,color=gray,-](3,0);
\draw (7,2) to[nos,l_=$S_6$,color=gray,-*](7,1);
\draw (9,1) to [short,-*] (7,1);
\draw (7,1) to [nos,l_=$S_7$,color=gray,-](7,0);
\draw (3,0) to[short, -] (7,0);
\draw (5,0) to (5,0) node[sground]{};
\draw (5,2) to[short,i_>=$q2/3$,*-o] (5,1) node[anchor=west]{$V_{out}$};
\end{circuitikz}