Using a microcontroller to manage the operation of a switching power supply allows designers to implement new programmable features previously unavailable from stand-alone controller chips. Many of these features can be demonstrated with the design of a 24-V to 5-V dc-dc buck regulator. This design may seem generic because it has many of the standard features common to a switching power-supply design. However, this design exploits the power of the microcontroller to add a number of novel programmable features.
One such feature is an adaptive current limit control that lets the designer specify separate current limit values for different phases of the power supply's operation. It's possible to program an elevated current limit at startup for capacitive loads, a reduced current limit for high-temperature operation and the normal operating current limit.
Another feature is programmable output voltage, which lets the designer set the output voltage through programming rather than a manual adjustment. A calibration option also allows the designer to do an automated setting of the output voltage by simply connecting a reference voltage to the output and powering up the supply with a jumper in place. Also, an output voltage ramp-up lets the designer specify the speed at which the output voltage rises on power up.
Using the microcontroller allows designers to implement supervisory features, such as a programmable undervoltage lockout, that makes the minimum supply-voltage requirements a programmed value rather than a manual adjustment. Another possibility is a trigger voltage input, which lets designers coordinate the startup of the power supply with other supplies in the system. Other options are an output overcurrent detect that doesn't use a high-side current sense, an automatic power-up restart in the event of a serious fault and a retry counter to limit restarts.
Most of the features listed aren't new to power-supply design. However, the designer's ability to program and configure the features, as well as specify complex sequences for the startup and fault recovery, is new.
Once specifications for the buck regulator were defined, the next step was to design hardware to support them. For clarity, the design was broken into two sections: the power chain and the microcontroller.
The power chain was based on Texas Instruments' UC3847 chip. Not a new device, the UC3847 provided access to several internal signals required for the features described above. Specifically, it allowed access to the Vref input of the error amplifier.
The microcontroller had to be able to control the output voltage of the power chain. Access to the Vref input of the error amplifier was needed so the microcontroller could inject its own variable reference voltage in place of the UC3847's reference. Access to the UC3847's voltage reference also provided a convenient supply voltage for the microcontroller and gave the microcontroller's variable reference voltage the same stability as the original reference.
Another feature of the UC3847, an external current-limit input, allowed the microcontroller to set the limit for the power chain. The UC3847 also offered access to the output of the error amplifier. Measuring this voltage allowed the microcontroller to determine the average output current of the power chain. The combination of the UC3847's easy access to internal signals and the general controllability of the device made it a good candidate for the power-chain controller.
The choice of a microcontroller also was influenced by the features required for the design. Two PWM outputs were needed. One output would require a minimum of 10 bits of resolution to generate the reference voltage input to the power chain, and a second 6-bit to 8-bit resolution PWM was needed for controlling the current limit input to the UC3847.
Other requirements included a multiple-input 10-bit analog-to-digital converter for monitoring the various levels in the power chain, and an EEPROM memory for storing configuration constants and the output-voltage set point. Low-current operation also would be sought, so the microcontroller could be powered from the reference voltage in the UC3847. Because of the microcontroller's scaling of the reference voltage, it would be necessary for the PWM output driver to be powered by the reference. Also, the ability to reprogram and configure the microcontroller required that the device have Flash program memory.
The microcontroller selected to fit the requirements was a Microchip PIC16F684. In addition to meeting the design requirements, its small size (14 pins), low cost and the availability of low-cost development tools recommended it for the design.
Once the main control devices were selected, the hardware design was simply a matter of interfacing the PIC16F684 to the UC3847 and filling in the required peripheral components. The UC3847 and its power chain are based on a design example from its datasheet. The PIC16F684's programming interface is taken from the PICkit 1 Flash Starter Kit user's manual. Fig. 1 shows the final schematic for the power supply, and Fig. 2 shows the final development board.
A couple of points in the design should be highlighted. The power-supply connection to the microcontroller is connected through jumper J6. This is done because the power supply for the microcontroller must be isolated during programming so the programmer can properly reset the part. The bypass capacitance on the microcon-troller supply must also be below 0.5 µF for proper programming.
Also noteworthy is the combination of an isolation diode and a pull-up resistor on pin RA3 of the microcontroller. These components prevent the leakage of the 12-V programming voltage into the 5-V supply during programming. Furthermore, all control pins on the UC3847 that are driven by the microcontroller are biased to their inactive states with a large-value resistor to keep the device inactive until the microcontroller exits reset following power up. These design precautions are reasonable and prudent for any design that uses a microcontroller with in-circuit programming.
Many features associated with the power supply are implemented in software. This is advantageous in that changes and upgrades are just a matter of reprogramming. The disadvantage is that the software design becomes more complex, requiring the ability to handle multiple simultaneous operations.
Handling simultaneous operation or multitasking is accomplished by building the software using state machine constructs. Much like hardware state machines, software state machines use a counter to sequence their operation. Based on the value, or state, of the counter, the state machine executes different software functions. The current state and external inputs are then combined to determine the next state to be executed.
Multitasking is done by building separate state machines for the various functions that operate simultaneously, and calling them, one after the other, inside an infinite loop. This system allows each state machine to execute one state each time through the loop. The overall effect is that all state machines appear to be operating simultaneously, although slower than if executed individually.
For this power-supply controller design, four state machines were written: Monitor_sm(), Control_sm(), Crnt_lmt_sm() and Out_volt_sm(). Control_sm() coordinates the activity of the other state machines and sets the overall operational “mood” of the system. Monitor_sm() performs all of the analog-to-digital conversion for the system, monitoring the supply, output, error amplifier and trigger voltages, as well as the temperature of the power MOSFET. Crnt_lmt_sm() controls the loop timing for the system and generates the current limit control voltage. Finally, Out_volt_sm() controls the output voltage of the power supply and generates the ramp-up function on power up. Fig. 3 shows how the control and data flows through the state machines.
Monitor_sm() is a simple state machine that continuously cycles through the various analog signals, converting each into a 10-bit number for storage in the measured array. The sequence is supply voltage, trigger voltage, transistor temperature, error amplifier, and output voltage, before looping back to the supply voltage. The exception to the sequence is for the calibration mode. When calibrating, Monitor_sm() repeatedly converts only the output voltage signal, as the power chain is inactive.
Control_sm() directs the activity of all the other state machines through its state-variable mood. The state machine's states correspond to the six moods of the system. Based on the value of the mood state variable, the system's other state machines alter their states accordingly to coordinate their activity with the Control_sm().
The states of Control_sm() are Shutdown, Start, Normal, Iomax, Error and Cal. Shutdown is active when the power supply is waiting for the supply and trigger voltages to climb into their nominal ranges. Start is active when the output voltage is ramping up to its preset output voltage. Normal is active during all normal operation. Either Iomax or error is active during fault conditions. Iomax is for output overcurrent and Error is for an overtemperature condition.
Cal is active in response to a request for calibration. But note that Cal is a dead-end state, requiring a power-down to exit. Fig. 4 shows the states of Control_sm() and the possible state transitions, with their causes. The circles denote the specific state, with the arrow denoting a transition. The tag on each arrow notes the specific condition causing the transition.
Crnt_lmt_sm() performs three functions. It synchronizes the start of each pass through the loop by delaying until the hardware timer Timer0 rolls over from FF to 00. Then, Crnt_lmt_sm() generates the current limit PWM output pulse before moving on to execute the current state.
The Crnt_lmt_sm() has four possible states: Shutdown, Boost, Normal and Reduce. The Shutdown state holds the current limit PWM output at a duty cycle of zero, forcing the UC3847 to shut down the output of the power supply. The Boost state increases the current-limit duty cycle during the ramp-up of the output voltage. The Normal state sets the current limit duty cycle to the steady-state current limit. Reduce reduces the current limit duty cycle in response to a high-temperature condition in the power chain transistors.
The transitions from state to state in the Cnrt_lmt_sm() state machine occur in response to changes in the systems, as indicated by the mood state variable. Fig. 5 shows the transition diagrams for the Crnt_lmt_sm() state machine.
Out_volt_sm() operates in much the same way as Crnt_lmt_sm(), with a few exceptions. It doesn't contain the timer monitoring or pulse generation sections, and it uses three states, not four: Shutdown, Ramp and Normal.
Shutdown and Normal behave like the Shutdown and Normal states in Crnt_lmt_sm(), driving the output voltage PWM to zero for Shutdown, and to the preprogrammed setpoint during Normal operation. The new state is Ramp, in which Out_volt_sm() ramps up the output voltage over time, using increment and delay values set by the designer. Once the ramp up of the output is complete, Control_sm() is notified and the mood of the system and its state machines change to Normal. Fig. 6 diagrams Out_volt_sm().
When combined, the four state machines create a single management system that monitors and controls the operation of the power supply, responding to both internal and external events based on configuration values stored in the microcontroller's EEPROM memory.
Another issue in power-supply design is reliability. With the inclusion of a managing microcontroller, additional mechanisms must exist within the hardware and software design of the microcontrollers for handling fault conditions. Hardware reliability involves two concerns — the behavior of the microcontroller at power-up/power-down and its response to EMI/RFI. Software concerns are limited to detecting and correcting fault conditions that arise from corrupted data and/or programming memory.
To manage the behavior of the microcontroller during power-up and power-down conditions, two systems are built into the microcontroller hardware: the power on reset (POR) circuit and the brownout reset (BOR) circuit. The POR circuit holds the microcontroller in reset during power-up until the supply voltage for the microcontroller reaches the minimum safe operating voltage and the main oscillator has stabilized.
The BOR operates during power-down, generating and holding a reset when the microcontroller power-supply voltage drops below the user-defined minimum supply voltage. Together, these two systems combine to hold the microcontroller in reset, whenever the power supply for the microcontroller is insufficient for stable operation of the device.
Managing the microcontroller's response to EMI and RFI is a matter of combining proper static protection for the device, proper selection of bypass capacitors and good layout. Good software design is important because EMI and RFI events can corrupt data and program memory. Although safeguards are implemented in software, they shouldn't be taken as a license to neglect proper hardware protection.
Two important software safeguards have been incorporated into this design to prevent unpredictable behavior by the software. The watchdog timer (WDT) is enabled and set for a time-out that is slightly longer than the worst-case timing for the main loop in the program. In addition, a clear WDT instruction exists in only one place, and that is in the main software loop. This protects the system from lockup conditions in the software by creating a means for the software to recover from a fault serious enough to have corrupted the program counter in the microcontroller.
Another safeguard is the inclusion of a default state in all of the state decoding in the state machines. The default state is to be called whenever the state variable doesn't decode to a valid state. Within the default state is a routine to reset all of the critical state machine data variables, including the state counter variable.
Together, the hardware and software systems help the microcontroller recover from unpredictable behavior. Careful consideration of their use should be part of any design incorporating microcontroller management of a power-supply system.
Those interested in building the power-supply design presented within the text of this article may visit http://techtrain.microchip.com/downloads/pet_0904.zip for a zipped file with source listings, a hex file, gerber files and a bill of materials.
Thank you to Datatronics and Wirebenders for supplying the magnetic components in the design.
For more information on this article, CIRCLE 334 on Reader Service Card