#Peak amplitude
#given data :
E_rms=230.0 #in V
Ep=2**(1.0/2)*E_rms
print "Peak amplitude, Ep = ", round(Ep,2), " V."
#Resistance
#given data :
import math
Rm=500.0 #in ohm
E_rms=50.0 # in V
E_dc=(2**(1.0/2)*E_rms)/(math.pi/2)
Im=1*10**-3 #in A
R=E_dc/Im
Rs=(R-Rm)*10**-3
print "The resistance, Rs = ", round(Rs,1), " kohm."
#Percentage error
ff1=1.0 #form factor
r=1.11 #sine wave form factor
per=((r-ff1)/ff1)*100 #percentage error
print "Percentage error is ", per, " %"
#part (i)
# form factor
T1=3.0 #
T=range(0,4)
##Function for integration
def integrate(a,b,f):
# def function before using this
# eg. : f=lambda t:200**2*t**2
#a=lower limit;b=upper limit;f is a function
import numpy
N=1000 # points for iteration
t=numpy.linspace(a,b,N)
ft=f(t)
ans=numpy.sum(ft)*(b-a)/N
return ans
# Calculating Vrms
a=T[0]
b=T[3]
f=lambda t:200**2*t**2
Vrms=(1/T1*integrate(a,b,f))**(1.0/2) # V
# Calculating Vav
g=lambda t:200*t
Vav=1/T1*integrate(a,b,g) # V
ff=Vrms/Vav # form factor
print "Form factor is ", round(ff,4)
# part (ii)
ff1=1.11 #form factor of sine wave
per=((ff1/ff)-1)*100 #percentage errpr
print "Percentage error in meter indication is", round(per,3), " %"
# Answer is not accurate in the textbook.
#Current
#Given data :
gm=0.005 #in mho
V1=1.5 #in V
rd=200.0*10**3 # in Ohm
Rd=15.0*10**3 #in ohm
Rm=75.0 #in ohm
I=(gm*V1*((Rd*rd)/(rd+Rd)))/((2*((Rd*rd)/(rd+Rd)))+Rm) # A
I*=10**3 # mA
print "Current, I = ", round(I,2), " mA"
#Current
#Given data :
gm=0.005 #in mho
V1=[0.2,0.4,0.6,0.8,1.0] #in V
rd=200.0*10**3 # in Ohm
Rd=15.0*10**3 #in ohm
Rm=75.0 #in ohm
Im=[]
for v1 in V1:
Im.append(gm*(rd*Rd*v1/(rd+Rd))/(2.0*(rd*Rd/(rd+Rd))+Rm)*1000) # mA
#Im*=1000 # mA
print "Voltage Current"
i=0
for im in Im:
print V1[i]," V ",round(Im[i],3)," A"
i+=1
# Design
v1=100.0 # in V
v2=30.0 #in V
v3=103.0 # in V
v4=1.0 #in V
x=9.0 #assume input resistance in Mohm
r4=(v4/v3)*x*10**3 #in kohm
r3=(((v4/v1)*x*10**6)-(r4*10**3))*10**-3 #in kohm
r2=(((v4/v2)*x*10**6)-((r4+r3)*10**3))*10**-3 # in kohm
r1=9*10**6-((r2+r3+r4)*10**3) # in ohm
r1*=10**-6 # Mohm
print "Resistance, R4 is ",round(r4,2)," kohm."
print "Resistance, R3 is ",round(r3,2)," kohm."
print "Resistance, R2 is ",r2," kohm."
print "Resistance, R1 is ",r1," Mohm."
#Current
#given data :
rd=150.0*10**3 # in ohm
Rm=50.0 # in ohm
Rs=1000.0*10**3 # in ohm
gm=0.0052 #in mho
rd1=rd/((gm*rd)+1)
V0=gm*((rd1*Rs)/(rd1+Rs))
R0=(2*Rs*rd1)/(Rs+rd1)
I=V0/(R0+Rm) # A
I*=10**3 # mA
print "Curent, I = ", round(I,3)," mA"
# Answer in the textbook is not accurate.
#Resistance
#given data :
V1=1.0 #in V
I=1.5*10**-3 #in A
rd=200.0*10**3 # in ohm
Rm=50.0 # in ohm
Rs=600.0*10**3 # in ohm
gm=0.005 #in mho
rd1=rd/((gm*rd)+1)
V0=gm*((rd1*Rs)/(rd1+Rs))*V1
R0=(2*Rs*rd1)/(Rs+rd1)
R_cal=(V0/I)-Rm-R0
print "Resistance , R_cal = ",round(R_cal,2)," ohm"
# answer is wrong in book
#Current and voltage
rm=10.0 #in ohm
im=5.0 # in mA
i=1.0 # in A
v=5.0 #in A
ish=i-(im*10**-3) # in A
m=i/(im*10**-3) # ratio
rsh=rm/(m-1) #in ohm
vo=v/i #in V
rsh1=vo/(im) #in kohm
print "Shunt resistance is ",round(rsh,2)," ohm to measure current upto 1 A"
print "Shunt resistance is ", rsh1," kohm to measure voltage upto 5 V"