In [1]:

```
from __future__ import division
#Given data
N = 100 # number o turns
B = 0.15 #air gap in Wb/m**2
I = 5 #current in mA
I = I * 10**-3 # in A
l= 10 #length in mm
b = 8 #width in mm
A = l*b #area in mm**2
A = A * 10**-6 # in m**2
Td = N*B*A*I #deflecting torque in Nm
K = 0.2*10**-6 # in Nm/degree
# Td = Tc= K*theta
theta = Td/K #deflecting in degrees
print "The deflecting = %0.f degrees " %theta
```

In [2]:

```
#Given data
B = 8*10**-3 #flux density in Wb/m**2
N = 300 # number of turns
l = 15 #length in mm
r = 30 #radius in mm
K = 2.5*10**-9 #spring constant in Nm/rad
J = 10*10**-9 # in kg-m**2
D = 2*10**-9 # in Nm/rads**-1
Rg = 80 # in ohm
A = l*r # in mm**2
A = A * 10**-6 # in m**2
G = N*B*A # in Nm/A
i = 1 # in µA
i = i * 10**-6 # in A
theta_f = (G*i)/K # in rad
r = 1 # in m
r = r * 10**3 # in mm
d = 2*theta_f*r #deflection of galvanometer in mm
print "The deflection of galvanometer = %0.f mm " %d
Si = d/i # in mm/A
Si = Si * 10**-6 #Current sensitivity in mm/µA
print "Current sensitivity = %0.f mm/µA " %Si
```

In [9]:

```
from math import exp, sqrt
from numpy import pi
#Given data
B = 10*10**-3 # in Wb/m**2
N = 200 # in turns
l = 16 # in mm
K = 12*10**-9 # in Nm/rad
J = 50*10**-9 # in kg-m**2
D = 5*10**-9 # in Nm/rads**-1
R = 120 # in ohm
A = l**2 # in mm**2
A = A * 10**-6 # in m**2
G = N*B*A # in Nm/A
i = 1 # in µA
i = i * 10**-6 # in A
theta_f = (G*i)/K # in rad
r = 1 # in m
r = r * 10**3 # in mm
# deflection of the galvanometer
d = 2*theta_f*r # in mm
print "The deflection of the galvanometer = %0.4f mm " %d
i = i * 10**6 # in µA
# Current sensitivity
Si = d/i # in mm/µA
print "The current sensitivity = %0.4f mm/µA " %Si
# Voltage sensitivity
Sv = d/(i*R) # in mm/µV
print "The voltage sensitivity = %0.3f mm/µV " %Sv
So = d/(i*10**-6*10**6) #megaohm sensitivity in Mohm/mm
print "The megaohm sensitivity = %0.3f Mohm/mm " %So
omega_d = (sqrt((4*J*K) - ((D)**2)))/(2*J) # in rad/sec
f_d = omega_d/(2*pi) #frequency of damped oscillation in Hz
print "The frequency of damped oscillation = %0.4f Hz " %f_d
omega_n = sqrt(K/J)
# period of free oscillation
To = (2*pi)/omega_n # in sec
print "The period of free oscillation = %0.3f sec " %To
Dc = 2*sqrt( J*K )
# The relative damping
Epsilon = D/Dc
print "The relative damping = %0.3f " %Epsilon
# The first maximum deflection
theta1 = theta_f * ( 1 + (exp(-pi*Epsilon)/(sqrt(1 - ((Epsilon)**2)))) ) # in rad
theta1 = theta1*2*r # in mm
print "The first maximum deflection = %0.3f mm " %theta1
# The logarithmic decrement
lembda = (pi*Epsilon)/(sqrt(1 - ((Epsilon)**2)))
print "The logarithmic decrement = %0.4f " %lembda
```

In [10]:

```
#Given data
Rm = 100 #internal resistance in ohm
Im = 2 # in mA
Im = Im * 10**-3 # in A
I = 150 # in mA
I = I * 10**-3 # in A
Rsh = (Im*Rm)/(I-Im) #shunt resistance in ohm
print "The value of shunt resistance = %0.3f ohm " %Rsh
# Note: The calculation in the book is wrong.
```

In [11]:

