# Chapter 12 - Waveshaping and Waveform Generation¶

## Example 12_1 Page No. 370¶

In :
from __future__ import division
VEE=15
print "VEE= %0.2f"%(VEE)," volts" #  voltage supply
VCC=15
print "VCC= %0.2f"%(VCC)," volts" #  voltage supply
VHI=+5
print "VHI= %0.2f"%(VHI)," volts" #  output voltage upper limit
VLO=-5
print "VLO= %0.2f"%(VLO)," volts" #  output voltage Lower limit
Vo=-VLO
IZmin=1*10**(-3)
print "IZmin= %0.2f"%(IZmin)," A" # Zener diode current rating
SR=0.5*10**(6)
print "SR= %0.2f"%(SR)," volts/seconds"#Slew rate
RB=100
print "RB= %0.2f"%(RB)+ " ohm"  # resistance
RA=10*10**(3)
print "RA= %0.2f"%(RA)+ " ohm"  # resistance
A = 5000
print "A = %0.2f"%(A)#op-amp gain
VREF=1
print "VREF= %0.2f"%(VREF)," volts" # Reference- voltage
print "part(i)"
RD=(VCC-Vo)/IZmin
print "RD=(VCC-Vo)/IZmin= %0.2f"%(RD)+ " ohm"  # Series dropping-resistance

print "part(ii)"
t=(VHI-VLO)/SR
print "t=(VHI-VLO)/SR= %0.2e"%(t)," seconds"# Time required to swing the output
tp=10*t
print "tp=(VHI-VLO)/SR= %0.2e"%(tp)," seconds"# Pulse width
fmax=1/(2*tp)
print "fmax=1/(2*tp) = %0.2f"%(fmax)," Hz"# Maximum frequency of operation of OP-AMP comparator
print "part(iii)"
B=RB/(RA+RB)
print "B=RB/(RA+RB)= %0.2f"%(B)#Feedback factor
VLTP=(VLO*B)+(VREF*(RA/(RA+RB)))
print "VLTP=(VLO*B)+[VREF*(RA/(RA+RB))]= %0.2f"%(VLTP)," volts" #   Lower trigger point
VUTP=(VHI*B)+(VREF*(RA/(RA+RB)))
print "VUTP=(VHI*B)+[VREF*(RA/(RA+RB))]= %0.2f"%(VUTP)," volts" # Upper trigger point
VH=VUTP-VLTP
print "VH=VUTP-VLTP= %0.2f"%(VH)," volts" #  Hysteresis voltage

VEE= 15.00  volts
VCC= 15.00  volts
VHI= 5.00  volts
VLO= -5.00  volts
IZmin= 0.00  A
SR= 500000.00  volts/seconds
RB= 100.00 ohm
RA= 10000.00 ohm
A = 5000.00
VREF= 1.00  volts
part(i)
RD=(VCC-Vo)/IZmin= 10000.00 ohm
part(ii)
t=(VHI-VLO)/SR= 2.00e-05  seconds
tp=(VHI-VLO)/SR= 2.00e-04  seconds
fmax=1/(2*tp) = 2500.00  Hz
part(iii)
B=RB/(RA+RB)= 0.01
VLTP=(VLO*B)+[VREF*(RA/(RA+RB))]= 0.94  volts
VUTP=(VHI*B)+[VREF*(RA/(RA+RB))]= 1.04  volts
VH=VUTP-VLTP= 0.10  volts


## Example 12_2 Page No. 372¶

In :
from math import log
from __future__ import division
Vo=14
print "Vo= %0.2f"%(Vo)," volts" #  output voltage
f=500
print "f = %0.2f"%(f)," Hz"#frequency
IB2=500*10**(-9)
print "IB2= %0.2e"%(IB2)," A" #base- Current
B=0.5
print "B=%0.2f"%(B)#Feedback factor
vf=B*Vo
print "vf=B*Vo= +%0.2f"%(vf),", -%0.2f"%(vf)," volts" # Feedback voltage
IR=100*IB2# Taking IR as 100 times that of IB2
print "IR=100*IB2= %0.2e"%(IR)," A" # Current in RB resistor
RB=vf/IR
print "RB=vf/IR= %0.2f"%(RB)+ " ohm"  # resistance
RA=RB*((1/B)-1)# Using formulae B=RA/(RA+RB)
print "RA=RB*((1/B)-1)= %0.2f"%(RA)+ " ohm"  # resistance
RF=100*10**(3)#Choosing RF=100k
print "RF= %0.2f"%(RF)+ " ohm"  #Feedback resistance
C1=1/(2*RF*f*log(1+(2*RB/RA)))
print "C1=1/[2*RF*f*log(1+(2*RB/RA))]= %0.2e"%(C1)," farad" # calculated capacitance value

