lecture 6 matlab applications in electronics

44
Lecture 6 MATLAB Applications In Electronics Dr. Bedir Yousif

Upload: others

Post on 21-Jan-2022

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lecture 6 MATLAB Applications In Electronics

Lecture 6MATLAB Applications

In Electronics

Dr. Bedir Yousif

Page 2: Lecture 6 MATLAB Applications In Electronics

Chapter 5DIODES

• In this chapter • The characteristics of diodes are presented. Diode

circuit analysis techniques will be discussed. • Problems involving diode circuits are solved using

MATLAB.

Page 3: Lecture 6 MATLAB Applications In Electronics

DIODES1- DIODE CHARACTERISTICS

Vf

If

Vr

Ir

Ideal CHARACTERISTICS

Switch off

Switch on

Page 4: Lecture 6 MATLAB Applications In Electronics

DIODESPractical CHARACTERISTICS

whereIS : is reverse saturation current or leakage current,n : is an empirical constant between 1 and 2,VT : is thermal voltage, given by

k : is Boltzmann’s constant = 1.38x10−23 J / oK,q : is the electronic charge = 1.6x10−19 Coulombs,T : is the absolute temperature in oK At room temperature (25 oC), the thermal voltage is about 25.7 mV.

Page 5: Lecture 6 MATLAB Applications In Electronics

DIODES

• Forward-biased region• In the forward-biased region, the voltage

across the diode is positive.• If we assume that the voltage across the diode

is greater than 0.1 V at room temperature

• For a particular operating point of the diode ( i= ID and v= VD ), we have

Page 6: Lecture 6 MATLAB Applications In Electronics

DIODESTo obtain the dynamic resistance of the diode at a specified operating point

the dynamic resistance of the diode, rd , is

From forwardbias equation, we get

Thus

Page 7: Lecture 6 MATLAB Applications In Electronics

DIODES

This Eqn. used to obtain the diode constants n and IS

The following example illustrates how to find n and Is from an experimental data. Since the example requires curve fitting, the MATLAB function polyfit will be covered before doing the example.

MATLAB function polyfitThe polyfit function is used to compute the best fit of a set of data points to a polynomial with a specified degree. The general form of the function is

coeff_xy = polyfit(x, y, n)x and y : are the data points.n: is the nth degree polynomial that will fit the vectors x and y.coeff _ xy : is a polynomial that fits the data in vector y to x in the east square

Page 8: Lecture 6 MATLAB Applications In Electronics

DIODEScoeff _ xy returns n+1 coefficients in descending powers of x.

coeff _ xy(x)=c1xn + c1xn-1 + … + cm

The degree of the polynomial is n and the number of coefficients m=n+1 and the coefficients (c1 , c2, ..., cm ) are returned by the MATLAB polyfit function.

Example 1

A forward-biased diode has the following corresponding voltage and current. Use MATLAB to determine the reverse saturation current, Is and diode parameter n.

Page 9: Lecture 6 MATLAB Applications In Electronics

DIODES

Page 10: Lecture 6 MATLAB Applications In Electronics

DIODESMATLAB script file

% Diode parametersvt = 25.67e-3;v = [0.1 0.2 0.3 0.4 0.5 0.6 0.7];i = [0.133e-12 1.79e-12 24.02e-12 321.66e-12 4.31e-9 …57.69e-9 772.58e-9];lni = log(i); % Natural log of current% Coefficients of Best fit linear model is obtainedp_fit = polyfit(v,lni,1);

Page 11: Lecture 6 MATLAB Applications In Electronics

DIODES% linear equation is y = m*x + bb = p_fit(2);m = p_fit(1);ifit = m*v + b;% Calculate Is and nIs = exp(b)n = 1/(m*vt)% Plot v versus ln(i), and best fit linear modelplot(v, ifit, 'w', v, lni ,'ow')axis([0,0.8,-35,-10])xlabel('Voltage (V)')ylabel('ln(i)')title('Best fit linear model')

