#Variable declaration
R=10*10**6; #in Ohm
C=10*10**-9; #in Farad
#Calculations&Results
T=R*C; #discharge Time
print "T = %.1fS"%T;
Vled=2.5; #in V
Vsat=13; #in V
Rl=500; #in Ohm
Iled=(Vsat-Vled)/Rl*10**3;
print "Iled = %.f mA"%Iled;
import math
import matplotlib.pyplot as plt
import numpy
%matplotlib inline
#Variable declaration
R2=1.5*10**3; #in Ohm
R1=10*10**3; #in Ohm
Vcc=15; #in V
Vpm=1; #in V
C=10*10**-9; #in Farad
#Calculations&Results
Vofst=Vcc*R2/(R1+R2);
print "Voffset = %0.2f V"%Vofst;
Vc=Vofst+Vpm;
print "Vc = %0.2f V"%Vc;
Rl=10*10**6; #in Ohm
T=Rl*C; #discharge Time
print "T = %0.2f S"%T;
Vinp=1.96;
Vinm=5.96;
Vind=Vinp-Vinm;
print "Vin_diff =% 0.0f V"%Vind;
#Graph
t=numpy.linspace(0,5);
f=1; #1kHz
Vin=2*numpy.sin(f*numpy.pi*t);
Vin1=Vin**2-1;
Vout=Vin1+2.96;
plt.plot(t,Vout,'b')
plt.plot(t,Vin1,'g')
plt.title("Green Input signal & Blue Output signal")
plt.xlabel("t")
plt.ylabel("Vin");
plt.grid();
plt.show()
import numpy
#Variable declaration
Rf=20*10**3; #in Ohm
Ri=10*10**3; #in Ohm
Av=-Rf/Ri;
Vin=4; #in V
#Calculations&Results
Vout=Av*Vin;
print "Vout = %0.0f V(peak)"%Vout;
Vzener=5.1; #in V
Vlimit=(Vzener+0.7);
print "Vlimit +_%.1f V"%Vlimit;
import matplotlib.pyplot as plt
import numpy
%matplotlib inline
#Variable declaration
Vz=3.9; #in V
Rf=20000.; #in Ohm
Ri=5000; #in Ohm
Ra=10000; #in Ohm
#Calculations&Results
Vbreak=Vz+0.7;
print "Vbreak = +_ %.2f V"%Vbreak;
Av=-Rf/Ri;
print "Av = %.2f "%Av;
Av2=(-Rf*Ra/(Rf+Ra))/Ri;
print "Av2 = %.2f "%Av2;
#Graph
t=list(range(-4,5));
L=len(t);
def f():
x1=[]
for i in range(0,L):
if t[i]<-1.15:
x2=Av2*t[i]+3.0705;
x1.append(x2)
elif t[i]<1.15:
x2=Av*t[i] ;
x1.append(x2)
elif t[i]>1.15:
x2=Av2*t[i]-3.0705 ;
x1.append(x2)
return x1
z = f()
plt.plot(t,z);
plt.title('Transfer Characteristics')
plt.xlabel('Vin')
plt.ylabel('Vout')
plt.grid();
plt.show()
import matplotlib.pyplot as plt
%matplotlib inline
#Variable declaration
Vz1=1; #in V
Vz2=2.2; #in V
Rf=12000; #in Ohm
Ri=10000; #in Ohm
R2=15000; #in Ohm
R1=20000; #in Ohm
#Calculations&Results
Vbreak1=Vz1+0.7;
print "Vbreak1_in = +_ %.2f V"%Vbreak1;
Vbreak2=Vz2+0.7;
print "Vbreak2_in = +_ %.2f V"%Vbreak2;
Av=-Rf/Ri;
print "Av %.1f "%Av;
Av1=-Rf*(Ri+R1)/(R1*Ri);
print "Av1 %.1f "%Av1;
Av2=-Rf*(Ri*R1+R1*R2+R2*Ri)/(R1*Ri*R2);
print "Av2 = %.1f "%Av2;
Vbreak1_out=Av*Vbreak1
Vbreak2_out=Vbreak1_out+Av2*(Vbreak2-Vbreak1);
print "Vbreak1_out = %.2f V "%Vbreak1_out;
print "Vbreak2_out = %.2f V"%Vbreak2_out;
#graph
t=list(range(-5,6));
L=len(t);
def f():
x1=[]
for i in range(0,L):
if t[i]<-2.9:
x2=Av2*t[i]-3;
x1.append(x2)
elif t[i]<-1.15:
x2=Av1*t[i]-0.67;
x1.append(x2)
elif t[i]<1.15:
x2=Av*t[i] ;
x1.append(x2)
elif t[i]<2.9:
x2=Av1*t[i]+0.67 ;
x1.append(x2)
elif t[i]>2.9:
x2=Av2*t[i]+3;
x1.append(x2)
return x1
z = f()
plt.plot(t,z);
plt.title('Transfer Characteristics')
plt.xlabel('Vin')
plt.ylabel('Vout')
plt.show()
import matplotlib.pyplot as plt
%matplotlib inline
#Variable declaration
Vz1=1; #in V
Vz2=2.2; #in V
Rf=10000; #in Ohm
Ri=10000; #in Ohm
#Calculations&Results
Vzp=3-0.7;
print "Vz+in = %.2f V"%Vzp;
Vzm=-(4-0.7);
print "Vz_in = %.2f V"%Vzm;
#Ra||Rf=8k
Ra=8000*Rf/(Rf-8000);
Av2=0.8;
Av1=1;
#graph
t=list(range(-50,50));
L=len(t);
def f():
x1=[]
for i in range(0,L):
if t[i]<-40:
x2=0.8*t[i]-8;
x1.append(x2)
elif t[i]<30+0.01:
x2=1*t[i];
x1.append(x2)
elif t[i]>30:
x2=0.8*t[i]+5.5;
x1.append(x2)
return x1
z = f()
plt.plot(t,z);
plt.title('Transfer Characteristics')
plt.xlabel('Vin')
plt.ylabel('Vout')
plt.show()
import matplotlib.pyplot as plt
import math
import numpy
from scipy import signal
%matplotlib inline
#Variable declaration
Vi=5; #in V
Vsat=13; #in V
R2=2000; #in Ohm
R1=20000; #in Ohm
#Calculations
Vupper=Vsat*R2/R1;
Vlower=-Vsat*R2/R1;
print "Vupperthreshold = %.1f V"%Vupper;
print "Vlowerthreshold = %.1f V"%Vlower;
#t=list(range(0,20));
t = numpy.linspace(0,20)
f=0.1;
x3=1*numpy.sin(2*f*numpy.pi*t);
A=math.asin(Vupper);
k=math.atan(A)
x4=(2*f*math.pi*t-2*f*math.pi*k)
plt.figure(1)
plt.subplot(211)
plt.plot(t,x3)
plt.xlabel('time n--->');
plt.ylabel('Vout--->');
plt.grid()
plt.subplot(212)
plt.plot(t,signal.square(x4),'g');
plt.xlabel('time n--->');
plt.ylabel('Vout--->');
plt.title('Input(Blue) / Output(Green)');
plt.grid();
plt.show()
import math
#Variable declaration
Vin=1; #in V
T=300; #in Kelvin
Ri=50000; #in Ohm
Is=30*10**-9; #in Amp
#Calculations&Results
#Vout=-0.0259*math.ln(Vin/RiIs)
Vout=-0.0259*math.log1p(Vin/(Ri*Is))
print "Vout when Vin=1V is %.4f V"%Vout;
#for Vin=0.5V
Vin1=0.5; #in V
Vout1=-0.0259*math.log1p(Vin1/(Ri*Is))
print "Vout when Vin=0.5V is %.4f V"%Vout1;
#for Vin=2V
Vin2=2; #in V
Vout2=-0.0259*math.log1p(Vin2/(Ri*Is))
print "Vout when Vin=2V is %.4f V"%Vout2;
import numpy
import matplotlib.pyplot as plt
%matplotlib inline
#Variable declaration
K=0.1;
t=numpy.linspace(0,0.5);
#Calculations
Vin=2*numpy.sin(2*60*numpy.pi*t);
Vout=K*Vin**2;
#Results
plt.plot(t,Vout)
plt.plot(t,Vin)
plt.title(" Input(Green) signal & Output (Blue)signal")
plt.xlabel("t")
plt.ylabel("V");
plt.show()
#output appears different due to use of python poltting libraries