Chapter 8 : Non-linear Applications of Op-amp

example 8.1, Page No. 332

In [5]:
# Threshold voltages(refer fig. 8.20)

import math
#Variable declaration
Vcc = 15             # positive saturation voltage
Vee = -15            # Negative saturation voltage
R1 = 120.0           # resistance R1
R2 = 51*10**3        # resistance R2
vin = 1              # input voltage

#Calculations
Vut = Vcc*R1/(R1+R2)
Vult = Vee*R1/(R1+R2)

#Result
print("Vut  = %.1f mV\nVult = %.1f mV"%(Vut*1000,Vult*1000))
Vut  = 35.2 mV
Vult = -35.2 mV

example 8.2, Page No.333

In [3]:
# Values of R1 and R2

import math
# Variable declaration
Vcc = 12.0                      # positive saturation voltage
Vee = -12.0                     # negative saturation voltage
Vh = 6.0                        # hysteresis width


#Calculations
R1 = 10*10**3
R2 = (1-(Vh/(Vcc-Vee)))*R1/(Vh/(Vcc-Vee))

#Result
print("R1 = %.0f k-ohm\nR2 = %.0f k-ohm"%(R1/1000,R2/1000))
    
R1 = 10 k-ohm
R2 = 30 k-ohm

example 8.3, Page No. 333

In [6]:
# Schmitt trigger

import math
#Variable declaration
Vh = 2.0              # hysteresis width
Vlt = -1.5            # lower threshold
Vpp = 5.0             # sine wave amplitude
f = 1000.0            # frequency

# Calculations
Vut = Vh - abs(Vlt)
Vm = Vpp/2
theta = math.asin(-Vlt/Vm)
theta = theta*180/math.pi
T = 1/f
T1 = T*(180.0+theta)/360.0
T2 = T-T1

#Result
print("Time duration for negative portion , T1 = %.3f ms\nTime duration for positive portion , T2 = %.3f ms"%(T1*1000,T2*1000))
Time duration for negative portion , T1 = 0.602 ms
Time duration for positive portion , T2 = 0.398 ms

example 8.4, Page No. 334

In [12]:
# Schmitt Trigger

import math
#Variable declaration
Vh = 10.0                # ligher threshold
Vl = -10.0               # lower threshold
Imax = 100*10**-6        # maximum current through R1 and R2
Vhv = 0.1                # hysteresis width


#Calculations
R2 = 1000.0              # assumed
R1= R2*(1-(Vhv/(2*Vh)))/(Vhv/(2*Vh))
R = R1*R2/(R1+R2)

#Result
print("R1 = %.0f k-ohm\nR2 = %.0f k-ohm\nR1||R2 = %.0f ohm"%(R1/1000,R2/1000,R))
# R1||R2 value is in ohm and not in k-ohm
R1 = 199 k-ohm
R2 = 1 k-ohm
R1||R2 = 995 ohm

example 8.5, Page No. 334

In [13]:
 print("Theoretical example")
Theoretical example

example 8.6, Page No.336

In [16]:
# Threshold voltages and hysteresis voltage (refer fig. 8.26)

import math
#Variable declaration
VsatP = 12.0              # Positive saturation voltage
VsatN = -12.0             # Negative saturation voltage
R1 = 1000.0               # Resistor R1 
R2 = 3*10**3              # Resistor R2

#Result
Vlt = -VsatP*R1/R2
Vut = -VsatN*R1/R2
Vh = (R1/R2)*abs(VsatP-VsatN)

#Result
print("Vlt = %.0f V\nVut =  %.0f V\nVh  =  %.0f V"%(Vlt,Vut,Vh))
Vlt = -4 V
Vut =  4 V
Vh  =  8 V

example 8.7, Page No.336

In [19]:
# Schmitt's trigger (refer fig. 8.27)

import math
#Variable declaration
Vcc = 12.5             # positive supply voltage
Vee = -12.5            # negative supply voltage
R1 = 80.0*10**3        # Resistor R1
R2 = 20.0*10**3        # Resistor R2

#Calcualtions
Vut = R2*Vcc/(R1+R2)
Vlt = R2*Vee/(R1+R2) 
Vhv =  R2*2*Vcc/(R1+R2)

#Result
print("Vlt = %.1f V\nVut =  %.1f V\nVh  =  %.1f V"%(Vlt,Vut,Vhv))
Vlt = -2.5 V
Vut =  2.5 V
Vh  =  5.0 V

example 8.8, Page No.350

In [20]:
print("Theoretical example")
Theoretical example

example 8.9, Page No.360

In [41]:
# Sample and hold circuit

import math
#Variable declaration
del_Vin = 5.0                 # changes in input volage
FRR = 80.0                    # feedthrough rejection ratio

#Calculations
math.sqrt(5)
del_Vout = del_Vin/math.pow(10,FRR/20)

#Result
print("Change in output = %.4f V = %.1f mV"%(del_Vout,del_Vout*1000))
Change in output = 0.0005 V = 0.5 mV

example 8.10, Page No. 365

In [36]:
# Threshold voltages and frequency of oscillation ( refer fig.8.72)

import math
#Variable declaration
R1 = 86*10**3                 # Resistor R1
R2 = 100*10**3                # Resistor R2
Vcc = 15.0                    # positive saturation voltage
Vee = -15.0                   # negative saturation voltage
Rf = 100*10**3                # feedback resistance
C = 0.1*10**-6                # capacitance

#Calculations
Vut = R1*Vcc/(R1+R2)
Vlt = R1*Vee/(R1+R2) 
fo = 1/(2*Rf*C*math.log((Vcc-Vlt)/(Vcc-Vut)))

#Result
print("(i)  Vut =  %.2f V\n(ii) Vlt = %.2f \n(iii)fo  =  %.0f Hz"%(Vut,Vlt,fo))
(i)  Vut =  6.94 V
(ii) Vlt = -6.94 
(iii)fo  =  50 Hz

example 8.11, Page No. 365

In [37]:
print("Theoretical example")
Theoretical example