```
#Given data
Rsh = 0.01 #shunt resistance in ohm
Rm = 750 #resistance in ohm
Vm= 400*10**-3 #voltage in V
Ish = 50 #current in A
# Ish*Rsh = voltagedrop
Ish = Vm/Rsh #current through shunt in A
print "The current through shunt = %0.f A " %Ish
Ish=50 # in A
Vsh = Ish*Rsh # in V
Im = Vm/Rm # in A
# Im*R_m = Vsh
R_m = Vsh/Im #resistance of meter in ohm
print "The resistance of meter = %0.1f Ω " %R_m
```

In [12]:

```
#Given data
# The first range is 0-10 mA
I1 = 10 #in mA
Im = 2 # in mA
Rm = 75 # in ohm
R1 = (Im*Rm)/(I1-Im) # in ohm
print "The value of R1 = %0.2f ohm " %R1
# Second range is 0-50 mA
I2 = 50 # in mA
R2 = (Im*Rm)/(I2-Im) # in ohm
print "The value of R2 = %0.3f ohm " %R2
# The third range is 0-100 mA
I3 = 100 # in mA
R3 = (Im*Rm)/(I3-Im) # in ohm
print "The value of R3 = %0.2f ohm " %R3
```

In [41]:

```
import numpy as np
#Given data
I1 = 10 # in A
Im = 1*10**-3 # in A
Rm = 50 # in ohm
I2 = 5 # in A
I3 = 1 # in A
# I1*R1= Im*(R2+R3+Rm) or I1*R1 - Im*R2 - Im*R3 = Im*Rm (i)
# I2*(R1+R2) = Im*(R3+Rm) or I2*R1 + I2*R2 - Im*R3 = Im*Rm (ii)
# I3*(R1+R2+R3) = Im*Rm or I3*R1 + I3*R2 + I3*R3 = Im*Rm (iii)
# Solving eq (i),(ii) and (iii)
A= np.array([[I1,-Im,-Im],[I2,I2,-Im],[I3,I3,I3]])
B= np.array([Im*Rm,Im*Rm,Im*Rm])
R= np.linalg.solve(A,B)
R1= R[0] #value of R1 in ohm
R2= R[1] #value of R2 in ohm
R3= R[2] #value of R3 in ohm
print "The value of R1 = %0.3f ohm " %R1
print "The value of R2 = %0.3f ohm " %R2
print "The value of R3 = %0.3f ohm " %R3
```

In [14]:

```
#Given data
Rm = 500 #resistance of meter in ohm
Im = 40 #current in µA
Im = Im * 10**-6 # in A
V = 10 #voltage in V
# The required multiplier resistance
Rs = (V/Im)-Rm # in ohm
Rs = Rs * 10**-3 # in k ohm
print "The required multiplier resistance = %0.1f kΩ " %Rs
```

In [15]:

```
#Given data
Im = 20 #current in mA
Vm = 200 #voltage in mV
# Vm = Im*Rm
Rm = Vm/Im #resistance in ohm
I = 200 # in A
Im = Im * 10**-3 # in A
Rsh = (Im*Rm)/(I-Im) #required shunt resistance in ohm
print "The required shunt resistance = %0.3f Ω " %Rsh
V = 500 # in V
Rs = (V/Im)-Rm #required multiplier resistance in ohm
Rs = Rs * 10**-3 # in k ohm
print "The required multiplier resistance = %0.2f kΩ " %Rs
```

In [16]:

```
#Given data
Rm = 50 #resistance of meter in ohm
Im = 2 #current in mA
Im = Im * 10**-3 # in A
V4 = 10 #voltage in V
R4 = (V4/Im) - Rm # in ohm
R4= R4*10**-3 # in k ohm
print "The value of R4 = %0.2f kΩ " %R4
R4= R4*10**3 # in ohm
V3 = 50 # in V
# (R3+R4) = (V3/Im) - Rm
R3 = (V3/Im) - Rm-R4 # in ohm
R3= R3*10**-3 # in k ohm
print "The value of R3 = %0.f kΩ " %R3
R3= R3*10**3 # in ohm
V2 = 100 # in V
#(R2+R3+R4) = (V2/Im) - Rm
R2 = (V2/Im) - Rm - R3 - R4 # in ohm
R2= R2*10**-3 # in k ohm
print "The value of R2 = %0.f kΩ " %R2
R2= R2*10**3 # in ohm
V1 = 500 # in V
# (R1+R2+R3+R4) = (V1/Im) - Rm
R1 = (V1/Im) - Rm - R4 - R3 - R2 # in ohm
R1= R1*10**-3 # in k ohm
print "The value of R1 = %0.f kΩ " %R1
```