Vo= 14.00  volts
f = 500.00  Hz
IB2= 5.00e-07  A
B=0.50
vf=B*Vo= +7.00 , -7.00  volts
IR=100*IB2= 5.00e-05  A
RB=vf/IR= 140000.00 ohm
RA=RB*((1/B)-1)= 140000.00 ohm
RF= 100000.00 ohm


## Example 12_3 Page No. 373¶

In :
from __future__ import division
Vo=14
print "Vo= %0.2f"%(Vo)," volts" #  output voltage
f=500
print "f = %0.2f"%(f)," Hz"#frequency
R2=10*10**(3)
print "R2= %0.2f"%(R2)+ " ohm"  # resistance
VTW=14
print "VTW= %0.2f"%(VTW)," volts" # Triangular peak-peak output voltage
T=1/f
C2=(Vo*T)/(2*VTW*R2)
print "C2=(Vo*T)/(2*VTW*R2)= %0.2e"%(C2)," farad" # calculated capacitance value for deriving triangular wave from square wave astable multivibrator

Vo= 14.00  volts
f = 500.00  Hz
R2= 10000.00 ohm
VTW= 14.00  volts


## Example 12_4 Page No. 374¶

In :
from __future__ import division
VI=-15
print "VI= %0.2f"%(VI)," volts" #  Input voltage
TSW=2*10**(-3)
print "TSW= %0.2e"%(TSW)," seconds"# triangular wave Sweep time
R=10*10**(3)
print "R= %0.2f"%(R)+ " ohm"  # resistance as ckt. parameter
C=0.5*10**(-6)
print "C= %0.2e"%(C)," farad" #  capacitance as ckt. parameter
S=-VI/(R*C)
print "Sweep rate=VI/(R*C)=%0.2f"%(S)+ " V/s" # Sweep rate for sweep generator
VSW=TSW*S
print "VSW=TSW*S= %0.2f"%(VSW)," volts" #   Sweep voltage amplitude

# note in book author has not provided any variable for sweep rate ... but here I have used 'S' for it .

VI= -15.00  volts
TSW= 2.00e-03  seconds
R= 10000.00 ohm
Sweep rate=VI/(R*C)=3000.00 V/s
VSW=TSW*S= 6.00  volts


## Example 12_5 Page No. 375¶

In :
from __future__ import division
VEE=15
print "VEE= %0.2f"%(VEE)," volts" #  voltage supply
VCC=15
print "VCC= %0.2f"%(VCC)," volts" #  voltage supply
R1=10*10**(3)
print "R1= %0.2f"%(R1)+ " ohm"  # resistance
RF=20*10**(3)
print "RF= %0.2f"%(RF)+ " ohm"  # Feedback resistance
RB1=3*10**(3)
print "R1= %0.2f"%(R1)+ " ohm"  # resistance
RB2=RB1
RF1=1*10**(3)
print "RF1= %0.2f"%(RF1)+ " ohm"  # Feedback resistance
RF2=RF1
Av=1*10**(3)
print "Av= %0.2f"%(Av)
print "part(i)"
VBR1= (VCC*RF1)/RB1
VBR2 = VBR1
print "VBR1=VBR2=(VCC*RF1)/RB1= %0.2f"%(VBR1)," volts" #Limit values at the break points and VBR=VBR1=VBR2
So=-RF/R1
print "So=-RF/R1= %0.2f"%(So) # slope of Transfer characteristic at zero crossings
S1=-(RF1/R1)
print "S1=S2=-RF1/R1= %0.2f"%(S1)# slope of Transfer characteristic at the extreme ends
VSL=(-VBR1/So)
print "VSL=VSU=(-VBR1/So)= %0.2f"%(VSL)," volts" #  magnitude of input voltage required to produce vo=VBR
VSU=VSL
print "part(ii)"
VSU=(VBR2/Av)#Formulae
print "VSU=VSL=(VBR2/Av)= -%0.2f"%(VSU),", +%0.2f"%(VSU)," volts" #  magnitude of input voltage required to produce vo=VBR in case gain Av is very large

VEE= 15.00  volts
VCC= 15.00  volts
R1= 10000.00 ohm
RF= 20000.00 ohm
R1= 10000.00 ohm
RF1= 1000.00 ohm
Av= 1000.00
part(i)
VBR1=VBR2=(VCC*RF1)/RB1= 5.00  volts
So=-RF/R1= -2.00
S1=S2=-RF1/R1= -0.10
VSL=VSU=(-VBR1/So)= 2.50  volts
part(ii)
VSU=VSL=(VBR2/Av)= -0.01 , +0.01  volts