Page 12: Lecture 6 MATLAB Applications In Electronics

DIODESThe results obtained from MATLAB areIs = 9.9525e-015 and n = 1.5009Figure 1 shows the best fit linear model used to determine the reverse saturation current, IS , and diode parameter, n.

Page 13: Lecture 6 MATLAB Applications In Electronics

Temperature effectsFrom the diode equation ,the thermal voltage VT and the reverse saturation current Is are temperature dependent.The thermal voltage is directly proportional to temperature.

The reverse saturation current Is increases approximately 7.2% /oC for both silicon and germanium diodes. The expression for the reverse saturation current as a function of temperature is

Page 14: Lecture 6 MATLAB Applications In Electronics

Temperature effectsks = 0.072 / oC.T1 and T2 are two different temperatures. Since e0.72 is approximately equal to 2, Equation (5.8) can be simplified and rewritten as

Example 2The saturation current of a diode at 25 oC is 10-12 A. Assuming that the emission constant of the diode is 1.9, (a) Plot the i-v characteristic of the diode at the following temperatures: T1 = 0 oC, T2 = 100 oC.Solution

Page 15: Lecture 6 MATLAB Applications In Electronics

Temperature effects%MATLAB Script% Temperature effects on diode characteristicsk = 1.38e-23; q = 1.6e-19;t1 = 273 + 0;% zero Celsiust2 = 273 + 100; % 100 CelsiusIs1 = 1.0e-12;ks = 0.072;Is2 = Is1*exp(ks*(t2-t1));v = 0.45:0.01:0.7; % Forward bias voltageI1 = Is1*exp(q*v/(k*t1));I2 = Is2*exp(q*v/(k*t2));

Page 16: Lecture 6 MATLAB Applications In Electronics

Temperature effects%MATLAB Scriptplot(v,I1,'-ro',v,I2,'-b+')axis([0.45,0.75,0,10])title('Diode I-V Curve at two Temperatures')xlabel('Voltage (V)')ylabel('Current (A)')text(0.5,8,'o is for 100 degrees C')text(0.5,7, '+ is for 0 degree C')

Page 17: Lecture 6 MATLAB Applications In Electronics

Temperature effectsOutput of the program

Page 18: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS

We want to determine the diode current ID and the diode voltage VD

Using Kirchoff Voltage Law, we can write the loadline equationThe diode current and voltage will be related by the diode equation

Page 19: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS

These Eqns. can be used to solve for the current ID and voltage VD. There are several approaches for solving ID and VD. In one approach, 1-plotting ID and loadline Eqns. and the intersection will be the operating point of the diode. This is illustrated by the following example.Example 3For the circuit shown in Figure , if R = 10 kΩ , VDC = 10V, and the reverse saturation current of the diode is 10 -12 A and n = 2.0. (Assume a temperature of 25 oC.)(a) Use MATLAB to plot the diode forward characteristic curve and the loadline.(b) From the plot estimate the operating point of the diode.

Page 20: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS% Solution MATLAB Script% Determination of operating point using% graphical technique diode equationk = 1.38e-23;q = 1.6e-19;t1 = 273 + 25; vt = k*t1/q;v1 = 0.25:0.05:1.1;i1 = 1.0e-12*exp(v1/(2.0*vt));% load line 10=(1.0e4)i2 + v2vdc = 10;r = 1.0e4;v2 = 0:2:10;i2 = (vdc - v2)/r;

Page 21: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS% plotplot(v1,i1,‘r', v2,i2,‘b')axis([0,2, 0, 0.0015])title('Graphical method - operating point')xlabel('Voltage (V)')ylabel('Current (A)')text(0.4,1.05e-3,'Loadline')text(1.08,0.3e-3,'Diode curve')% operating point Determinationf1=find (abs(i1-i2)<=1e-5);disp('operating point is')q=[v1(f1) i2(f1)]

Page 22: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS

Loadline and Diode Forward Characteristicsoperating point isq =1.0595 8.9405e-004