In [17]:

```
#Given data
Rm = 50 #meter resistance in ohm
Im = 2 #current in mA
Im = Im * 10**-3 # in A
S = 1/Im #sensitivity in ohm/V
# Voltage ranges
V1 = 500 # in V
V2 = 100 # in V
V3 = 50 # in V
V4 = 10 # in V
R4 = (S*V4) - Rm # in ohm
R4= R4*10**-3 # in k ohm
print "The value of R4 = %0.2f kΩ " %R4
R4= R4*10**3 # in ohm
R3 = (S*V3) - (Rm+R4) # in ohm
R3= R3*10**-3 # in k ohm
print "The value of R3 = %0.f kΩ " %R3
R3= R3*10**3 # in ohm
R2 = (S*V2) - (Rm+R4+R3) # in ohm
R2= R2*10**-3 # in k ohm
print "The value of R2 = %0.f kΩ " %R2
R2= R2*10**3 # in ohm
R1 = (S*V1) - (Rm+R2+R3+R4) # in ohm
R1= R1*10**-3 # in k ohm
print "The value of R1 = %0.f kΩ " %R1
```

In [19]:

```
#Given data
Im = 50 #current in µA
Im = Im * 10**-6 # in A
S = 1/Im # in ohm/V
V = 500 # in V
Rm = 200 #internal resistance in ohm
Rs = (S*V) - Rm #multiplier resistance in ohm
Rs = Rs * 10**-6 # in Mohm
print "The value of multiplier resistance = %0.f MΩ " %Rs
```

In [23]:

```
#Given data
Rs = 25 #resistance in k ohm
Rs = Rs * 10**3 # in ohm
Rm = 1 #meter resistance in k ohm
Rm = Rm * 10**3 # in k ohm
V = 100 #voltage in V
# Rs = (S*V) - Rm
S = (Rs+Rm)/V #sensitivity in ohm/V
print "For meter A: The value of S =",int(S)," Ω/V"
Rs = 150 # in k ohm
Rs = Rs * 10**3 # in ohm
V = 1000 # in V
# Rs = (S*V) - Rm
S = (Rs+Rm)/V # in ohm/V meter B
print "For meter B: The value of S =",int(S)," Ω/V"
print "The meter A is more sensitive than meter B"
```

In [25]:

```
#Given data
# Case (i): When voltmeter having a sensitivity of 500 Ω/V
R1 = 20 # in k ohm
R2 = 25 # in k ohm
Vdc = 250 # in V
V = (Vdc/(R1+R2))*R2 # in V
Vrange = 150 # in V
S = 500 # in ohm/V
R_V = S*Vrange # in ohm
R_V = R_V * 10**-3 # in k ohm
Req = (R2*R_V)/(R2+R_V) # in k ohm
V = (Req/(Req+R1))*Vdc # in V voltmeter first
print "Case (i): When voltmeter having a sensitivity of 500 Ω/V"
print " The voltmeter will reads : ",round(V,2)," V"
# Case (ii): When voltmeter having a sensitivity of 1000 Ω/V
S = 10000 # in ohm/V
R_V = S*Vrange # in ohm
R_V = R_V * 10**-3 # in k ohm
Req = (R2*R_V)/(R2+R_V) # in k ohm
V = (Req/(Req+R1))*Vdc # in V Voltmeter second
print "Case (ii): When voltmeter having a sensitivity of 1000 Ω/V"
print " The voltmeter will reads : ",round(V,2)," V"
print "Thus the second voltmeter reads more accurately."
```

In [33]:

