Micro - Controller Implementation
Nowadays the use of a micro-controller is popular. But control of a circuit
switching at 20 kHz tends to be difficult, essentially due to delays involved
in A/D conversion and some mathematical operations. Hence the approach to
closed-loop control is a combination of rule-based logic and action of a PID
controller. The delay that occurs from the instant the A/D converter samples
an input signal to the instant when the corresponding digital output is available
for use tends to be of the same order as the switching cycle period.
At 20 kHz, the switching cycle period is 50 mS
and the delay involved due to the use of an A/D converter is about 40 mS.
This means that no more than one sample can be obtained during one switching
cycle period. If this sampling is done in an asynchronous manner, closed-loop
can be difficult. For example, the inductor current can vary considerably
over a cycle period and asynchronous sampling of inductor current may not
lead to stable closed-loop control. It is preferable to sample the inductor
current at a predetermined instant of the cycle period. For example, at the
start of a switching cycle, a sample and hold circuit can be used to store
the instantaneous value of inductor current and the A/D converter can convert
this value. In the fifth applet displayed below, the A/D converter delay is
set to be equal to one switching cycle period. When that is so, the sampling
occurs at the beginning of each cycle. The inductor current and the capacitor
voltage are sampled once in two cycles, since conversion period for each sample
equals one switching cycle period.
If the sampling is to be done at a faster rate, the sampling has to be asynchronous
and then an analogue filter has to be used to reduce the variations in the
feedback signal corresponding to inductor current before it is used as the
input to the A/D converter.
The scheme suggested for controlling the SMPS with a micro-controller is
outlined with the help of a pseudo-code presented below.
Initialize:
Output Voltage Count = 0 // Output of A/D converter
Inductor Current Count =0 // Output of A/D converter
Old Current Count = 0
// Previous current count required for derivative feedback
swCycleCount = 100
// Set the period of switching frequency as a number of
micro-controller clock frequency.
atod_delay =100
// Set the A/D converter's conversion period and computing
delay as a number of // micro-controller clock frequency.
lowCount= 5;
highCount=95;
dutyCycle=lowCount;
// Set the limits for duty cycle and set the duty cycle
at its lowest value
on_off=true;
// boolean value indicating switch is ON when it is true
rampCount=0;
// Used with dutyCycle and swCycleCount for setting on_off
to either true or false value
atod_Count=0;
feedback Voltage=0
integrator Output=0
//Output of an integrator used in feedback control
Go to Main Loop
Main Loop:
Call Parameters Subroutine
Increment ramp Count
If (rampCount<dutyCycle) on_off = true;
Else on_off = false;
If (rampCount == swCycleCount)
{
on_off = true
rampCount=0;
}
Increment atod_Count
Increment rampCount
If (atod_Count>atod_delay) call NextValues subroutine
Return to Main Loop
Parameters Subroutine:
Begin
Desired Output Voltage=50.0
// numerical setting using thumb-wheel
switches/KeyPad
Current Limit = 125%
// Set in software, using KeyPad
or thumb-wheel switches
kd=20
// Derivative feedback coefficient
in Ohms.
// Feedback in Volt equals (kd
´ Inductor Current).
dkI=0.1
// Integrating Coefficient effective
when output voltage is within
// a close band of ±
5% of source voltage from the desired output voltage.
End subroutine
NextValues Subroutine
Begin
atod_Count=0;
Inductor Current Count = output
of A/D output
Ouput Voltage Count = output of
A/D output
if (Inductor Current Count <=Current
Limit)
{
feedback
Voltage= Ouput VoltageCoun +kd*( Inductor Current Count - Old Current Count);
if (Desired
Output Voltage>(feedback Voltage+5%)) dutyCycle++;
if (Desired
Output Voltage<(feedback Voltage-5%)) dutyCycle--;
if (Desired
Output Voltage>(feedback Voltage-5%)) AND (Desired Output Voltage<(feedback
Voltage+5
{
integrator output+=
dkI*(Desired output Voltage-Ouput Voltage Count)
dutyCycle+= integrator output;
if (dutyCycle<=lowCount) dutyCycle=lowCount
if (dutyCycle>=lowCount) dutyCycle=highCount
}
else
{
integrator output =0;
}
else
{
dutyCycle
= dutyCycle-2;
if (dutyCycle<=lowCount)
dutyCycle=lowCount;
}
End Subroutine
The fifth applet presented below simulates the operation of the switch mode
step-down power supply controlled by a micro-controller. The applet has default
values for the parameters listed below.
Input Voltage,dc avg = 100
Input Ripple Volt., pk-pk = 0;
Input Ripple Frequency = 100
Inductance, microHenry = 500;
Capacitor, microFarad = 500 ;
Load Resistance, Ohms = 10;
Desired Output Voltage = 50;
Rated Current, Amp = 10;
Micro's Clock Freq, MHz = 2 ;
Switching Period:Clock Cycles = 100;
A/D Delay :Clock Cycles = 100;
Derivative FeedBack Coef. =20;
Integrating Coefficient = 0.1;
This applet has the same structure as the fourth applet and is hence not
described any further.
click here to open the applet
FIFTH APPLET
TO THE TOP |