# diode calculations

## Contents

- Diode equation
- Solve example 1
- load line
- Example 2 - assume diode conducts.
- assume diode does not conduct

## Diode equation

    IS = 3e-15;
    VT = .026;
    vd = linspace(0,0.79,201);
    id = IS*(exp(vd/VT)-1)*1e3;
    plot(vd,id,'k','LineWidth',2);
    xlabel('V_d (volts)');
    ylabel('I_d (mA)');
    axis([0 1 0 30]);
    grid;

## Solve example 1

    Von = 0.7;
    Vs = 4;
    Rs = 500;
    id = (Vs - Von)/Rs;
    vd = fzero(@diode_fcn,Von);
    fprintf('approximate id %g mA\n',id*1e3);
    fprintf('exact id %g mA\n',(Vs-vd)/Rs*1e3);

    approximate id 6.6 mA
    exact id 6.5228 mA

## load line

    Vs = 4;
    Rs = 500;
    Ix = Vs/Rs*1e3;
    vd = linspace(0,0.79,201);
    id = IS*(exp(vd/VT)-1)*1e3;
    plot(vd,id,'k','LineWidth',2);
    hold on;
    plot([0 Vs],[Ix 0],'r','LineWidth',2);
    hold off;
    xlabel('V_d (volts)');
    ylabel('I_d (mA)');
    axis([0 5 0 10]);
    grid;

## Example 2 - assume diode conducts.

    R = [5 10 10];
    Rp = 1/sum(1./R);
    Vs = 14;
    Vb = 9;
    v1 = Rp*(Vs/R(1)+(Vb+0.7)/R(3));
    fprintf('v1 %g V\n',v1);
    i3 = (v1-Vb-0.7)/R(3);
    fprintf('i3 %g A\n',i3);
    if (i3<0)
        fprintf('diode is not conducting\n');
    end

    v1 9.425 V
    i3 -0.0275 A
    diode is not conducting

## assume diode does not conduct

    v1 = R(2)/(R(1)+R(2))*Vs;
    v2 = Vb;
    vd = v1 - v2;
    fprintf('vd %g V\n',vd);
    if (vd<0.7)
        fprintf('diode is not conducting\n');
    end

    vd 0.333333 V
    diode is not conducting