```
#Given data
Ra = 5 # in k ohm
Rb = 1 # in k ohm
V = 25 # in V
Vrange = 5 # in V
S = 1 # in k ohm/V
# True voltage across Rb
Vb = (Rb/(Ra+Rb))*V # in V
print "The true voltage across Rb = %0.3f V " %Vb
R_V = S*Vrange # in k ohm
Req = (Rb*R_V)/(Rb+R_V) # in k ohm
V1 = (Req/(Req+Ra))*V #reading on the voltmeter 1 in V
print "The reading on the voltmeter 1 = %0.3f V " %V1
S = 20 # in k ohm/V
R_V = S*Vrange # in k ohm
Req = (Rb*R_V)/(Rb+R_V) # in k ohm
V2 = (Req/(Ra+Req))*V #reading on the voltmeter 2 in V
print "The reading on the voltmeter 2 = %0.3f V " %V2
PerError1 = ((Vb-V1)/Vb)*100 #percentage error in meter 1 in %
print "The percentage error in voltmeter 1 = %0.1f %% " %PerError1
PerError2 = ((Vb-V2)/Vb)*100 #percentage error in meter 2 in %
print "The percentage error in voltmenter 2= %0.2f %% " %PerError2
PerAccuracy1 = 100 - PerError1 #percentage accuracy of meter 1 in %
print "The percentage accuarcy of voltmeter 1 = %0.1f %% " %PerAccuracy1
PerAccuracy2 = 100-PerError2 #percentage accuracy of meter 2 in %
print "The percentage accuracy of voltmeter 2 = %0.2f %% " %PerAccuracy2
print "Thus voltmeter 2 is ",round(PerAccuracy2,2),"% accurate while voltmeter 1 is",round(PerAccuracy1,1),"% accurate"
```

In [34]:

```
#Given data
Erms = 10 #r.m.s. range of the voltmeter in V
Ep = sqrt(2)*Erms # in V
Eav = 0.6*Ep # in V
Eav = 9 # in V
Eavoutput = (1/2)*Eav # in V
Edc = 0.45*Erms # in V
Idc = 1 # in mA
Idc = Idc * 10**-3 # in A
Rm = 200 # in W
Rs = (Edc/Idc) - Rm #required multiplier resistance in ohm
Rs = Rs * 10**-3 # in k ohm
print "The required multiplier resistance = %0.1f kΩ " %Rs
```

In [35]:

```
#Given data
Idc = 2 #dc current in mA
Idc = Idc * 10**-3 # in A
Rm = 500 #meter resistance in ohm
Erms = 10 #r.m.s value in v
Eav = 9 #average value in V
Edc = 0.9*Erms #dc voltage in V
Rs = (Edc/Idc) - Rm #multiplier resistance in ohm
Rs = Rs * 10**-3 # in k ohm
print "The multiplier resistance = %0.f kΩ " %Rs
```

In [37]:

```
#Given data
Kf_true = 1 # true value of form factor
Kf_measured= 1.11 # measured value of form factor
PerError = ((Kf_true-Kf_measured)/Kf_true)*100 #percentage error in the meter reading in %
print "The percentage error in the meter reading = %0.f %% " %PerError
```

In [35]:

```
from __future__ import division
from scipy.integrate import quad
from math import sqrt
#Given data
V1 = 100 # in V
V2 = 0 # in V
e1= 0 # in V
e2= 100 # in V
T=2 # in sec
T1 = 0 # in sec
T2 = 2 # in sec
# Slope of ramp
A= (e2-e1)/(T2-T1) # in V/sec
e= 'A*t' # in sec
def integrand(t):
return ((50*t)**2)
ans, err = quad(integrand, 0, 2)
Erms= sqrt(1/T*ans) # in V
def integrand(t):
return (50*t)
ans, err = quad(integrand, 0, 2)
Eav= 1/T*ans # in V
Kf= Erms/Eav # form factor
Kf_sine= 1.11 # form factor of sine wave
True_reading= 1 # true reading
Meas_reading= Kf_sine/Kf # measured reading
PerError= (True_reading-Meas_reading)/True_reading*100 #percentage error in the reading in %
print "The percentage error in the reading = + %0.2f %% " %PerError
```

In [39]:

```
#Given data
Erms = 200 #r.m.s value in V
Rm = 100 #meter resistance in ohm
Idc = 25 #dc current in mA
Idc= Idc*10**-3 # in A
Rf = 500 # in ohm
R_D = 2*Rf # in ohm
Edc = 0.9*Erms # in V
Rs = (Edc/Idc) - Rm # in ohm
R_m = Rm+R_D # in ohm
Rs = (Edc/Idc) - R_m #required series resistance in ohm
print "The required series resistance = %0.f Ω " %Rs
```