Page 23: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITSThe second approach for obtaining the diode current ID and diode voltage VDof Figure 5.5 is to use iteration. Assume that (ID1, VD1.) and (ID2,VD2.) are two corresponding points on the diode forward characteristics.Then, from Equation (5.3), we have

Dividing these Equations we have

Take the ln of both sides, we get on

To show how the iterative technique is used, we assume that ID1 = 1mA and VD1 = 0.7 V. Using Equation of loadline, ID2 is calculated by

Page 24: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITS

VD2 is calculated by

VD3 is calculated by

Using Equation of loadline, ID3 is calculated by

Similarly, ID4 and VD4 are calculated by

Page 25: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITSThe iteration is stopped when VDn is approximately equal to VDn-1 or IDn isapproximately equal to IDn-1 to the desired decimal points. The iterationtechnique is particularly facilitated by using computers. Example 5.4 illustratesthe use of MATLAB for doing the iteration technique.Example 4Redo Example 3 using the iterative technique. The iteration can be stopped when the current and previous value of the diode voltage are different by 10-7 volts.SolutionMATLAB Script% Determination of diode operating point using iterative methodk = 1.38e-23;q = 1.6e-19;t1 = 273 + 25; vt = k*t1/q;vdc = 10;r = 1.0e4;n = 2; vd(1) = 0.1;id(1) = 1.0e-12*exp(vd(1)/(2.0*vt)); reltol = 1.0e-7;i = 1;

Page 26: Lecture 6 MATLAB Applications In Electronics

2- ANALYSIS OF DIODE CIRCUITSvdiff = 1;while vdiff > reltolid(i+1) = (vdc - vd(i))/r;vd(i+1) = vd(1) + n*vt*log(id(i+1)/id(1));vdiff = abs(vd(i+1) - vd(i));i = i+1;endk = 0:i-1;% operating point of diode is (vdiode, idiode)idiode = id(i)vdiode = vd(i)% Plot the voltages during iteration processplot(k,vd,'b')axis([-1,5,0.6958,0.701])title('Diode Voltage during Iteration')xlabel('Iteration Number')ylabel('Voltage, V')

Page 27: Lecture 6 MATLAB Applications In Electronics

ANALYSIS OF DIODE CIRCUITS

Diode Voltage during Iteration Process

Operation point is idiode =

8.9405e-004

vdiode =

1.0595

Page 28: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIER

V0 = Vs when Vs ≥ 0V0 = 0 when Vs < 0

Page 29: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIER

Page 30: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIERExample 5A battery charging circuit is shown in Figure . The battery voltage is VB = 11.8 V. The source voltage is Vs(t) = 18sin(120πt) V and the resistance is R = 100 Ω. Use MATLAB (a) to sketch the input voltage, (b) to plot the current flowing through the diode, (c ) to calculate the conduction angle of the diode, and (d) calculate the peak current. (Assume that the diode is ideal.)

Page 31: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIERSolution:When the input voltage Vs is greater than VB , the diode conducts and the diode current, id , is given as

The diode starts conducting at an angle θ, given by Vs ≥ VB18 sinθ1= 18 sin( 120πt1)= VB = 11.8

The diode stops conducting current when Vs ≤ VB18 sinθ2= 18 sin( 120πt2) = VB

due to the symmetryθ2 = π - θ1

MATLAB Program:% Baltery charging circuitperiod = 1/60; % the input signal frequency 60 Hzperiod2 = period*2;inc =period/100;npts = period2/inc;

Page 32: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIERvb = 11.8;t = [ ];for i = 1:nptst(i) = (i-1)*inc;vs(i) = 18*sin(120*pi*t(i));if vs(i) > vbidiode(i) = (vs(i) -vb)/r;elseidiode(i) = 0;endendsubplot(211), plot(t,vs)%title('Input Voltage')xlabel('Time (s)')ylabel('Voltage (V)')text(0.027,10, 'Input Voltage')subplot(212), plot(t,idiode)%title('Diode Current')

