Electrical circuit means LaTeX and TikZ

Sometimes you need to draw a simple electrical circuit. Next, show how to do that without a third-party BY means of the LaTeX. It further is designed for those who are already familiar with this tool creating a vector for LaTeX as TikZ. Otherwise, you need to first familiarize yourself with TikZ. A little information on the Russian language there is here . Those who are already familiar with TikZ, see under cat. These ways of drawing diagrams in LaTeX I used in the process of writing a dissertation.

Here's a diagram you can draw LaTeX facilities:



the

the TikZ library circuits


For drawing electrical circuits is the circuits library. It is necessary to connect in the document preamble with the command \usetikzlibrary.Additionally, as the parameter of the tikzpicture environment, you need to specify
circuit ee IEC.

the
\usetikzlibrary{circuits}
\usetikzlibrary{circuits.ee}
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{circuits.logic.IEC}


The circuit elements are in this library special types of nodes and are set as normal nodes in TikZ command \node. Here we must note that the node text, specified in curly brackets, the radioactive elements are always empty. Reference designator and the value entered as the info parameter in square brackets. The parameter point up deploys a component by 90 degrees and point down — 270 degrees.

the
\node (R) to [resistor={info={$R$}}] at (2,2) {}; % horizontal resistor
\node (C1) at (3,0) [point up,capacitor={info = $C_1$, info'= 100 pF}] {}; %vertical condenser

Full list of all components available in the documentation for TikZ.
The schema node is set to the special node contact, which draw a filled circle.

the
\node (p2) [contact] at (6,-2) {}; % node at the point x=6, y=-2

The wires between elements are defined as usual in TikZ /draw. A direct line is drawn with the command

the
\draw (R1) -- (C1);


And the wire under an angle of 90 degrees is drawn with the command:

the
\draw (R1) |- (C1);


or
the
\draw (R1) | (C1);


The difference is that in the first case, the wire is first vertically and then horizontally, and in the second case — Vice versa.

To the wires, you can apply all options (arrows, thick line like normal trajectories. For example, a thick wire with an arrow:
the
\draw [thick, ->] (R1) | (C1);


The scheme can be combined with any graphics, TikZ, for example, place it on the schematic graph.

Now consider a small example with comments.

the
\documentclass[12pt]{article}
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\usepackage[koi8-r]{inputenc}
\usepackage[russian]{babel}
\usepackage[pdftex]{graphics}
\usepackage{tikz}

\usetikzlibrary{circuits} % plug-in libraries containing
\usetikzlibrary{circuits.ee} % HUGO for diagrams
\usetikzlibrary{circuits.ee.IEC}
\usetikzlibrary{arrows} % plug-in library arrow
\usetikzlibrary{patterns} % and with shading

\begin{document}

Mega-a description of the RLC-circuit

\begin{figure}[!h]
\begin{center}
\begin{tikzpicture}[circuit ee IEC] % must specify circuit ee IEC
\node (in) at (0,0) [contact] {}; % input contact
\node (L1) at (1,0) to [inductor={info = $L_1$, info'= 47 µh}] {}; % coil -
% info - designation in the diagram info' - nominal
\node (C1) at (3,0) to [capacitor={info = $C_1$, info'= 100 pF}] {}; % capacitor
\node (R) at (5,0) to [resistor={info = $R_1$, info'= 2 Ω}] {}; % resistor
\node (out) at (6,0) [contact] {}; %  output  clamp
\draw (in) -- (L1) -- (C1) -- (R) -- (out); %output clamp
\end{tikzpicture}
\end{center}
\caption{series RLC circuit}
\end{figure}

\begin{figure}[!h]
\begin{center}
\begin{tikzpicture}[circuit ee IEC]
\node (R) to [resistor={info={$R$}}] at (2,2) {}; % draw the resistor
\node (p1) [contact] at (3,2) {}; % draw the connection point R and
\node (C) [point up, capacitor={info={$C$}}] at (3,1) {}; % condensor turn 90 degrees
\node (p2) [contact] at (3,0) {}; % draw the connection point of the capacitor with a common wire
\draw [-latex] (p1) -- (5,2); % connect the nodes of the schema R and
\draw [latex-] (0,2) -- (R);
\draw (R) -- (p1) -- (C) -- (p2); % draw wire
\draw [latex-] (0,0) -- (p2);
\draw [-latex] (p2) -- (5,0);
\node at (0,1) {Input}; % sign where the Entrance is
\node at (5,1) {Exit}; % and where the Exit is

% now draw the frequency response graph as usual
\draw[xshift=60mm,-latex] (0,0) -- (4,0) node [anchor=west] {$\omega$}; % X-axis
\draw[xshift=60mm,-latex] (0,0) -- (0,3) node [anchor=south] {$K(\omega)$}; % Y-axis

declare function={K(\w)=1/sqrt(1+\w^2);}] plot [domain=0:3, samples=10,
smooth] (\x,{K(\x)}); % graph the frequency response
\end{tikzpicture}
\end{center}
\caption{RC - chain and its response}
\end{figure}
\end{document}


The result looks like this:





the

Package circuitikz


The package circuitikz is a further development of the library cirtuits. The package contains much more components: passive components, transistors, diodes, thyristors, logic gates, transformers. The circuitikz package incompatible with a library of circuits. Use them together impossible. The documentation for the package can be downloaded here

The package circuitikz connected in the preamble like so:

the
\usepackage[europeanresistors,americaninductors]{circuitikz}

With these parameters, HUGO gets the most friends to our Standards.

Package defines a special environment in which you want to place the schematic:
the
\begin{circuitikz}
\end{circuitikz}


Place it inside the tikzpicture environment is not necessary.

The ideology of drawing schemes are different from the library circuits. Components are nodes (nodes) and routes (paths). To place a single component, you need to create a path with the command /draw. The rotation component is the orientation of the path. As an example, consider the circuit of thyristor phase controller.

the
\begin{circuitikz}
\draw (-1,0) to [sV,l=$U_c$] (-1,2) % source of sinusoidal voltage
to [R, l=$R_н$,i > _=$R$] (2,2) % the resistor with the direction of current
to [Ty,l={VS},*-,n=VS] (2,0); % thyristor
\draw (VS.G) to [R,mirror,l=$R_у$i<_=$U$] ++(4,0) |- (2,2);
\draw (VS.cathode) |- (-1,0);
\end{circuitikz}

The result is the following:



the

Insights


For drawing diagrams in LaTeX, you can use the TikZ library circuits for or package circuitikz. I would recommend the last package only to draw complex circuits with semiconductor components. I usually prefer to use the library circuits. Schemes made using each of these methods do not appear in LaTeX alien used the same font and style lines, as in the rest of the document. All illustrations embedded in the document and everything is stored in a single file.

The disadvantage is that a large circuit slows down the compilation document, as each time you compile, they are rendered anew. Also on the drawing tools TikZ takes more time than using visual editors.

Resources:
    the
  1. More examples of diagrams made with TikZ and circuitikz: www.texample.net/tikz/examples/area/electrical-engineering
  2. the
  3. Documentation circuittikz: texdoc.net/show.php?pkg=circuitikz
  4. the
  5. List of free software for drawing electrical circuits: https://en.wikipedia.org/wiki/Wikipedia:WikiProject_Electronics/Programs
Article based on information from habrahabr.ru

Comments

Popular posts from this blog

Powershell and Cyrillic in the console (updated)

Active/Passive PostgreSQL Cluster, using Pacemaker, Corosync

Automatic deployment ElasticBeanstalk using Bitbucket Pipelines