# find pulse width
import math
#Variable declaration
delt=1*10**-3 #pulse width
#w=2wo
#delt at w=2wo
#Calculations
delT=(delt/2.0) #changed in pulse width
#Result
print("pulse width:")
print("delT = %.1f ms"%(delT*10**3))
# detector senstivity
import math
#Variable declaration
#senstivity of phase detection
#Sphi=(Vo/sin(B))=(Vo/B)=(+/-)0.5Vmax, B is phase displacement
Vmax=1.0 #amplitude of cosine waves
#Calculations
Sphi=(1.0/2)*Vmax
#Result
print("senstivity of phase detection:")
print("Sphi = %.1f V/rad"%Sphi)
# phase measured
import math
#Variable declaration
Vp=1.3 #pulse height
delt=0.31*10**-3 #pulse width
T=1*10**-3 #pulse repetion rate
#Calculations
Vphi=Vp*(delt/T) #phase deviation
phi=2*math.pi*(Vphi/Vp) #phase
#Result
print("phase measured:")
print("phi = %.4f rad"%phi)
#Answer is wrong in the book
# measured phase difference
import math
#Variable declaration
delt=0.13*10**-3 #time delay
T=1.3*10**-3 #time period
#Calculations
n=(1.0/3.0)*(1+(delt/T)) #order of phase meter
delphi=(n-(1.0/3))*1080 #measured phase difference
#Result
print("measured phase difference:")
print("delphi = %.f°"%delphi)
#Answer slightly different than the book
# find phase difference
import math
#Variable declaration
n=8.0 #8-bit counter
N2=64.0 #output digital count
#Calculations
theta=math.pi*(N2/(2**n-1))
#Result
print("measured phase difference:")
print("theta = %.3f radian"%theta)
# states for stages required
import math
#Variable declaration
#since the no. is more than 9, the two-stage counting is required. the states of the stages are
print("D C B A decimal equivalent")
a1="0 0 0 1 1"
a5="0 1 0 1 5"
#Result
print a1
print a5
# find time base division
import math
#Variable declaration
fd=10.0*10**6 #frequency meter input
fc=10.0*10**3 #counter clock
fi=100.0*10**6 #actual input frequency
#Calculations
k=fc*(fd/fi) #division time base
#Result
print("division time base:")
print("k = %.f"%k)
# frequency of sinusoid
import math
#Variable declaration
V2=0.130 #output-1
V1=0.103 #output-2
Vx=0.4 #peak amplitude
delt=0.1*10**-3 #time delay
#Calculations
f1=(1.0/(2*math.pi*delt))*(math.asin(V2/Vx)-math.asin(V1/Vx))
#Result
print("frequency of sinusoid:")
print("f1 = %.0f Hz"%(math.ceil(f1)))
# count of counter(refer fig. 7.30(a),(b),(c))
import math
#Variable declaration
#N=(2*fc/fs^2)*fi
fs=10*10**2 #sampler frequency
fc=10*10**3 #counter clock
#Calculations
M=(fs**2)/(2*fc) #multiplication factor
fi=113.0 #input frequency
N=(1.0/M)*fi #count of counter
print("count of counter:")
print("N = %.2f "%N)
# find time between events
import math
#Variable declaration
n=10.0*10**2 #scale factor=(1/n)
fc=10.0*10**5 #clock frequency
N=10.0 #count
#Calculations
Tp=(n/fc)*N #time between events
#Result
print("time between events:")
print("Tp = %.f ms"%(Tp*1000))