If you need to measure the current from an AC source, a current transformer can be a low cost, accurate option. You can find current transformers designed specifically for anything between 50/60Hz power line applications and much higher frequencies that are more suitable for industrial/scientific machinery or process monitoring. Current transformers are non-contact and non-invasive, meaning that you do not need to run AC power through your circuit board for many models. Instead, a wire is run through the opening of a transformer, or the transformer itself might open to allow it to snap on a wire.
The wire running through the current transformer serves both as a single winding of the transformer, and as the primary coil. The body of the transformer has tens to thousands of windings which form the secondary coil. Unlike voltage transformers, a current transformer has an inverse ratio. This means that a 1000:1 ratio current transformer will create 0.001A in the secondary for every 1A through the wire that is the primary.
You can find current transformers with winding ratios suitable for measuring from a single amp up to and beyond thousands of amps allowing them to be used in a much broader range of applications than PCB mounted/conducted current sensors.
In this project, we’re going to look at a couple of ways to convert the output of a current transformer into something more useful for interfacing with a microcontroller. At first glance, this seems to be a pretty simple task, but as you go a little deeper, current transformers get a bit more interesting, especially if you haven’t used them before. Therefore, this project is going to be a little more practical and hands-on than some of my previous projects, First, we’ll pull out the breadboard, function generator, and oscilloscope to understand current transformers. Then, we’ll actually build a precision rectifier board to be able to make optimal use of a current transformer with a microcontroller ADC input. You can find the PCB and Schematic files for this project on GitHub.
Basic Output of a Current Transformer
Using Ohm’s Law (V = IR), we can convert the current output from the transformer into a usable voltage. I’m using a Talema AC1010 as the current transformer for everything in this article. For this sensor, a 100 ohm burden resistor will generate a 1V RMS voltage for 10A on a wire through the current transformer.
Having connected the transformer and resistor in parallel, you could simply connect one end of the structure to the ground, and the other to the ADC in order to get your reading. However, this is probably a very bad idea. I only present this schematic to show the simplest way you could see a current transformer in action.
This is what the output on the ADC would look like on my oscilloscope. This is an output from my function generator to simulate a 7amp load, rather than the actual current sensor output—we’ll get to that soon.
There’s a few important things to note here:
- The signal is 2 volts peak-to-peak, but I said it’s a 7 amp (i.e. 0.7V) load!
- The waveform is AC, so it’s +1V to -1V, which a microcontroller will not like.
Current transformers are just converting the current on the line, so your actual current will be the root mean square (RMS) of the waveform. The function generator outputs an almost perfect sine wave, but depending on your load, the current in an actual current transformer circuit may not be that perfect. A rough estimation of current could be determined by reading just the peak voltage, but to get an accurate current measurement, you will need to take many measurements to determine the total area under the curve that is the current draw.
With a 2V peak-to-peak output centered around ground, this is not very microcontroller friendly. We’ll need to do something with the signal to make it more usable.
As the current transformer is simply a floating voltage across the burden resistor, the only way we can have a reference for the transformer voltage is by tying to it ground. Instead of tying it to ground, we can instead tie one leg to a bias DC voltage obtained through a resistive divider. This will provide a DC offset to the AC waveform instead.
This is a simple voltage divider that will have half the 3.3V input at the midpoint between the resistors, yielding a 1.65V DC offset. Now our 2V peak-to-peak waveform should swing around 1.65V for a 0.65V to 2.65V range.
We can show this with the oscilloscope. I’m using some very cheap bulk-pack resistors which don’t give me quite 1.65V at the center of the voltage divider. Blue is the 2V peak-to-peak signal, and yellow is the signal with the DC offset.
I have a 1.1kW heater pad for an upcoming project, if I run it through the AC1010 current transformer and the same resistors, I get an offset voltage sine wave. Note how the waveform is not as perfect as the function generator’s; real-world loads are almost never going to be perfect sine waves.
The downside of this measurement method is that we have offset the voltage of the waveform to keep it within our ADC’s range, and this means there’s a lot of the voltage range which we’re not utilizing effectively.
A relatively low cost modern ARM Cortex microcontroller will have a 12bit ADC, while some newer ones come with 14bit or 16bit ADCs as standard, and some older ones come with 10bit. For this article though, I’ll be working on the premise of a 12bit ADC.
A simple 12bit ADC will give us 212, or 4096 possible values. Applied to a 3300mV range, this gives us a resolution of about 0.8mV. The load pictured above has a total peak-to-peak voltage span of 1219mV, and should be about a 4.5-4.7A load. The 1219mV give us a possible 1523 values for the voltage displayed at our calculated resolution, which translates to about 3mA per ADC value when using our 100 ohm load resistor (remember: it’s RMS!). That’s more than enough for this 10 amp sensor. However, as you start reading larger and larger amperages or use a current transformer with many more turns than the AC1010, this may fall short of your requirements.
Nevertheless, this offset DC voltage is still the simplest way to read a current transformer, requiring only 3 resistors in total. You should also include TVS diodes to clamp the load to ensure it cannot exceed the microcontroller’s maximum voltage rating during a current spike.
The Precision Rectifier
You could use a bridge rectifier to rectify the waveform out of the current transformer, but the forward voltage of the diodes would greatly reduce your current-sensing capability. A diode could easily remove more than half of your current-sensing range, making anything under half the amp range of the sensor unreadable. Even worse, is that a diode’s forward voltages change depending on the voltage, temperature, and other conditions, so your rectified voltage is not likely to be particularly useful.
Instead of a simple bridge rectifier, we can build a precision rectifier using two op amps. A single op amp would give you a half-wave rectifier, which may be sufficient for some amperage measurements. Still, the additional component cost for a full wave rectifier is negligible, so we might as well use it even for situations in which a half wave rectifier would suffice. Precision rectifiers are common in instrumentation applications such as this, and are a fantastic way to generate a usable voltage. As a bonus, since you are using op amps, you can also amplify the rectified waveform while you’re at it.
I’m using a cheap AD8542 op amp which has two amplifiers in one package. Despite how amazingly accurate op amp tuning is these days, having both amps in the same package greatly increases the likelihood of the same gain being applied by both amplifiers, which is important. In my final design, I’ll also be using 0.1% resistors for the same reason.
Finally, I have a simple 600Hz RC filter at the output of the op amp to remove any AC noise that might have been picked up. This filter is of a high enough cutoff frequency that it does not affect the 50Hz signal.
The prototype on my breadboard, however, is using mystery resistors that claim to be 5%, so our results are not quite as accurate.
Notice that the negative wave is a little lower in voltage than the positive one. That’s because the resistors I’m using are not particularly well matched.
As we test this with the heating element as a load, the error is not as noticable. Just as before, blue is the waveform coming out of the current transformer, and yellow is the output of the precision rectifier.
As I am giving the op amp a ground reference (rather than a negative voltage to work with) we have a slight DC offset of 103mV for the rectified signal. This offset is acceptable for my application, as it is consistent and can therefore be programmed into the microcontroller during board testing.
For the same load applied with the voltage offset method, we had 1219mv of signal. Yet, with the precision rectifier and a 2x gain on the output, we effectively have 2066mV of peak-to-peak reading for this signal. We’ve just doubled our resolution!
As this time we’re also able to look at the original waveform with the scope, we can calculate the RMS voltage for the waveform to determine the current draw. The 442.9mV should mean we are pulling 4.429A through the heater. If this is correct, our 12bit ADC gives a current sensing resolution of 1.71mA, which is good enough for my application.
Is The Current Sensor Correct?
The question is, how can I verify the current measurement is correct, or at least close? Every device will have its own tolerance and precision, and the AC1010 datasheet logarithmic graphs make it a little hard to read the tolerance for this part with the 100 ohm burden resistor. Instead, we can calculate what our expected load is and compare this to the measured waveform from the sensor. Ideally, I would do this with multiple loads, but for this article, I’ll just use the one to see if we are even remotely close to the expected result.
Measuring The Heating Element
I used a 4 wire resistance measurement to measure the heating element. After letting my multimeter average the readings for awhile, it settled at 50.262 ohms.
Measuring The Burden Resistor
Considering how bad some of the 10k resistors that I’m using are, I was pleasantly surprised to find that the 100 ohm burden resistor I have been using is 99.983 ohms.
Measuring AC Power
After the surprise of the burden resistor being so close to the labelled value, I wasn’t expecting the same from my AC voltage. Other countries I’ve lived in claim to be 240V but I’ve measured 270VAC at the wall. The UK is 240V +10/-20%, and my house gets 239.632V! To me, that’s pretty amazing.
Putting it all together
Now back to Ohm's law, V = IR, our 239.623V over a 50.262 ohm load means we should see 4.76766A. In the last test with the precision rectifier, we measured 4.429V RMS from the sensor. With the 99.983 ohm burden resistor, this should equate to 4.4297A, meaning we’re about 7% off.
You can buy more precise current transformers, however these are cheap and 10% tolerance is sufficient for my application.
The Precision Rectifier Design
The precision rectifier is a fairly simple design, and very common in precision instrumentation applications. The first op amp inverts the signal, and the reference to ground cuts out the negative voltage, giving us just a positive half rectified signal. To ensure symmetry of the rectified waveform, the first op amp gain is at unity (R3 = R6). The second op amp combines the two signals, and with the resistors R8 and R5 set to 5k and 10k, we double the output voltage.
R2 and C1, as mentioned earlier, form an RC filter on the output.
Maximum Voltage Considerations
The maximum voltage the op amps will be able to output is V+ minus the diode forward voltage. This should be kept in mind during the precision rectifier design. If the gain is too high in an attempt to use the entire voltage range that the ADC can read, you will clip the top of the waveform.
Maximum Current Consideration
You should also allow some headroom for amperage spikes. The actual current loads this sensor will be reading should be less than the 1100W load I applied to it for testing. However, even at full range, this precision rectifier will have about a 2.8V output at the full 10A load. This should be more than sufficient for my application, but keep it in mind just in case it isn’t for your applications.
Let's Design a PCB!
The board design for this project is very simple, as it only has a handful of components and nothing high frequency. It would make a very good first PCB project for a new Altium user.
I’m planning to use 6 of these current transformers in an upcoming project, so I wanted to work on keeping the design as small as possible. I have added a Molex SL 70553 series latching connector to the board, which will make this a practical standalone board for measuring current inside a piece of machinery or other equipment. With the current transformer determining the width, and the connector determining the length of the board, we end up with a 25x25mm area in which to layout the circuitry. I’m using 0603 components to make this project ‘beginner friendly’ to assembly and hand solder. The MSOP-8 version of the AD8542 op amp might go against that somewhat, but it’s also available in an SOIC-8 package, which could easily be fitted into the extra board space. Modifying the design to use the larger IC could make a good exercise for a beginner.
I also added some large 1206 decoupling capacitors to the design. If this board is at the end of a cable, it’s always nice to have a bit of extra onboard capacitance.
With this design being either 50hz or 60hz depending on the country you live in, there are no signals that need impedance matching or any other considerations that complicate the board design process.
The current transformer looks enormous in this 3D view, which really goes to show how small this board is. In reality, the AC1010 current transformer is smaller than I had expected, despite having 3D modeled it to add it to my open-source Altium library.
A Note on the Schematic
If you are planning to use this with a 15A or 20A model of the current transformer, you may want to consider changing the 5k resistor for a 10k resistor, or perhaps an even higher one to ensure the gain of the second op amp stage does not clip the signal. The 5k resistor is well suited for the 10A sensor.
Hopefully, this project has demystified current transformers for you. You can find the PCB design files and schematic for this project on GitHub. The design is free, and open source, so feel free to use it in any way you wish.
About the AuthorMore Content by Mark Harris