# Chapter 11 : Test Signal Generation¶

## Example11_1,pg 343¶

In [11]:
# limits of duty cycle

import math
#Variable decl;aration
R1=1.0*10**3               #input resistance
R2=1.0*10**3               #feedback resistor
R3=1.0*10**3               #non inverting ter. resistor
R8=1.0*10**3               #potentiometer
R4=1.0*10**3

#Calculations
DF1=(R1/((2*R1)+R8))     #duty factor lim.-1
DF2=(R1+R4)/((2*R1)+R8)  #duty factor lim.-2
#T=(((2*R4*C*((2*R1)+R8)))/R1)*(Vt/Vi)=((6*R4*C*Vt)/Vi)

#Result
print("range of duty factor is DF1 to DF2 i.e.")
print("%.2f  to %.2f "%(DF1,DF2))
print("\nlimits of t1 and t2:")
print("(T/3)  to  (2T/3)")

range of duty factor is DF1 to DF2 i.e.
0.33  to 0.67

limits of t1 and t2:
(T/3)  to  (2T/3)


## Example11_2,pg 344¶

In [11]:
# determine sinewave amplitude and segment slopes

import math
#Variable declaration
Vtx=5.0                         #triangular peak(+/-)5
Vsx=(2/math.pi)*Vtx             #sinewave peak
#if n=3 then there are 2*3=6 break points these are at o/p voltages
n=3.0                           #break point parameter

#Calculations
Vs1=(2/math.pi)*Vtx*math.sin((1*math.pi)/((2*n)+1))
Vs2=(2/math.pi)*Vtx*math.sin((2*math.pi)/((2*n)+1))
Vs3=(2/math.pi)*Vtx*math.sin((3*math.pi)/((2*n)+1))
#calculating slopes
ms1=(((2*n)+1)/math.pi)*(math.sin((math.pi*(1+1))/((2*n)+1))-math.sin((math.pi*1)/((2*n)+1)))
ms2=(((2*n)+1)/math.pi)*(math.sin((math.pi*(2+1))/((2*n)+1))-math.sin((math.pi*2)/((2*n)+1)))
ms3=(((2*n)+1)/math.pi)*(math.sin((math.pi*(3+1))/((2*n)+1))-math.sin((math.pi*3)/((2*n)+1)))

#Result
print("break points:")
print("output voltages:")
print("Vs1 = %.2f V  "%Vs1)
print("Vs2 = %.2f V  "%Vs2)
print("Vs3 = %.2f V\n"%Vs3)
print("segment slopes:")
print("ms1 = %.2f "%ms1)
print("ms2 = %.2f "%ms2)
print("ms3 = %.2f "%ms3)
#Answers are slightly different than book

break points:
output voltages:
Vs1 = 1.38 V
Vs2 = 2.49 V
Vs3 = 3.10 V

segment slopes:
ms1 = 0.78
ms2 = 0.43
ms3 = 0.00


## Example11_3,pg 505¶

In [20]:
# find inductance

import math
#Variable declaration
R1=0.0              #resistance
C=0.1*10**-6        #capacitance
f=1.0*10**3         #frequency

#Calculations
L=(1.0/(((2*math.pi*f)**2)*C))

#Result
print("Inductance of circuit:")
print("L = %.6f H "%(L))
#Answer do not matche with book

Inductance of circuit:
L = 0.253303 H


## Example11_4,pg 506¶

In [23]:
# resonance frequency of crystal

import math
#Variable declaration
C1=4*10**-12       #Capacitance
L=94*10**-3        #inductance
C=13*10**-9        #capacitance
R=91.3             #resistance

#Calculations
f1=(1/(2*math.pi))*((L*C)**(-1.0/2))                     #resonance frequency-1
f2=(math.sqrt(1+(C/C1))/(2*math.pi*math.sqrt(L*C)))      #resonance frequency-2

#Result
print("resonance frequency-1:")
print("f1 = %.2f kHz\n"%(f1/1000))
print("resonance frequency-2:")
print("f2 = %.2f kHz"%(f2/1000))
#Answer for f2 is slightly different

