
Graphics, Figures & Tables ⇒ Help with a circuitikz problem
Help with a circuitikz problem

NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
Help with a circuitikz problem
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Help with a circuitikz problem
welcome to the forum!
Ramón Jaramillo already wrote such an example. It's with colors but you can easily remove the colors. As it's your homework, you should at least work something with it. You should be able to understand it. The teacher may ask you. If you have questions about a specific detail, just ask.
If you click on "Open in writeLaTeX" you can directly edit it online.
Code: Select all
% Block Diagram for TTL IC Multiplexer 74HC153
% Author: Ramón Jaramillo.
\documentclass[tikz,border=10pt,12pt,x11names]{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.logic.US} % TiKZ Library for US Logic Circuits.
\begin{document}
\begin{tikzpicture}[circuit logic US, every circuit symbol/.style={thick}]
% Logic Gates in Left Side of Multiplexor
\node[buffer gate, point down,inputs={i}] (buf1) at (-1,3) {}; % Input Ea
\node[and gate,inputs={nnnn}, point down] (and1) at (0,-1) {};
\node[and gate,inputs={nnnn}, point down] (and2) at (1.5,-1) {};
\node[and gate,inputs={nnnn}, point down] (and3) at (3,-1) {};
\node[and gate,inputs={nnnn}, point down] (and4) at (4.5,-1) {};
\node[or gate,inputs={nnnn}, point down] (or1) at (2.25,-3) {};
\node[not gate, point down] (not1) at (5.5,4) {}; % Input Sa
\node[buffer gate, point down,inputs={i}] (buf2) at (5.5,2.5) {};
% Left Side connections
\draw [red, very thick] (buf1.output) -- ++(down:26.4mm) -| (and1.input 4);
\draw (and1.output) -- ++(down:5mm) -| (or1.input 4);
\draw (and2.output) -- ++(down:3mm) -| (or1.input 3);
\draw (and3.output) -- ++(down:3mm) -| (or1.input 2);
\draw (and4.output) -- ++(down:5mm) -| (or1.input 1);
\draw (not1.output) -- (buf2.input);
% Logic Gates in Right Side of Multiplexor
\node[not gate, point down] (not2) at (7,4) {}; % Input Sb
\node[buffer gate, point down,inputs={i}] (buf3) at (7,2.5) {};
\node[buffer gate, point down,inputs={i}] (buf4) at (13.50,3) {}; % Input Eb
\node[and gate,inputs={nnnn}, point down] (and5) at (8,-1) {};
\node[and gate,inputs={nnnn}, point down] (and6) at (9.5,-1) {};
\node[and gate,inputs={nnnn}, point down] (and7) at (11,-1) {};
\node[and gate,inputs={nnnn}, point down] (and8) at (12.5,-1) {};
\node[or gate,inputs={nnnn}, point down] (or2) at (10.25,-3) {};
\draw (not2.output) -- (buf3.input);
% Right Side connections
\draw [red, very thick] (buf4.output) -- ++(down:26.4mm) -| (and8.input 1);
\draw (and5.output) -- ++(down:5mm) -| (or2.input 4);
\draw (and6.output) -- ++(down:3mm) -| (or2.input 3);
\draw (and7.output) -- ++(down:3mm) -| (or2.input 2);
\draw (and8.output) -- ++(down:5mm) -| (or2.input 1);
% Inputs and Outputs of Multiplexer
\draw [black,very thick] (buf1.input) -- ++(up:5mm) node [above]{$E_a$};
% Enable Signal a
\draw [black,very thick] (buf4.input) -- ++(up:5mm) node [above]{$E_b$};
% Enable Signal b
\draw [black,very thick] (not1.input) -- ++(up:5mm) node [above]{$S_a$};
% Selection Signal a
\draw [black,very thick] (not2.input) -- ++(up:5mm) node [above]{$S_b$};
% Selection Signal b
% Inputs I_na with n={0, 1, 2, 3}
\draw [black,very thick] (and1.input 1) -- ++(up:4.3) node [above]{$I_{0a}$};
\draw [black,very thick] (and2.input 1) -- ++(up:4.3) node [above]{$I_{1a}$};
\draw [black,very thick] (and3.input 1) -- ++(up:4.3) node [above]{$I_{2a}$};
\draw [black,very thick] (and4.input 1) -- ++(up:4.3) node [above]{$I_{3a}$};
% Inputs I_nb with n={0, 1, 2, 3}
\draw [black,very thick] (and5.input 4) -- ++(up:4.3) node [above]{$I_{0b}$};
\draw [black,very thick] (and6.input 4) -- ++(up:4.3) node [above]{$I_{1b}$};
\draw [black,very thick] (and7.input 4) -- ++(up:4.3) node [above]{$I_{2b}$};
\draw [black,very thick] (and8.input 4) -- ++(up:4.3) node [above]{$I_{3b}$};
% Output of NOT gates
\draw [blue, very thick] (not1.output) -- ++(down:2.5mm)
-- ++(left:5mm) -- (5,0.45);
\draw [blue, very thick] (not1.output) -- (buf2.input);
\draw [Gold3, very thick] (not2.output) -- ++(down:2.5mm) -- ++(left:5mm)
-- (6.5,0.1);
\draw [Gold3, very thick] (not2.output) -- (buf3.input);
% Output of BUFFER gates
\draw [Brown4, very thick] (buf2.output) -- (5.5,1);
\draw [Green4, very thick] (buf3.output) -- (7,0.7);
% Interconnection of AND gates
\draw [red,very thick] (and1.input 4) -- ++(up:3mm) -| (and2.input 4)
-- ++(up:3mm) -| (and3.input 4) -- ++(up:3mm) -| (and4.input 4);
\draw [red,very thick] (and5.input 1) -- ++(up:3mm) -| (and6.input 1)
-- ++(up:3mm) -| (and7.input 1) -- ++(up:3mm) -| (and8.input 1);
\draw [blue,very thick] (and1.input 3) -- ++(up:9mm) -| (and2.input 3)
-- ++(up:9mm) -| (and5.input 3) -- ++(up:9mm) -| (and6.input 3);
\draw [Gold3,very thick] (and1.input 2) -- ++(up:6mm) -| (and3.input 2)
-- ++(up:6mm) -| (and5.input 2) -- ++(up:6mm) -| (and7.input 2);
\draw [Green4,very thick] (and2.input 2) -- ++(up:12mm) -| (and4.input 2)
-- ++(up:12mm) -| (and6.input 2) -- ++(up:12mm) -| (and8.input 2);
\draw [Brown4,very thick] (and3.input 3) -- ++(up:15mm) -| (and4.input 3)
-- ++(up:15mm) -| (and7.input 3) -- ++(up:15mm) -| (and8.input 3);
% Outputs of multiplexer
% Buffers at output of OR logic gates.
\node[buffer gate, point down,inputs={i}] (1y) at (2.25,-4.5) {};
\node[buffer gate, point down,inputs={i}] (2y) at (10.25,-4.5) {};
% Connecting output of OR logic gates to Buffers input
\draw (or1.output) -- (1y.input);
\draw (or2.output) -- (2y.input);
% Outputs of multiplexer
\draw (1y.output) -- ++(down:5mm) node [below]{$1Y$};
\draw (2y.output) -- ++(down:5mm) node [below]{$2Y$};
\end{tikzpicture}
\end{document}
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Help with a circuitikz problem
Code: Select all
% https://www.packtpub.com/hardware-and-creative/latex-cookbook
\documentclass[border = 10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{circuits.ee.IEC}
\begin{document}
\begin{tikzpicture}[
circuit ee IEC,
x = 3cm, y = 2cm,
every info/.style = {font = \scriptsize},
set diode graphic = var diode IEC graphic,
set make contact graphic = var make contact IEC graphic,
]
\foreach \i in {1,...,3} {
\node [contact] (lower contact \i) at (\i,0) {};
\node [contact] (upper contact \i) at (\i,1) {};
}
\draw (upper contact 1) to [diode] (lower contact 1);
\draw (lower contact 2) to [capacitor] (upper contact 2);
\draw (upper contact 1) to [resistor = {ohm = 6}]
(upper contact 2);
\draw (lower contact 2) to [resistor = {adjustable}]
(lower contact 3);
\draw (lower contact 1) to [
voltage source = {near start,
direction info = {volt = 12}},
inductor = {near end}]
(lower contact 2);
\draw (upper contact 2) to [make contact = {near start},
battery = {near end,
info = {loaded}}]
(upper contact 3);
\draw (lower contact 3) to [bulb = {minimum height = 0.6cm}]
(upper contact 3);
\end{tikzpicture}
\end{document}
Stefan
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
Help with a circuitikz problem
What I would improve at first:
- Avoid having coordinate numbers everywhere. Working on it, it's hard to remember what (3.5,4) actually means. It's better to use a name such as (E2) for it, so you always know the meaning. You can even label the coordinates, so no need for extra nodes.
- Use length or macros, build coordinates on parameters, which makes changes easier, such as shifting a whole row of coordinates upwards.
- Use styles for all what has formatting or color, so later re-styling is much easier.
- Let TikZ calculate points such as midpoints, so it will adjust automatically when you change coordinates.
- Use spacing to have a better readable code.
Code: Select all
\documentclass{article}
\usepackage[european]{circuitikz}
\usetikzlibrary{arrows.meta,quotes,positioning}
\def\distance{0.5}
\def\leftColor{red}
\def\rightColor{blue}
\def\Top{4}
\def\Bottom{1}
\tikzset{
sign1/.style={anchor=center, text=\leftColor},
sign2/.style={anchor=center, text=\rightColor},
}
\begin{document}
\begin{figure}[ht!]
\begin{circuitikz}
\coordinate (LeftTop) at ( -8,\Top);
\coordinate (RightTop) at ( 7,\Top);
\coordinate ["$B_1$"] (B1) at ( -6,\Top);
\coordinate ["$B_2$"] (B2) at ( 0,\Top);
\coordinate ["$E_1$"] (E1) at ( -3,\Top);
\coordinate ["$E_2$"] (E2) at (3.5,\Top);
\coordinate ["$C_1$"] (C1) at ( -1,\Top);
\coordinate (ZT) at (5.5,\Top);
\coordinate (LeftBottom) at ( -8,\Bottom);
\coordinate (RightBottom) at ( 7,\Bottom);
\coordinate (B2B) at ( 0,\Bottom);
\coordinate (E1B) at ( -3,\Bottom);
\coordinate ["below:$C_2$"] (C2) at (3.5,\Bottom);
\coordinate (ZB) at (5.5,\Bottom);
%\draw (LeftTop) to [open, v=$u_{ul}$,o-o] (LeftBottom);
\draw (LeftTop) -- (B1);
\draw (B1) to[R,l_=$h_{ie1}$,i>=$i_{b1}$,*-] (E1);
\draw (B1) to [R,l=$R_{B1}$,i>=$i_{B1}$,-*] (-6,1);
\draw (-0.5,4) to[european inductor,l_=$L_i$,i>=$i_{12}$,*-*] (-0.5,1);
\draw (E1) to[C,l_=$C_{E1}$,i>=$i_{e1}$,*-] (-3,1);
\draw (3.5,1) to[american current source,color=magenta,l=$h_{fe}i_{b2}$] (3.5,4);
\draw (C1) to[american current source,color=magenta,l=$h_{fe}i_{b1}$] (-3,4);
\draw (-0.5,4) to[R,l_=$h_{ie2}$,i>=$i_{b2}$,*-*] (3,4);
\draw (5.5,4) to[R,l_=$Z_{E2}$] (5.5,1);
\draw (RightTop) to[R,l_=$R_p$] (RightBottom);
\draw (LeftBottom) -- (RightBottom);
\draw (E2) -- (5.5,4);
\draw (5.5,4) -- (RightTop);
\draw (C1) -- (B2);
%\draw (7.5,4) to [open, v=$u_{iz}$,] (7.5,1);
\node (plus1) [below = \distance of LeftTop, sign1] {$+$};
\node (minus1) [above = \distance of LeftBottom, sign1] {$-$};
\draw [rounded corners, \leftColor, ->, >=Triangle]
($(plus1)!.5!(minus1)+(\distance,0)$) --
($(plus1)+(\distance,0)$) --
($(E1) -(\distance,\distance)$) --
($(E1B)+(-\distance,\distance)$) ->
($(minus1)+(\distance,0)$)
;
\node (plus2) at ($(B2)+(0,-\distance)$) [sign2] {$+$};
\node (minus2) at ($(B2B)+(0,\distance)$) [sign2] {$-$};
\node (plus3) at ($(RightTop)+(\distance,-\distance)$) [sign2] {$+$};
\node (minus3) at ($(RightBottom)+(\distance,\distance)$) [sign2] {$-$};
\draw [rounded corners, \rightColor, dashed, ->, >=Triangle]
($(B2)!.5!(B2B)+(\distance,0)$) --
($(B2)+(\distance,-\distance)$) --
($(ZT) + (\distance,-\distance)$) --
($(ZB) + (\distance,\distance)$) ->
($(minus2)+(\distance,0)$)
;
\end{circuitikz}
\end{figure}
\end{document}
Stefan
Help with a circuitikz problem
I would like to know if we can inverter(three phase) switching configuration with operating switches and current flow? mean at any given instant only 2 switches operate with one connected to positive supply and other to ground. Like if UVW are phases with 6 switches , U+W- conduct. I just started to use Latex today so i am not aware of complete commands to draw a electrical circuit.Please guide me through this.