Current and voltage are probably the most important electrical properties in any electrical circuit. They are the cornerstones of every other parameter and the first properties you look at when designing a circuit.
As you can imagine, for dynamic circuits, it is quite important to know the voltage and current at certain points in order to control the device operation or trigger certain action as well as calculate the heat dissipation.
Like voltage, current can a constant value (DC current) or a varying waveform oscillating at a certain frequency (AC current).
To measure current there are two popular ways of doing it: by measuring voltage drop on a resistor or by sensing a magnetic field in a conductor.
In this article, we will focus on how to sense a magnetic field in a conductor with the idea of measuring AC current using a tiny, cheap circuit.
What this module is good for
This module is good for measuring AC current from the mains for currents over 1A and applications that require total isolation between the measuring circuit and the measured current and low current measurement accuracy.
It was designed to be interfaced with a microcontroller that can then open a relay if the measured analogue signal is bigger than a predefined threshold value.
System design and how it works
This simple module has two main components: a hall effect sensor and a buffer/amplification/filtering stage.
Hall Effect Sensor
A Hall effect sensor is a device, in this case an IC, that can output a voltage proportional to the magnetic field passing through the component.
In this application, we are using it to measure current, as AC current creates a varying magnetic field that can be picked up by this sensor, however, it can be used in any other application that you might require to measure a magnetic field such as in electrical motors or devices that use magnetism as feedback for controlling direction and speed.
The selected IC was the DRV5053 from Texas Instruments.
This little guy comes in a SOT-23 and TO-92 package and has different sensitivities to choose from.
The only mandatory component it needs as with most ICs is a decoupling capacitor next to the Vcc pin.
This stage is required basically because we are using this hall effect sensor without a concentrator. A concentrator is a ferrous component with a cylindrical or squared shape that goes around the conductor.
As the name implies, the concentrator concentrates the magnetic field in a smaller area. This is good in hall sensing because you get cleaner and more accurate measurements of the magnetic field of interest.
Here is a typical example of a hall sensor in combination with a concentrator taken from Allegro Application Note 296096.
In this application, we are placing the sensor into the conductor’s magnetic field without any concentrator, therefore, for low currents, the sensitivity of the sensor is not high enough to pick the magnetic field created by the current passing through the conductor.
Another important part from this stage is that we can add a filter to attenuate all frequencies above 60Hz (mains frequency) and placing a buffer between a sensor and an MCU is always good practice as it electronically separates one stage from the other, this prevents overloading the sensor and protects the MCU in case of an overvoltage event, given that an OPAMP will be more robust than an MCU.
C1 and C5 – Decoupling capacitors for the opamp and hall sensor
U1 – Hall effect sensor
R1 and C3 – Make an initial low pass filter to attenuate frequencies above 330Hz
C4 – Removes the 1V DC offset from U1
R2 and R3 – Gain resistors for the OPAMP. These values will need to be selected according to your application gain needs
R4 and R5 – Voltage divider to create a DC offset for the output signal
U4 – Rail-to-Rail general-purpose operational amplifier
R6 and C7 – Single pole low pass filter set at a -3dB corner frequency of 72Hz
As stated in the beginning, this module is used just to sense if the current going through a conductor has passed over a predefined threshold, it does not provide accurate current readings. If this is what you want then adding a concentrator will be the way to go.
It is important to place this module in very close proximity from the conductor and away from other magnetic field sources such as other power cables or transformers. Also, take into account sensor positioning by following TI’s application guidelines found on the datasheet:
Here’s a quick way to read the analogue signal from the sensor using the dsPIC33E ADC. This code samples the analogue signal 60 times with a 2ms break between each sample and then takes the max value from the sampled signal.
delay_ms(2); //Set sampling frequency which has to be no bigger than 8ms (1/120Hz)
currentADCbuff[ix_CurrentADCbuff] = ADC1_Channel0ConversionResultGet();
int maxValue = currentADCbuff;
maxValue = currentADCbuff[ix_CurrentADCbuff];
currentPeak = maxValue;
In this example, I have powered the module with a 3.3V external supply and connected an oscilloscope probe to the output of the module.
I have also connected a 100ohm 200W power resistor directly into the 110VAC mains line in order to draw around 1A of current.
Finally, I placed the sensor right next to one of the AC lines.