Introduction
I was casting around for designs for DC-DC converters - switched-mode power supplies (SMPS) - and coming up against a number of issues. An SMPS basically uses an electronic switch (such as a MOSFET device) and a reactive component (usually an inductor, but occasionally a capacitor) in such a way that by controlling the operation of the switch you can transfer electrical energy from a power supply to a load increasing or decreasing the voltage of the supply to the load in the process. This can be useful if you want equipment to operate using commonly available power sources (batteries or a USB port, for example) but the voltages they offer are either too high or too low for the circuit you want to power.
There are a variety of potential circuit configurations - boost converters can only raise voltage, buck converters can only lower voltage, buck-boost converters can do both and flyback circuits (which employ a transformer as the reactive component) can use the transformer to achieve significantly greater step-up and step-down ratios. And there are a whole lot more. There's a video from Texas Instruments (TI) that gives a useful introduction.
The most straightforward way to build a SMPS is to use one of the chips provided by companies such as TI, selecting one of the inductors made by one of their partner firms to complement it. The snag is, firstly, that, these days, most of the chips are surface-mount devices (which isn't ideal for the occasional hobbyist), secondly they can be quite expensive as one-offs and, thirdly, that most of the magnetics are only available from large distributors - which can turn your one-off hobby project into quite an expense if you're making only a small order or mean that you have to start from the premise of making do with whatever you can lay your hands on and work backwards from there.
Typically, the circuits use a variable duty cycle square wave to drive the electronic switch, with feedback from the output voltage being used to increase the duty cycle if the load voltage is dropping and to decrease it if the load voltage is getting to high. Given that the Rapberry Pi Pico has hardware for both pulse-width modulation (PWM - in other words, generating a square wave with a variable duty cycle) and for analogue to digital conversion (ADC - in other words the ability to measure voltages), it came to mind that it might just be possible to use it as the basis of a power supply. The documentation for these capabilities can be found in the RP2040 datasheet - the documentation for the chip at the heart of the Pico.
Initial Steps
The first thing to do, of course, is to acquire your Pico and set up your development environment. Unlike its larger cousins, the Pico seems to be widely available and for this purpose you don't need the variant with WiFi, though for breadboarding the version with headers already soldered is convenient. I'm going to be using the C programming model, Python is also available as an alternative.
Installing the development environment is not trivial, but there is a fairly comprehensive Getting Started guide that takes you through it, though you may find you need to do a bit of independent research to get it working as advertised, especially if you want to do your builds with Visual Studio Code.
There are a lot of examples provided to demonstrate the various hardware functions. In the directory pico-examples/pwm/led_fade the program pwm_led_fade.c uses the PWM hardware to continuously fade up and fade down the on-board LED of the Pico. It's probably worth building this and loading it onto the Pico to get a sense of how everything works and to be able to see the PWM hardware in action.
If you were to alter the program to use a different PWM output pin (i.e. not the LED), you would be able to observe the signal that's driving the LED using an oscilloscope:
As you can see, the frequency and magnitude of the signal stays the same, but the duty cycle increases and decreases. We at least have the basis of what we need to generate a signal with a variable duty cycle. We'll investigate this in more detail in the next post.
The Basic SMPS Circuit
At least to a first approximation, the two most important factors determining the output of such a power supply are the duty cycle of the switching signal and the characteristics of the inductor: not just its inductance which will determine how much power can be transferred in each cycle, but its construction which will determine the switching frequency at which it is most efficient. If you have the luxury of choosing your components you can do most of your design work up front. However, for hobby projects and one-offs, you may simply have to make the most of what's lying around and this is where having a programmable device comes into its own: you can generate a whole range of different switching signals and measure the results.
For the particular project I had in mind, I wanted to use a flyback configuration as I wanted to generate a variety of different output voltages using a transformer with multiple secondary windings. I happened upon one of the WE-FLEX transformers made by Würth: these have 6 identical windings that can be configured in series (for higher voltages) or in parallel (for higher currents).
The very basic outline of a flyback design using such a transformer can be reduced to this:
The PWM input signal drives the gate of a MOSFET operating as a switch to rapidly turn on and turn off the power to the transformer primary. The diode does not simply function as a rectifier: it is the second "switch" in the circuit and ensures that current does not flow in the secondary when the primary switch (MOSFET) is turned on and the relative polarity of the transformer windings is significant.
The principal omission from this circuit is any means of regulation: in the real world we'd want the output voltage to be kept reasonably constant, but it will suffice to demonstrate the principle.
In the next post, we'll find out how to generate the gate signal and see what we get when we apply it to the circuit shown.
Comments
Post a Comment