In [40]:

```
#Given data
r = 2 #radius in m
r = r * 10**3 # in mm
d = 200 #deflection in mm
To = 3.1415 # in sec
J = 2*10**-6 # in kg-m**2
i = 1 # in µA
i = i * 10**-6 # in A
# d = 2*r*theta_f
theta_f = d/(2*r) # in rad
# To = 2*pi * (sqrt( J/K ))
K = 4*pi**2*J/To**2 # in Nm/A
# theta_f = (G*i)/K
G = (theta_f*K)/i # in Nm/A
# The required resistance to obtain critical damping
Rc = G**2/( 2*sqrt(J*K)) # in ohm
Rc = Rc * 10**-3 # in k ohm
print "The required resistance to obtain critical damping = %0.f kΩ " %Rc
```

In [42]:

```
from math import log
#Given data
theta1 = 128 #first maximum deflection in mm
theta3 = 90 #second maximum deflection in mm
theta_f = 70 # in mm
i = 6.2 # in µA
# The current sensitivity
Si = theta_f/i # in mm/µA
print "The current sensitivity = %0.4f mm/µA " %Si
# The logarithmic decrement
# Formula %e**(2*lambda)= (theta1-thetaf)/(theta3-thetaf)
lembda = log((theta1-theta_f)/(theta3-theta_f) )*(1/2)
print "The logarithmic decrement = %0.4f " %lembda
# lembda = (pi*sie)/(sqrt( 1-((sie)**2) ))
# ((lembda/pi)**2) = ((sie)**2)/(sqrt( 1-((sie)**2) ))
sie = lembda/sqrt(lembda**2+pi**2) # the relative damping
print "The relative damping = %0.3f " %sie
```

In [45]:

```
#Given data
I = 100 # in mA
Im = 1 # in mA
Rm = 25 # in ohm
# m = I/Im = 1 + Rm/Rsh
Rsh = Rm/((I/Im) - 1) # in ohm
del_t = 10 # in °C
Alpha_c = 0.004
Alpha_m = 0.00015
# When temperature increase by 10 °C
R_m = Rm * ( 1 + (Alpha_c*del_t) ) # in ohm
R_sh = Rsh * (1 + (Alpha_m*del_t)) # in ohm
# When I= 100 mA then
I_m = (R_sh/(R_sh+R_m))*I # in mA
# But Im required for full scale deflection
PerEerror= ((I_m-Im)/Im)*100 # in %
print "Part (i) "
print "The percentage error = %0.3f %% " %PerEerror
Rx = 75 # in ohm
Rtotal = Rm+Rx # in ohm
Rsh = Rtotal/((I/Im) - 1) # in ohm
#R_total =R_m+R_x
R_total = R_m + (Rx*(1+(Alpha_m*del_t))) # in ohm
R_sh = Rsh * (1+( Alpha_m*del_t )) # in ohm
I_m = (R_sh/(R_sh+R_total))*I # in mA
PerEerror = ((I_m-Im)/Im)*100 #percentage error in %
print "Part (ii) "
print "The percentage error = %0.2f %% " %PerEerror
```

In [46]:

```
#Given data
Im =25 #current in mA
Im = Im * 10**-3 # in A
Rm = 10 #resistance in ohm
I = 20 # in A
Rsh = (Im*Rm)/(I-Im) #shunt resistance in ohm
print "The value of Rsh = %0.5f Ω " %Rsh
V = 120 # in V
Rs = (V/Im)-Rm # in ohm
print "The value of Rs = %0.f Ω " %Rs
```

In [48]:

```
#Given data
Vm = 10 # in mV
Vm = Vm * 10**-3 # in V
Rm = 1 # in k ohm
Rm = Rm * 10**3 # in ohm
Im = Vm/Rm # in A
# Part (i) : For the range of 100 mV
Vrange = 100 # in mV
Vrange = Vrange * 10**-3 # in V
Rs = (Vrange/Im) - Rm # in ohm
Rs= Rs*10**-3 # in kohm
print "Part (i) For the range of 100 mV"
# Part (ii) : For the range of 1 V
print "The value of Rs = %0.f kΩ " %Rs
Vrange = 1 # in V
Rs = (Vrange/Im) - Rm # in ohm
Rs= Rs*10**-3 # in kohm
print "Part (i) For the range of 1V"
print "The value of Rs = %0.f kΩ " %Rs
```

