Hi
I am simulating an active power factor correction switching regulator. I am having a bit of trouble getting a good algorithm going for it though.
Here is my circuit. The input is rectified AC, 60Hz, ~160V vin = 160*|sin(2*pi*60*t)|
|------[inductor]--[L_ESR]---|---[diode->|]---|-------| | | | | | | | | [vin] [contro]-[fet] [cap] [load] | | | | | | [C_ESR] | | | | | |--------------------|-------|----------------|-------| | [gnd]
This is the code I am using to simulate the circuit: (StepSize is 1E-9)
if (SwitchOn) { //left half inductorCurrent += (vin - inductorESRVoltage) * StepSize / inductance;
inductorESRVoltage = inductorCurrent * inductorESR;
//right half capacitorVoltage += loadCurrent * StepSize / capacitance; vout = capacitorVoltage + loadCurrent * capacitorESR; loadCurrent = vout / loadResistance; capacitorCurrent = loadCurrent; } else { inductorCurrent += (vin - inductorESRVoltage) * StepSize / inductance; if (inductorCurrent < 0) { inductorCurrent = 0;//diode } inductorESRVoltage = inductorCurrent * inductorESR + vout; capacitorVoltage += (inductorCurrent - loadCurrent) * StepSize /
capacitance; loadCurrent = vout / loadResistance; vout = capacitorVoltage + loadCurrent * capacitorESR; capacitorCurrent = inductorCurrent - loadCurrent; }
The PWM controlling the proportion of time on/off for the Switch in the above code is here:
Microloop()//called at 100kHz { duty = (desiredVout - vout)*(k * vin - inductorCurrent); //the (desiredVout - vout) sets the error for the output voltage //(k * vin - inductorCurrent) sets an error current for the input, to //make sure the input current is proportional to input voltage. I have //been using a k of 0.25 if (duty >= 95) { duty = 95; } else if (duty < 0) { duty = 0; } }
The problem with my simulated controller as it stands is that the inductor current has a lot of ripple in it, but the magnitude of the inductor ripple is proportional to the input voltage. The output voltage regulates well though. Do I need to make changes to my circuit or algorithm to make this work better?
Scott