data_example #data_design_AC #data_design_DC function displayLine(label,val,valComputed,vs) disp(sprintf( "%25s%25.3e%25s%25.3e%25.3f",label,val,vs,valComputed,100*(val-valComputed)/val)); endfunction disp(sprintf("%25s%25s%25s%25s%25s","Variable","Design","Design vs computed","Computed","Deviation [%]")); #Cin # to compute for AC design #Nps #to compute with AC design #Cout Cout_min_computed = (Iout/fc)/(Vout*0.1); displayLine("Cout",Cout,Cout_min_computed,">="); #Duty cycle duty_computed = Nps*Vout/( (Vbulk_min) + Nps*Vout); displayLine("duty",duty,duty_computed,"="); #Lpm Lpm_min_computed = (Vbulk_min*duty) / ( 0.7*Iout*fsw / (Nps*efficiency)); displayLine("Lpm",Lpm,Lpm_min_computed,">=") #ILpm ILpm_computed = (Vbulk_min*duty)/(fsw*Lpm); displayLine("ILpm",ILpm,ILpm_computed,"=") #ILpPK ILpPK_computed = Iout/( Nps * (1-duty)) + ILpm/2; displayLine("ILpPk",ILpPK,ILpPK_computed,"=") #RCS Rcs_computed = 1/ (ILpPK*1.3); displayLine("Rcs",Rcs,Rcs_computed,"=") #Power in Rcs PRcs_min_computed = 1/3 * 1^2 / Rcs; displayLine("P Rcs",PRcs,PRcs_min_computed,">") #Lsm this i am unsure of the computation... I need sourceto validate Lsm_computed = Lpm/(Nps^2); displayLine("Lsm",Lsm,Lsm_computed,"=") #Rs1 Rs1_computed = (1.7 * Rs2 * fsw *(2*Lsm*Nps)) / (Vout * (1-duty) * Rcs) - Rs2; displayLine("Rs1",Rs1,Rs1_computed,"=") #Ri Ri_computed = (Rk*(Vout-VTL431Ref)/VTL431Ref); displayLine("Ri",Ri,Ri_computed,"=") #Vout Vout_computed = VTL431Ref * ( Rk + Ri )/ Rk; displayLine("Vout",Vout,Vout_computed,"=") #frequency response s= @(f) 2*pi*f*i; #Optocoupler Gopto = @(f) Rc/Rf * ctr_min ./ (s(f)/(2*pi*fopto)+1); #Transfer function of the output of the opto to the PWM control voltage GBC(f) Gbc = @(f) Ra/Rb * 1./(s(f)*Ra*Ca+1); #Gco(f) D = @(Vbulk) Nps*Vout/(Vbulk+Nps*Vout); Sn = @(Vbulk) Vbulk*Rcs/Lpm; Se = 1.7 * Rs2*fsw/(Rs1+Rs2); Q = @(Vbulk) 1/(pi*((1+Se/Sn(Vbulk))*(1-D(Vbulk))-0.5)); Gco = @(f,Vbulk) Nps.*((1-D(Vbulk))./(1+D(Vbulk))).* ... ((s(f).*ESR.*Cout+1)./(s(f).*Rout.*Cout+1)).*... (1-(s(f).*Lsm.*D(Vbulk)./(Rout.*(1-D(Vbulk)).^2))).*... (1/3) ./ (1 + (s(f)./(2.*pi.*fsw./2.*Q(Vbulk))) + (s(f)./(2.*pi.*fsw./2)).^2); Go = @(Vbulk) abs(Gco(0,Vbulk)); Frhpz_computed = (Nps^2) / ((2*pi*Lpm/Rout) * (D(Vbulk_min)/(1-D(Vbulk_min))^2)); displayLine("f_RHPZ",Frhpz,Frhpz_computed,"="); fcross_max_computed = Frhpz/2; displayLine("Cross over f",fcross,fcross_max_computed,"=<"); #Rz tmp =Ri/(Gopto(fcross/5)*Gbc(fcross/5)*Go(Vbulk_min)*Gco(fcross/5,Vbulk_min)); Rz_computed = abs(tmp); displayLine("Rz",Rz,Rz_computed,"=") #Cz Cz_computed = 1/(2*pi*fcross/5*Rz); displayLine("Cz",Cz,Cz_computed,"=") #Cp Cp_computed = Cz/10; displayLine("Cp",Cp,Cp_computed,"=") #Gc TL431 compensation circuit Gc = @(f) (s(f).*Rz.*Cz+1)./( s(f).*Ri .* (Cz+Cp) .* (((s(f)*Rz*Cz*Cp)/(Cz+Cp))+1)); Tv = @(f,Vbulk) Gc(f).*Gopto(f).*Gbc(f).*Go(Vbulk)*Gco(fc,Vbulk); f = logspace(0,log10(max_freq_to_plot),255); Gco(fc,Vbulk_min) Gco(fc,Vbulk_max) Tv_min = Tv(f,Vbulk_min); Tv_max = Tv(f,Vbulk_max); Gopto_rep = Gopto(f); figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Gopto_rep)),f,angle(Gopto_rep)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response of optocoupler")); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on Gbc_rep = Gbc(f); figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Gbc_rep)),f,angle(Gbc_rep)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response of Gbc")); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on Gco_rep = Gco(f,Vbulk_min); figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Gco_rep)),f,angle(Gco_rep)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response of Gco at %d V",Vbulk_min)); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on Gco_rep = Gco(f,Vbulk_max); figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Gco_rep)),f,angle(Gco_rep)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response of Gco at %d V ",Vbulk_max)); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on Gc_rep = Gc(f); figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Gc_rep)),f,angle(Gc_rep)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response of Gc ")); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Tv_min)),f,angle(Tv_min)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response at Vin = %.1f V",Vbulk_min)); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on figure; [ax, h1, h2] = plotyy(f,20*log10(abs(Tv_max)),f,angle(Tv_max)/(2*pi)*360); set(ax, "xscale", "log"); set(ax, "FontSize", 24); title(sprintf("Frequency response at Vin = %.1f V",Vbulk_max)); ylabel(ax(1),"Gain [dB]"); ylabel(ax(2),"Phase [°]"); xlabel("Frequency [Hz]"); grid on