How to draw single-phase half-wave rectifier in LaTeX

This tutorial is an introduction to a series of \LaTeX tutorials about the circuitikz package in which we will be drawing a half-wave rectifier. The aim of this latex tutorial is to redraw the rectifier shown in the next illustration. We will learn how to add electrical components like voltage source, diode, resistor and capacitor, and how to add labels. Ready, Let’s start!
draw single phase half wave rectifier latex
Single phase half wave rectifier drawn in LaTeX using circuitikz package

PGF-TikZ is a powerful tool for creating sophisticated graphics with vector representation. However, it lacks a good package for electric diagrams. Fortunately, circuitikz was created for this purpose, it provides the necessary macros to layout circuit diagrams for academic use in no time and in a rather intuitive, flexible and easy manner.

1. Minimal circuitikz code

Before we start using circuitikz, you should at least be familiar with the \LaTeX typesetting system without needing to be an expert. Basic knowledge of the TikZ package is also recommended but not necessary. Here is a minimal circuitikz code to start:

\documentclass{article}
\usepackage[american]{circuitikz}

\begin{document}

\begin{circuitikz}[voltage dir = RP]
% Here we place our code
\end{circuitikz}

\end{document}

In a circuitikz creation, we need at first to declare using the circuitikz package, here I declared it with the option \verb![american]! to tell the package we want to work with US symbols. Furthermore, I also specified the option \verb![voltage dir = RP]! but this time I specified it at the start of the environment like \verb|\begin{circuitikz}[voltage dir = RP]| as told in the package documentation. This option tells the package that the voltage arrows should be in direction of Rising Potential, which I find a more natural option than the default one (see section 4.2 “around page 97” of the circuitikz documentation).

2. Draw sinusoidal voltage source

We start drawing the circuit in the same way as a path in TikZ, but we specify special options for the elements:
\documentclass{standalone}
\usepackage[american]{circuitikz}

\begin{document}
\centering
\begin{circuitikz}[voltage dir = RP]
\draw (0,0)
to[sV,v=$u(t)$,i=$i_s$] (0,2); % The voltage source
\end{circuitikz}

\end{document}
sinusoidal voltage source latex
Latex Code v1

Starting at (0,0) we draw a sinusoidal voltage source (sV) to the coordinates (0,2), the option \verb!v=$u(t)$! shows the voltage signs with the label u(t) and \verb!i=$i_s$! shows the current direction with i_s as a label. 

Note that in case the package is called with the option \verb![european]! instead of \verb![american]! the voltage signs are replaced with arrows. Now we proceed to the diode and resistor.

3. Add diode and resistor elements

Firstly, we must draw a full diode (D*) from (0,2) to (3,2), then a resistor (R) from (3,2) to (3,0) with its label and current arrow, note that this time the label must be specified directly (\verb|R=$R_L$|) since the resistor voltage is omitted. Finally, we close with a short circuit (short) from (3,0) to (0,0).

\documentclass{standalone}
\usepackage[american]{circuitikz}

\begin{document}
\centering
\begin{circuitikz}[voltage dir = RP]
\draw (0,0)
to[sV,v=$u(t)$,i=$i_s$] (0,2) % The voltage source
to[D*] (3,2) % The diode
to[R=$R_L$,i=$i_L$] (3,0) % The resistor
to[short] (0,0);
\end{circuitikz}

\end{document}
Diode and resistor latex
Latex Code v2
incoming current arrow circuitikz
Latex Code v2 modified

Unlike active elements, it would be more convenient in passive elements like resistors to have incoming current arrow. Instead of using the default direction with (\verb|i=…|), circuitikz allows to specify the current direction as one pleases with \verb|i_>,i^<,i>_,i>^|

and other combinations, these allow to specify both direction and position of the label at once. A list of all possible combinations is depicted in section 4.3 around page 101 of the documentation. In our case it should be (\verb|i>^|) for the resistor (see illustration code v2 modified). Now, let’s proceed to the capacitor. 

4. Add capacitor to the circuit

Following the same steps, we can add the capacitor to our circuit using these properties \verb|[C=$C$,i>^=$i_C$,v=$v_o(t)$]|

\documentclass{standalone}
\usepackage[american]{circuitikz}

\begin{document}
\centering
\begin{circuitikz}[voltage dir = RP]
\draw (0,0)
to[sV,v=$u(t)$,i=$i_s$] (0,2) % The voltage source
to[D*] (3,2) % The diode
to[R=$R_L$,i&gt;^=$i_L$] (3,0) % The resistor
to[short] (0,0);
\draw (3,2)
to[short] (5,2)
to[C=$C$,i&gt;^=$i_C$,v=$v_o(t)$] (5,0) % The capacitor
to[short] (3,0);
\end{circuitikz}

\end{document}
rectifier latex circuitikz
Latex Code v3

5. Change components size

Our circuit still looks ugly, maybe due to the components’ sizes which seem inconsistent, and also the current arrows which have small lengths especially i_L. Both issues can be resolved by simply reducing the length of bipoles with \verb|\ctikzset{bipoles/length=0.8cm}| inside the \verb|circuitikz| environment, this will on the one hand change the size the bipoles for better appearance. We can also change the diode size with same manner as follows: \verb| \ctikzset{bipoles/diode/height=0.4}| \verb|\ctikzset{bipoles/diode/width=0.4}|
\documentclass{standalone}
\usepackage[american]{circuitikz}

\begin{document}
\centering
\begin{circuitikz}[voltage dir = RP]
\ctikzset{bipoles/length=0.8cm}
\ctikzset{bipoles/diode/height=0.4}
\ctikzset{bipoles/diode/width=0.4}
\draw (0,0)
to[sV,v=$u(t)$,i=$i_s$] (0,2) % The voltage source
to[D*] (3,2) % The diode
to[R=$R_L$,i>^=$i_L$] (3,0) % The resistor
to[short] (0,0);
\draw (3,2) 
to[short] (5,2)
to[C=$C$,i>^=$i_C$,v=$v_o(t)$] (5,0) % The capacitor
to[short] (3,0);
\end{circuitikz}

\end{document}
single phase half wave rectifier latex
Latex code v4

6. Change line drawing color and labels' font size

To change line drawing color to red, we will add this property to the circuitikz environment \verb|draw=red|. For labels’ font size, we will add the property \verb|font=\small| to the circuitikz environment. This will apply to all labels of the illustration. We can change each label locally by adding the same property to each element. Compiling the next code, we will get the last version of our illustration.

\documentclass{standalone}
\usepackage[american]{circuitikz}

\begin{document}
\centering
\begin{circuitikz}[voltage dir = RP,draw=red,font=\scriptsize]
\ctikzset{bipoles/length=0.8cm}
\ctikzset{bipoles/diode/height=0.4, bipoles/diode/width=0.4,}
\draw (0,0)
to[sV,v=$u(t)$,i=$i_s$] (0,2) % The voltage source
to[D*] (3,2) % The diode
to[R=$R_L$,i&gt;^=$i_L$] (3,0) % The resistor
to[short] (0,0);
\draw (3,2)
to[short] (5,2)
to[C=$C$,i&gt;^=$i_C$,v=$v_o(t)$] (5,0) % The capacitor
to[short] (3,0);
\end{circuitikz}

\end{document}
draw single phase half wave rectifier latex
Latex code v5

Leave a Reply

avatar
  Subscribe  
Notify of
Close Menu