In [43]:

```
#Given data
Vm = 0.1 #full scale deflection voltage in V
Rm = 20 #meter resistance in ohm
Im = Vm/Rm #current in A
I1= 10 # in A
I2= 1 # in A
I3= 100*10**-3 # in A
# I1*R1 = Im*(R2+R3+Rm) or I1*R1 - Im*R2 - Im*R3 = Im*Rm (i)
# I2*(R1+R2) = Im*(R3+Rm) or I2*R1 + I2*R2 -Im*R3 = Im*Rm (ii)
# I3*(R1+R2+R3) = Im*Rm or I3*R1 + I3*R2 + I3*R3 = Im*Rm (iii)
#A= [I1 I2 I3 -Im I2 I3 -Im -Im I3]
#B= [Im*Rm Im*Rm Im*Rm]
#R= B*A**-1 # Solving equation (i), (ii) and (iii) by matrix method
A= np.array([[I1,-Im,-Im],[I2,I2,-Im],[I3,I3,I3]])
B= np.array([Im*Rm,Im*Rm,Im*Rm])
R= np.linalg.solve(A,B)
R1= R[0] #value of R1 in ohm
R2= R[1] #value of R2 in ohm
R3= R[2] #value of R3 in ohm
print "The value of R3 = %0.4f ohm " %R3
print "The value of R1 = %0.4f ohm " %R1
print "The value of R2 = %0.4f ohm " %R2
```

In [53]:

```
#Given data
Im = 10 #current in mA
Im = Im * 10**-3 # in A
Rm = 50 #meter resistance in ohm
I = 5 # in A
# Value of resistance to be connected in parallel
Rsh = (Im*Rm)/(I-Im) # in ohm
print "The value of resistance to be connected in parallel = %0.4f Ω " %Rsh
V = 250 # in V
# The value of resistance to be connected in series
Rs = (V/Im) - Rm # in ohm
print "The value of resistance to be connected in series = %0.f Ω " %Rs
```

In [54]:

```
#Given data
Im = 1 # in mA
Im = Im * 10**-3 # in A
Rm = 100 # in ohm
I = 100 # in mA
I = I * 10**-3 # in A
# For 100 mA range, the value of Rsh to be connected in parallel
Rsh = (Im*Rm)/(I-Im) # in ohm
print "For 100 mA range, the value of Rsh to be connected in parallel = %0.2f Ω " %Rsh
I = 1 # in A
# For 1 A range, the value of Rsh to be connected in parallel
Rsh = (Im*Rm)/(I-Im) # in ohm
print "For 1A range, the value of Rsh to be connected in parallel = %0.1f Ω " %Rsh
V = 1 # in V
# For 1V range, the value of Rs to be connected in series
Rs = (V/Im)-Rm # in ohm
print "For 1V range, the value of Rs to be connected in series = %0.f Ω " %Rs
V = 100 # in V
# For 100 V range, the value of Rs to be connected in series
Rs = (V/Im)-Rm # in ohm
Rs= Rs*10**-3 # in k ohm
print "For 100V range, the value of Rs to be connected in series = %0.1f kΩ " %Rs
```

In [55]:

```
#Given data
Rm = 100 #meter resistance in ohm
Im = 2 #current in mA
Im = Im * 10**-3 # in A
I = 150 # in mA
I = I * 10**-3 # in A
m = I/Im
Rsh = Rm/(m-1) #required shunt resistance in ohm
print "The value of required shunt resistance = %0.4f Ω " %Rsh
Pm = ((Im)**2)*Rm # in W
Psh = ((I-Im)**2)*Rsh # in W
P = Pm+Psh #power consumption in W
P = P * 10**3 # in mW
print "The power consumption = %0.f mW " %P
```

In [56]:

```
#Given data
std_cell_emf = 1.45 #e.m.f. of standard cell in V
l = 50 #length in cm
Vdrop = std_cell_emf /l #voltage drop per unit length in V/cm
Vstdresistor = Vdrop*75 #voltage across standard resistor in V
Stdresistor = 0.1 #standard resistor in ohm
I = Vstdresistor/Stdresistor #magnitude of current in A
print "The magnitude of current = %0.2f A " %I
```