A number of our projects require accurate monitoring of voltages. Here we explain the numerous techniques for measuring voltages, both DC and AC, highlight some of the multitude of integrated circuits available and list the pros and cons of various techniques.
To measure power (and hence measure energy) within electrical systems, we need to know the voltage and the current. Power equals the voltage multiplied by the current (P=V x I). We have written information on measuring DC current, in this post we will be writing about measuring voltage, both DC and AC.
Accurate measurement is obviously beneficial, but higher accuracy comes with a higher cost and there are also some fundamental limits and hardware limitations to how accurate we can measure.
In this page I'm hoping to describe the main requirements for reasonably accurate voltage measurement and also a number of techniques to do this and a number of components and integrated circuits which are used to perform this function. I am assuming that this data will be read by a micro-controller (a digital device).
Voltage is sometimes called ‘potential difference’, and corresponds to the 'potential' or ability for electrons to flow around a circuit. So measuring voltage always requires direct connections to the two terminals we are trying to measure.
Often (especially with high voltage systems - above 55V DC has the potential to provide a dangerous electric shock) we require ISOLATION, hence I will break these methods down into non-isolated and isolated.
Non-isolated means that the input and output voltages are referenced to each other in some way. Generally they share the same ground connection. While simple to implement, there are over-voltage and safety issues for higher voltages.
We could measure the voltage by directly connecting it to the input of an Analogue-to-Digital Converter (ADC), such as those within microcontrollers. These have a maximum input of 5V or 3.3V, hence why we cannot directly attach the 20V signal, or else we would overload and damage the measuring ADC.
This method is only useful for low voltages and is not really the subject of this article.
A potential divider is a simple way of measuring voltages. The input voltage is measured between ground and the top point of two resistors in series. The output voltage is measured across the bottom resistor. This reduces the voltage of the output by a factor which relates to R1 and R2, the top and bottom resistors.
Let’s say the input voltage is 20V. The output voltage will be:
Vout = Vin (R2/(R1+R2)
So in this example the output voltage will be:
Vout = 20V x (100k/(680k+100K) = 2.564V
On the circuit diagram above we can see two additional elements. These are C1 and D1.
C1 is a filter capacitor. This will remove high frequency ‘noise’ in the signal. It might not be required.
D1 is a zener diode. A zener diode will short when a voltage greater than its rating is applied. This is protection to stop any over voltage problems. This is done to protect any equipment downstream of the zener diode, such as the microcontroller. The resistors in the potential divider mean that only a very low current will flow, even when shorted out, hence this will limit the voltage. (This is not done to stop any dangerous high voltages for the safety of people, as these voltages could still appear if, say, R1 failed to short circuit). In this case a 5.1V zener diode is used to protect a 5V input to a microcontroller.
If we are measuring relatively high voltages it is much better to have a totally isolated signal. This stops any problems with over-voltage being applied to our measurement device.
Also, 55V is known as the voltage above which dangerous current can flow through the skin. Hence anything above 55V is potentially dangerous. Both PV (photovoltaic) voltages greater than 55V and AC voltages from standard AC plug sockets have the potential to be dangerous.
There are a number of ways to implement isolated voltage measurements:
Transformers consist of two electrically isolated coils. Any magnetic flux is linked via the ferrite core. These provide electrical isolation, but only for AC signals.This was my first idea when I needed to test an AC mains voltage. I decided to test using a small transformer to measure AC mains voltages.
I used these 240V input 6V output transformers. I applied 240V AC mains to the inputs, which was measured using a high voltage scope probe.I also measured the output of the transformer. It was not quite what I hoped.
The transformer used is above. It is a 1.5VA rated unit. I was expecting a 6V AC waveform output. 6V is the rms (root mean square) output voltage, so I was expecting a peak of 6 x √2 = 8.485V.
I measured the input AC voltage waveform, shown in blue. With no load, the output voltage is shown in yellow. This output voltage is +/- 6V AC, but it can be seen that it is slightly out of phase and slightly distorted compared to the input.
These are screen shots of my digital oscilloscope. The yellow line (output) is not a perfect version of the blue line (input).
This shows more detail of the voltage with the time series expanded. We can see the phase change (the zero crossing is not in the same place) and the flattened output waveform.
This waveform shows a close up of the peak, to show the difference between the input (blue) and output (yellow) waveforms. This shows the waveform flattening.
In order to compare these results with other methods, I rigged up an isolation amplifier (more details below) to measure the AC waveform. I used exactly the same measuring devices (a low-end RIGOL digital scope). The results can be seen in the following graphs - again the input AC waveform is blue and the output waveform is yellow.
The input (blue) and output (yellow) waveforms are exactly in phase. These is no flattening of the waveform. The output waveform is an identical version of the input, apart from the magnitude.
This shows that the input and output waveforms are identical.
To conclude these tests, when I was first looking to provide an isolated output voltage from an AC mains waveform, my first thought was to use a transformer. These tests show that there are issues with non-linearity and phase change when measuring with a transformer. Hence I cannot use a transformer to accurately measure AC voltage.
My magnetic theory is not good enough to explain exactly why there are these differences. It could be due to magnetic saturation, parasitic capacitance and inductance in the coils or problems with the test equipment. I tired to exclude test measurement problems by comparing using the same test equipment. If you have any ideas on this then please add to the comments section.
Hence I looked for other methods to measure voltages...
Another technique is to convert the voltage into a current. We know that V=IR, so using measuring the current through a known resistance will give us the voltage. This current can be measured using the hall-effect.
One problem is that to get a decent current signal, we need a relatively large current to flow, which means relatively high power dissipation. This is in the region of 3W, which, for a renewable energy system, is a high energy loss, if it is constantly being measured.
Only a handful of manufacturers and hence relatively high cost.
One example of hall-effect voltage measurement is the LV-25-P transducer from LEM, which provides 2500V DC isolation between input and output.
The last form of isolation considered here is the isolation amplifier. This is a special type of integrated circuit which has two electrically isolated sides. The input voltage is scaled to suit the isolation amplifier (2V and 250mV maximum in the cases below). This input voltage is passed from one side of the isolation amplifier to the other via an optical connection. The optical output is received on the output side and converted back into a voltage signal. This output voltage is linearly proportional (around 0.1% non-linearity) to the input voltage, but electrically isolated.
Isolation amplifiers can be very expensive. I searched for various different devices and concluded on the following (although I am sure there are many others):
For DC measurements I found the ACPL-C870 device from Avago Technolgies. This costs around £5.43 + VAT from RS. This device requires a 5V isolated supply for both input and output stages. The input is in the region of 0-2V (using a potential divider) and it has unity gain, hence the output is an isolated 0-2V output. It works with DC voltages, although the input cannot go below 0V, hence is not easy to use with AC input voltages.
For AC measurements I am using the AMC1200 from Texas Instruments. This is harder to find, but is available from DigiKey at £4.84 + VAT. This can be used to measure AC waveforms as the input voltage can go + or - 250mV. Hence the input AC voltage can be reduced to +/-250mV using a potential divider. There is a x8 gain within the device and the output is 2.55V +/- (the input signal x 8). This means the output can be measured using a single side referenced DC ADC.
Both of these devices require an isolated 5V voltage supply for the input stage. This can be provided from the waveform under test, as shown in the data sheets, but I prefered to provide and isolated 5V supply using a DC/DC 5V to 5V converter with >1000V isolation. These are now relatively easily and cheaply available. I used the MEE1S0505DC from Murata technologies. This costs around £4.00 + VAT from Farnell. Lots of other version are available.
The waveforms from using an AMC1200 can be seen above in the comparison with the transformer voltage measurement.
As mentioned in the DC current measurment article, There are two main aspects to accurately measuring a varying signal, no matter what the signal. These are the sampling frequency and the resolution:
The sampling frequency is of great importance if we are to accurately monitor a waveform. For example if we took only one temperature measurement a day, at 7.47am, we could not say anything about the changes through the day. If we measure on the same day for 100 years, though, we might be able to say something about changes through the year. So it depends on what kind of data trend you are interested in.
The mathematics of this were done by Harry Nyquist and hence we have the Nyquist rate. This states that, to get all the information from a waveform, we must sample at a frequency at least twice that of the waveform. For example - we want to listen to music, which has audiable frequencies up to 20kHz. To cover this we must sample at a frequency of at least 40kHz. Those who have recorded music into a computer will know that the sample frequency used is generally 44kHz. Any less and you will loose information.
Voltage can generally be measured at all times. If we were to measure the voltage at a plug socket we will be able to measure 240V AC, but zero current if nothing is plugged in. When a load is switched on then the current will flow and hence power (V x I) is drawn. We generally see the voltage drop slightly (due to cable voltage drop) when supplying a load.
For some basic electrical systems we can assume that the voltage is constant, and then just measure the current. But this does not give very good accuracy. The voltage will vary quite considerably as loads are varied. In a typical 12V DC lead acid battery system, we will definitely see a voltage range of 11-14V DC, possibly more. Hence to make accurate power measurements we must take accurate voltage measurements.
To get good power information we must also take the voltage measurement at exactly the same time as the current measurement. This is especially true in AC systems, which also have power factor (which is out of the scope of this article).
This relates to the fact that we are converting an analogue signal into a digital signal. (This is sometimes called quantization). Digital signals can either be on or off. Analogue signals can be anything at all and can vary infinitely within their range. We are trying to get this varying analogue data into our digital device (the micro-controller). In order to do this we use the concept of levels (also called quanta).
Say we have a sine wave signal varying from 0 to 5V. Lets say we only have one bit resolution. The digital representation can only be on or off. If we set the level at 2.5V then we will see the digital signal to be 0 then 1 then 0 then 1 as the waveform goes above and below 2.5V. You can see that we do not get much detail from the signal. This might be enough data to do what we want, but generally we use more levels. The more levels, the higher the resolution and hence the better data accuracy.
Adding an extra bit to the resolution increases the resolution by a factor of 2. Hence 1 bit = 2 levels, 2bits - 4 levels, 3 bits = 8 levels. This quickly multiplies up and at 8 bits we have 256 levels or at 10bits we have 1024 levels. A typical micro-controller (such as a PIC 18 series, or the Atmel chip in an Arduino Uno) has 10-bit accuracy. Some have 12, 14 or even 16 bits. If you go to higher numbers of bits this puts more work onto the microprocessor, so you can also use special analogue to digital chips (ADC) which process the data and sends it to the micro-controller.
When measuring current, we are usually measuring very small voltages. These have the potential to be corrupted by other very small parasitic signals. These can be broken down into offsets and noise.
Although converting the signal from analogue to digital will mean a loss of information, it also means we can apply techniques to ensure the signal does not get corrupted by noise. Hence I try to convert to digital as quickly as possible.
Noise is everywhere. It comes from the physics of electrical devices and from interference of the many different man-made and natural electrical and magnetic waveforms. There is lots of information about noise and reducing noise levels, although it is sometimes a bit of a dark art.
I try to keep noise to a minimum by:
This is a complex area, so I will not go into too much detail here. Generally good layout and circuit design will ensure relatively low noise.
Offsets are when an additional signal is added to the waveform we are measuring. They generally occur when the signal has passed through some other active component, such as an op-amp. Lets say we are measuring a 0 to 5V analogue signal using a 10 bit ADC. This gives us 2^10 levels = 1024 levels. Each level equals 5V/1024 = 0.00488V, or 4.88mV. Hence any offset greater than 4.88mV will change the signal enough to change the number read by the microprocessor. The main reason this might be a problem would be if the signal is taken through an operation amplifier and the operational amplifier has some offset, or cannot get all the way to the ground rail. You can check out the offset voltage using the op-amp data sheet. For example, the offset voltage on a standard 741 op-amp is +/- 15mV, which could give an inaccuracy of over 3 levels. (Note: there is the option to null the offset on lots of op-amps, but this needs individual calibration and additional components). I try to use single supply rail to rail op-amps with an offset of less than 3mV.