from __future__ import division
from math import sqrt
#Given data
BW = 25 #bandwidth in MHz
Trd = 20 #rise time in ns
Trd = Trd * 10**-9 # in s
# BW = 0.35/Tro
Tro = 0.35/(BW*10**6) # in s
# Trd = sqrt( (Trs**2) + (Tro**2) )
Trs = sqrt( (Trd**2)-(Tro**2) ) # rise time of signal in sec
Trs = Trs * 10**9 # in ns
print "The rise time of signal = %0.2f ns " %Trs
#Given data
Trs = 17 #rise time in µs
Trs = Trs * 10**-6 # in s
Trd = 21 # in µs
Trd = Trd * 10**-6 # in s
# Trd = sqrt( (Trs**2) + (Tro**2) )
Tro = sqrt( (Trd**2)- (Trs**2) ) # in sec
BW = 0.35/Tro #band width in Hz
BW = BW * 10**-3 # in kHz
print "The band width = %0.3f kHz " %BW
#Given data
subdivision = 1/5 #sub division in units
positivepeak = 2.6 #positive peak in units
Vpp = positivepeak + positivepeak #peak to peak in divisions
verticalattenuation = 2 #vertical attenuation in mV/div
verticalattenuation = verticalattenuation * 10**-3 # in V/div
Vpp = Vpp * verticalattenuation # in V
Vpp = Vpp * 10**3 # in mV
Vm = Vpp/2 #amplitude of the sinusoidal voltage in mV
print "The amplitude of the sinusoidal voltage = %0.1f mV " %Vm
V_RMS = Vm/sqrt(2) #r.m.s. value of the sinusoidal voltage in mV
print "The r.m.s. value of the sinusoidal voltage = %0.4f mV " %V_RMS
#Given data
voltsBYdiv = 2 #volts per division in V/div
Timebase = 2 #base time in ms/div
Verticaloccupancy = 3 #Vertical occupancy in cm
Vpp = voltsBYdiv*Verticaloccupancy #peak to peak voltage in V
Vm = Vpp/2 # in V
V_RMS = Vm/sqrt(2) #r.m.s. value of the voltage in V
print "The r.m.s. value of the voltage = %0.4f V " %V_RMS
Horizontaloccupancy = 2 #Horizontal occupancy in cm
timeBYdiv = 2 #time per division in mV
timeBYdiv = timeBYdiv*10**-3 # in V
T = timeBYdiv*Horizontaloccupancy # in sec
f = 1/T # in Hz
print "The frequency = %0.f Hz " %f
from math import asin
from numpy import pi
#Given data
y1 = 8 # in units
y2 = 10 # in units
phi = asin(y1/y2)*180/pi # phase difference in degree
print "The phase difference = %0.2f degree " %phi
#Given data
verticaltangencies = 2 # vertical tangencies
horizontaltangencies = 5 # horizontal tangencies
f_H = 1 # frequency in kHz
# f_V/f_H = horizontaltangencies/verticaltangencies
f_V = (horizontaltangencies/verticaltangencies)*f_H #unknown frequency of vertical signal in kHz
print "The unknown frequency of vertical signal = %0.1f kHz " %f_V
#Given data
Cin = 35 # in pF
# (R1+Rin)/Rin = 10
RinBYR1= 1/9
#while balance equation with compensating capacitor
# R1*C1 = Rin*(C2+Cin)
C1= Cin*RinBYR1 #compansating capacitor in pF
print "The compansating capacitor = %0.2f pF " %C1
#Given data
n = 10 # number of cycle
fs = 1 #signal frequency in kHz
fs = fs * 10**3 # in Hz
Timeperiod = n/fs #time period in sec
Samplingfrequency = 1/Timeperiod #Sampling frequency in samples/sec
print "The sampling rate for 1 kHz = %0.f samples/sec " %Samplingfrequency
fs = 10 # in kHz
fs = fs * 10**3 # in Hz
Samplingperiod = n/fs #Sampling period in sec
Samplingfrequency = 1/Samplingperiod #sampling rate for 10 kHz in samples/sec
print "The sampling rate for 10 kHz = %0.f samples/sec " %Samplingfrequency
#Given data
Samplingrate = 200 #Sampling rate in MS/s
Samplingrate = Samplingrate * 10**6 # in S/s
t_r = 1/Samplingrate #minimum rise time of pulse in s
t_r = t_r * 10**9 # in ns
print "The minimum rise time of pulse = %0.f ns " %t_r
#Given data
Vd = 4 # vertical division
Va = 0.5 #Vertical attenuation in V/Div
App = Vd*Va #peak to peak amplitude in V
print "The peak to peak amplitude of the signal = %0.f V " %App
TimebyDiv = 2 #time per division in µs/Div
Hd = 4 # horizontal division
Time = Hd*TimebyDiv # in µs
f = 1/(Time*10**-6) # frequency of signal in Hz
f = f * 10**-3 # in kHz
print "The frequency of signal = %0.f kHz " %f
#Given data
Rin = 2 #resistance in Mohm
Cin = 50 #capacitance in pF
Cin = Cin * 10**-12 # in F
# (R1+Rin)/Rin = 10
R1 = 9*Rin #resistance in Mohm
print "The value of R1 = %0.f MΩ " %R1
R1 = R1*10**6 # in ohm
Rin = Rin * 10**6 # in ohm
# While balance equation with compensating capacitor
# R1*C1 = Rin*(C2+Cin)
C1 = (Rin*Cin)/R1 # in F(neglecting C2)
C1 = C1 * 10**12 # in pF
print "The value of C1 = %0.2f pF " %C1