resonance frequency-1:
f1 = 4.55 kHz

resonance frequency-2:
f2 = 259.59 kHz


## Example11_5,pg 506¶

In [24]:
# find R in CR section

import math
#Result
f=1.0*10**3             #frequency
C=0.01*10**-6           #capacitance

#Calculations
#f=(1/(2*%pi))*(1/(6^(1/2)*RC))
R=(1/(2*math.pi*(6**(0.5)*C*f)))

#Result
print("resistance of circuit\n")
print("R = %.1f k-ohm"%(R/1000))

resistance of circuit

R = 6.5 k-ohm


## Example11_6,pg 506¶

In [30]:
# find phase difference in wein network

import math
#Variable declaration
epsi=0.01                  #detuning parameter
eta1=1.0                   #(f/fo)=1
eta2=2.2                   #(f/fo)=2.2

#Calculations
#case-1
phi1=math.atan((3*eta1*((eta1**2)-1)*(3+(2*epsi)))/((((eta1**2)-1)**2)*(3+epsi)-(9*epsi*(eta1**2))))
#case-2
phi2=math.atan((3*eta2*((eta2**2)-1)*(3+(2*epsi)))/((((eta2**2)-1)**2)*(3+epsi)-(9*epsi*(eta2**2))))

#Result
print("phase difference for case-1:")
print("phase difference for case-2:")
#Answer for phi2 is not matching with book

phase difference for case-1:

phase difference for case-2:


## Example11_7,pg 507¶

In [31]:
# digital frequency synthesizer

import math
#Variable declaration
N=12.0                   #12-bit synthesizer
k1=1.0                   #sampling rate at sampler's rate
k2=4.0                   #sampling rate at 4 times sampler's rate

#Calculations
#case-1
#case-2

#Result
print("advancement of o/p register for case-1:")
print("advancement of o/p register for case-2:")

advancement of o/p register for case-1:

advancement of o/p register for case-2:


## Example11_8,pg 507¶

In [33]:
# find controlling voltage

import math
#Variable declaration
f=1.0*10**3                 #frequency
R6=10.0*10**3              #feed-back resistor
R5=22.0*10**3               #feed-in resistor
R4=10.0*10**3               #integrator resistor
C=0.1*10**-6                #integrator capacitor
Vsx=2.0                     #comparator pulse amplitude

#Calculations
Vi=((f*R4*R5*C)/(R6*4*Vsx)) #controlling voltage

#Result
print("controlling voltage:")
print("Vi = %.3f V"%Vi)

controlling voltage:
Vi = 0.275 V


## Example11_9,pg 507¶

In [19]:
# find limits of duty factor

import math
#Variable declaration
R1=10.0*10**3
R8=10.0*10**3
R4=10.0*10**3

#Calculations
lim1=(R1/((2*R1)+R8))         #limit-1 of duty factor
lim2=((R1+R4)/((2*R1)+R8))    #limit-2 of duty factor

#Result
print("duty factors are given by (t1/T) and (t2/T). the limits are giiven by\n")
print("lim1 = %.2f"%lim1)
print("lim2 = %.2f"%lim2)

duty factors are given by (t1/T) and (t2/T). the limits are giiven by

lim1 = 0.33
lim2 = 0.67


## Example11_10,pg 507¶

In [36]:
# find output voltage V1 and V2

import math
#Variable declaration
Vi=1.3                       #input voltage
R2=10.0*10**3
R3=10.0*10**3
R8=10.0*10**3                  #potentiometer
B=1.0/3                      #wiper distance

#Calculations
V1=((R3*Vi)/(R3+(B*R8)))     #output voltage-1
V2=-((R2*Vi)/(R3+((1-B)*R8)))#output voltage-2

#Result
print("ouput voltage-1:")
print("V1 = %.4f V"%V1)
print("ouput voltage-2:")
print("V2 = %.4f V"%V2)
#Answers are slightly different than book

ouput voltage-1:
V1 = 0.9750 V
ouput voltage-2:
V2 = -0.7800 V

In [ ]: