Powering from an AC source Apr 2016

Ok, we have a name: “JeeLabs Energy Monitor” - and we have a board to use: the Olimexino-STM32. As mentioned before, that board has a number of convenient features for this project.

Then again, any other board can be used - most differences are minor, and there is a huge variety to choose from. Even the “F103” µC family is not really important. Since the F103 is mature, and this is a low-end 128K flash / 20K RAM unit, most other µC’s should be fairly easy to port to.

The Olimexino can be powered from a 9-30 V supply, from the USB port, or from a LiPo battery. But there are a couple of advantages to powering from an AC power source, i.e. directly off a step-down transformer of 9..12 VAC:

That last point requires some clarification: the Olimexino specs mention a 9..30V DC power source. Powering it with AC means the on-board switching power supply will have to work a bit harder, since it will run with a widely varying input voltage: zero 50% of the time, and a half sinewave the other 50%.

The input capacitor is 100 µF, and will end up seeing fairly large currents, as it gets topped up every 20 ms. As will be shown below, the resulting voltage level always stays above 9V, allowing the regulator to do its work.

The voltage on an unloaded 9 VAC transformer used for testing looks like this:

It’s not such a great sine wave, probably because it’s not such a great transformer. But it’ll just have to do - a high-quality bell transformer should produce a more accurate representation of the AC mains waveform.

When we hook this up to power the Olimexino, something unfortunate happens:

The asymmetric loading of one half of the sine wave to power the board, plus the fact that the on-board 100 µF capacitor only draws current while being topped up, causes this distortion.

That’s not great if we also want to use the waveform later on for reactive power calculations. Fortunately, the original waveform is symmetric. So the solution is to use one half of this 50 Hz wave for drawing power and the other half for measurements. Here’s the circuit we will use:

As described in a recent article, a voltage divider is used to reduce the signal to acceptable levels for ADC readout and this divider is then connected to +3.3V to handle this - negative! - voltage.

By matching up the scales of the two signals we can see the result on the oscilloscope:

The blue trace is the transformer’s AC voltage (about 34 Vpp). The top half is used to power the board, and the bottom half gets converted to a “3.3V signal with downward blips”. There is enough information to reconstruct an accurate representation of the full signal. Thanks to the symmetry, we can place the zero crossings at the level where the upward and downward slopes have 50% duty cycle - halfway on the above screen shot, i.e. roughly 3.0V on the ADC input.

One last screenshot, using a bit of scope trickery to bring it all together:

There is a lot of useful information in here:

When running at 72 MHz, the Olimexino draws about 45 mA @ 5V - with the switcher this translates to around 20..30 mA drawn from the AC power supply. This should not be a problem, even if it were to double later on, when a bit more circuitry gets added.

So there you have it: we’ve re-used an existing power source, and we have a 0..3.3V signal which can be fed to an ADC pin, to let us determine AC mains voltage and frequency fluctuations as well as obtain a decent representation of the wave shape of AC mains power, all in real time.

Weblog © Jean-Claude Wippler. Generated by Hugo.