# Chapter 2: Diode Application

### Example 2.1, Page Number: 46

In [1]:
%matplotlib inline

Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].
For more information, type 'help(pylab)'.
In [2]:
import math

# variable declaration
V_p=50;    #Peak value is 50V

#calculation
V_avg=V_p/math.pi;

#result
print "average value of half wave rectifier = %.2f volts" %V_avg

average value of half wave rectifier = 15.92 volts

### Example 2.2(a), Page Number: 46

In [3]:
import math

f=1;    #frequency
V_p_in=5;  #peak input

#calculation
V_pout=V_p_in-0.7;   #output voltage
t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f);

#result
print "half wave rectifier output = %.2f volts" %V_pout;

half wave rectifier output = 4.30 volts

### Example 2.2(b), Page Number: 46

In [4]:
import math

f=1;    #frequency
T=1/f;  #time period
V_p_in=100;  #peak input voltage

#calculation
V_pout=(V_p_in-0.7);    #peak output
t_d=(math.asin(0.7/V_p_in))/(2*math.pi*f)

#result
print "output of half wave rectifier = %.2f volts" %V_pout

output of half wave rectifier = 99.30 volts

### Example 2.3, Page Number: 48

In [5]:
import math

# variable declaration
V_p_in=156;    #Peak input voltage
V_p_pri=156;   #Peak voltage of primary of transformer
n=0.5;         #Turn ratio is 2:1

#calculation
V_p_sec=n*V_p_pri;
V_p_out=(V_p_sec-0.7); #Peak output voltage

#result
print "peak output voltage of half wave rectifier = %.1f volts" %V_p_out

peak output voltage of half wave rectifier = 77.3 volts

### Example 2.4, Page Number: 49

In [6]:
import math

# variable declaration
V_p=15;    #Peak voltage in volt

#calculation
V_avg=(2*V_p)/math.pi;

#result
print "Average value of output of full wave rectifier = %.2f volts" %V_avg

Average value of output of full wave rectifier = 9.55 volts

### Example 2.5, Page Number: 52

In [7]:
V_p_pri=100.0;   #Peak voltage across primary winding
n=1.0/2;           #tun ratio is 2:1
V_p_sec=n*V_p_pri;
V_sec=V_p_sec/2;    #voltage across each secondary is half the total voltage
V_pout=V_sec-0.7;

print('full wave rectifier output voltage = %f V'%V_pout)
PIV=2*V_pout+0.7;
print('PIV = %fV'%PIV)

full wave rectifier output voltage = 24.300000 V
PIV = 49.300000V

### Example 2.6, Page Number: 54

In [8]:
import math

# variable declaration
V_rms=12.0;              #rms secondary voltage

#calculation
V_p_sec=math.sqrt(2)*V_rms;   #peak secondary voltage
V_th=0.7;                #knee voltage of diode
V_p_out=V_p_sec-2*V_th;  #in one cycle, 2 diodes conduct
PIV=V_p_out+V_th;        #applying KVL

#result
print "Peak output voltage = %.2f volt" %V_p_out
print "PIV across each diode = %.2f volt" %PIV

Peak output voltage = 15.57 volt
PIV across each diode = 16.27 volt

### Example 2.7, Page Number: 58

In [9]:
import math

# variable declaration
V_rms=115;     #rms of primary

#calculation
V_p_pri=math.sqrt(2)*V_rms;    #peak voltage across primary
n=0.1;        #turn ratio is 10:1
V_p_sec=n*V_p_pri;    #primary voltage across secondary
V_p_rect=V_p_sec-1.4  #unfiltered peak rectified voltage
#we subtract 1.4 because in each cycle 2 diodes conduct & 2 do not
f=120;    #frequency of full wave rectified voltage
V_r_pp=(1/(f*R_l*C))*V_p_rect;    #peak to peak ripple voltage
V_DC=(1-(1/(2*f*R_l*C)))*V_p_rect;
r=V_r_pp/V_DC;

#result
print "Ripple factor = %.3f " %r

Ripple factor = 0.079

### Example 2.8, Page Number: 62

In [10]:
import math

# variable declaration
V_REF=1.25;    #in volts
V_R1=V_REF;    #voltage in volt
R1=220.0;    #in ohms

#calculation
# MAX VALUE OF R2=5000 Ohms
R2_min=0.0;  #min resistance
R2_max=5000.0;  #max value of resistance

#result
print "minimum output voltage = %.2f volt" %V_out_min
print "maximum output voltage = %.2f volt" %V_out_max

minimum output voltage = 1.25 volt
maximum output voltage = 29.91 volt

### Example 2.9,Page Number: 64

In [11]:
V_NL=5.18    #No load output voltage

load regulation percent = 0.58%

### Example 2.10, Page Number: 66

In [12]:
import pylab as py
import numpy as np

#let input wave be V_in=V_p_in*sin(2*%pi*f*t)
f=1.0;   #Frequency is 1Hz
T=1/f;
R_1=100.0;    #Resistances in ohms
V_p_in=10.0;    #Peak input voltage
V_th=0.7;    #knee voltage of diode

V_p_out=V_p_in*(R_L/(R_L+R_1));    #peak output voltage
print('peak output voltage = %.2f V'%V_p_out)

t = np.arange(0, 3.5 , 0.0005)
z=V_p_in*np.sin(2*np.pi*f*t)*(R_L/(R_L+R_1))

subplot(211)
plot(t,z)
ylim(-9.09,9.09)
title('Input Voltage Waveform')

subplot(212)
plot(t,z)
ylim(-0.07,9.09)
title('Output Voltage Waveform')

peak output voltage = 9.09 V
Out[12]:
<matplotlib.text.Text at 0xa3bf44c>

### Example 2.11, Page Number: 67

In [13]:
#from pylab import figure, show
#from numpy import arange, sin, pi,bool
#import numpy as np
import pylab as py
import numpy as np
#let input wave be V_in=V_p_in*sin(2*%pi*f*t)
f=1.0;    #Frequency is 1Hz
T=1/f;
V_p_in=10;    #Peak input voltage
V_th=0.7;    #knee voltage of diode
print('max output voltage is 5.7V')
print('min output voltage is -5.7V')

###############GRAPH Plotting#################################
t = arange(0.0,4.5,0.0005)
V_in=V_p_in*sin(2*pi*f*t);

Vout=V_in;
#fig = figure(2)
subplot(211)
plot(t,V_in)
#ax2.grid(True)
ylim( (-10,10) )
title('Input to the +ve and -ve diode limiter ')
subplot(212)
plot(t,V_in)
#ax1.grid(True)
ylim( (-5.7,5.7) )
title('Output of +ve and -ve diode limiter')


max output voltage is 5.7V
min output voltage is -5.7V
Out[13]:
<matplotlib.text.Text at 0xa6c976c>

### Example 2.12, Page Number: 76

In [14]:
#variable declaration
V_p_in=18.0;   #peak input voltage is 18V
V_supply=12.0;
R2=100.0;
R3=220.0;    #resistances in ohms
#calculation
V_bias=V_supply*(R3/(R2+R3));

#result
print('diode limiting the voltage at this voltage =%fV'%V_bias)

diode limiting the voltage at this voltage =8.250000V

### Example 2.13, Page Number: 78

In [15]:
V_p_in=24.0;
V_DC=-(V_p_in-0.7);    #DC level added to output
print('V_DC = %.1fV'%V_DC)

V_DC = -23.3V