Page 33: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIERxlabel('Time (s)')ylabel('Current(A)')text(0.027, 0.7e-3, 'Diode Current')% conduction angletheta1 = asin(vb/18); theta2 = pi - theta1;acond = (theta2 -theta1)/(2*pi)% peak currentpcurrent = (18*sin(pi/2) - vb)/r% pcurrent = max(idiode)

Page 34: Lecture 6 MATLAB Applications In Electronics

3- HALF-WAVE RECTIFIER

The conduction angle, acond, and the peak current, pcurrent, areacond =

0.2724pcurrent =

0.0620

Page 35: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitThe output of the half-wave rectifier circuit of Figure 5.8 can be smoothed by connecting a capacitor across the load resistor. The smoothing circuit is shown in Figure .

Page 36: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing Circuit

Page 37: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitThe output voltage reaches the maximum voltage Vm , at time t=t2to t=t3 , the diode conduction ceases, and capacitor discharges through R. The output voltage between times t2 and t3 is given as

The peak to peak ripple voltage is defined as

For large values C such that CR >> (t3- t2), we can use the well-known exponential series approximation

e-x =1−x for |x| << 1Thus, Equation Vr approximates to

Page 38: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitThe discharging time for the capacitor, (t3- t2), is approximately equal to the period of the input ac signal, provided the time constant is large. That is,

f0 is the frequency of the input ac source voltage. Using this Equation in Vr Equation we get

For rectifier circuits, because RC >> T , the output voltage decays for a small fraction of its fully charged voltage, and the output voltage may be regarded as linear. Therefore, the output waveform of Figure is approximately triangular. The rms value of the triangular wave is given by

Page 39: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitThe approximately dc voltage of the output waveform is

MATLAB function fzeroThe MATLAB fzero is used to obtain the zero of a function of one variable. The general form of the fzero function is

fzero ('function ',x1)fzero ('function ',x1,tol)

fzero(' funct', x1) finds the zero of the function funct(x) that is near the point x1.fzero(' funct', x1, tol) returns zero of the function funct(x) accurate to within a relative error of tol.The MATLAB function fzero is used in the following example.

Page 40: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitExample 6For a capacitor smoothing circuit of Figure, if R = 10KΩ,C = 100μF, and vs (t) = 120 sin(120πt ),

(a) use MATLAB to calculate the times t2 , t3 , (b) compare the capacitor discharge time with period ofthe input signal.

SolutionThe maximum value of vs (t) is 120 , and it occurs at 120πt2= π/2, thus t2=The capacitor discharge waveform is given by

Page 41: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing CircuitAt t=t3Defining v(t) as

Then,

Thus.

MATLAB is used to solve Equation (5.32)MATLAB Script% Capacitance discharge time for smoothing capacitor% filter circuitvm = 120*sqrt(2);

Page 42: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing Circuitf0 = 60; r =10e3; c = 100e-6;t2 = 1/(4*f0);tp = 1/f0;% use MATLAB function fzero to find the zero of a% function of one variablerc = r*c;t3 = fzero('sinexpf1',4.5*t2);tdis_cap = t3- t2;fprintf('The value of t2 is %9.5f s\n', t2)fprintf('The value of t3 is %9.5f s\n', t3)fprintf('The capacitor discharge time is %9.5f s\n', tdis_cap)fprintf('The period of input signal is %9.5f s\n', tp)

Page 43: Lecture 6 MATLAB Applications In Electronics

Capacitor Smoothing Circuit%function y = sinexpf1(t)t2 = 1/240; tp = 1/60;rc = 10e3*100e-6;y = sin(120*pi*(t-tp)) - exp(-(t-t2)/rc);End

The results areThe value of t2 is 0.00417 sThe value of t3 is 0.02036 sThe capacitor discharge time is 0.01619 sThe period of input signal is 0.01667 s

Page 44: Lecture 6 MATLAB Applications In Electronics

Thanks