Ideally I would like to be able to measure and/or calculate the following:
- Zero-crosssing of voltage/current
- True-RMS of voltage/current
- Real Power
- Apparent Power
- Displacement Power Factor
- Power Factor
Before attempting to come up with a solution based on a microprocessor, I thought I would have a go with something simpler; an oscilloscope. My oscilloscope is a PicoScope which gives the added advantage that I can capture traces and perform calculations easily on my laptop.
At this point I feel it's probably necessary to write a disclaimer of sorts...
You can try the following at home, however i cannot be held responsible for any damage to, or loss of, life or property that arises as a result of connecting either yourself or your oscilloscope to the mains supply.
If you look in the user manual for your 'scope it probably advises against connecting it to the mains without using a "differential isolating probe rated for mains use." I leave it up to you as to whether or not you follow the manufacturer's advice.
A quick summary so there's no doubt; mains voltage is dangerous and can kill you.
As I didn't have a differential probe immediately to hand, I decided to improvise...
Using a 10x probe, it is therefore necessary to scale the voltage to below +/- 200 V pk
The nominal voltage of the UK mains supply is 230 V RMS. To give a bit of a safety margin I have assumed that the mains supply is running at its upper limit of 253 V. (The specification for the UK mains supply voltage is +10% / -6% so the voltage can be anywhere from 216.2 - 253 V RMS)
253 V RMS = 357.8 V pk
I decided to use a simple voltage divider to achieve the desired scaling effect. The linked website contains a calculator that lets you plug in parameters and calculates the output voltage for you.
I selected an R1 value of 360 kOhms and an R2 value of 470 kOhms to keep the current and power dissipation to a minimum.
The resistors are metal film, have a tolerance of 1% and are rated at 0.25 W.
The load impedance of my 'scope probe is 10 MOhms.
For a voltage input of 357.8 V pk I will get a voltage ouput of 198.56 V pk.
So let's take some measurements....
I configured the Picoscope software to accept a x10 probe on channel B, input voltage +/- 200 V with a 10 ms/div timebase.
I also configured it to trigger on the rising-edge zero-crossing of the signal, so that it will display 5 complete cycles nicely on the screen.
Some good features of the Picoscope software are "maths channels" which mean you can easily scale your input signal back to its real value, and "measurements" which allow you to easily measure things like Max/Min, True RMS, Frequency, Pulse width, etc...
So here we can see the voltage of my mains supply...at the bottom of the screen is the True RMS calculation.
Of note is the rather poor shape of the voltage waveform; displaying classic flat-top harmonic distortion.
A quick look with the FFT shows the harmonic content of my mains supply nicely.... this is to 2 kHz (40th harmonic), y-axis is dBV.
So voltage is quite easily measured...how about current?
I have a Robin K2413F clamp meter which has an 200 mV AC output (0-200 mV RMS representing the selected range on the clamp meter). So I can simply connect the output to another channel on the 'scope and measure current as well.
I have not yet really contemplated how to get a current waveform into a microprocessor, but I suspect I will end up with some sort of current transformer and some circuitry to convert/scale it down to a suitable range for connection to the device.
Starting with something nice and easy, a lamp...
I have added a new trace, in green, to show the power waveform. Note that the waveform is always positive, as the voltage and current waveforms are in phase with one another.
From the measurements at the bottom of the screen we can see the following information.
Average Voltage = 245.9 V RMS
Average Current = 0.0567 A RMS
Average Power = 13.84 W
A quick cross-check with a calculator...
245.9 * 0.0567 = 13.94 W
(An error of approximately 1%...which is not bad when you consider the accuracy of my 'scope probe is probably +/- 2%, and the accuracy of the Robin clamp meter is unknown.)
As a lamp is a purely resistive load, the real and apparent power are the same and thus the power factor is 1.
That's enough for now....next time I will connect some different items to the setup and attempt to take some displacement power factor, and real power factor measurements.