ACS758: How to measure up to ±50A with this magnetic sensor. Use this sensor to measure super high current
safely in the presence of hundreds of volts. Learn how to use this
chip safely with any microcontroller.
ACS758 : Is a magnetic Hall effect sensor that :
Can measure very high current ±50A.
Capable of safe measurement inside high voltage systems (up to 700Vrms).
For 240Vrms mains can measure to 8kW (240Vrms x 35Arms).
Cannot measure below 60W (240V x 0.25A) - due to the magnetic noise effect.
The chip is safe to use as its built in isolation means mains voltage
cannot accidentally arc across - it is so safe that it is rated for use
in the presence of 700Vrms.
This chip uses a magnetic hall effect
sensor to detect current so it has no direct physical connection from
the low voltage side to the high voltage side - making it an extremely
safe. It has so-called galvanic isolation built in.
This is talking about design safety where an electrical connection
(arc) can be made if elements in a circuit (high side to low side) are
too close.
Of course it is only safe for you if you enclose it within a sealed enclosure.
In the image
below you can see the high side voltage at the top (thick wires) and the
low side voltage at the bottom - the analogue outputs and low voltage chip power supply
wires.
ACS758 module
Usually you
use an opto coupler to separate high voltage and low voltage systems to
provide isolation between the dangerous and safe parts of the circuit but for the ACS758 you don't need that. The hall effect interface means the high voltage is separated from low voltage automatically with isolation
rated for voltages up to 700VRMS!
It can therefore safely measure high volts without risk of the high
voltage arcing over to the low side system - you still have to ensure
that the whole module is enclosed in an electrically safe unit. If you
are not experienced in high voltage safety don't do it.
The lowest specification device can measure ±50A - this is the one usually
found on breakout boards - and the one used here.
[1] Occurs when device is subjected to high or over current. [2] For 3V3 contact AllegroMicroSystems for accuracy data. [2a] The device is Ratiometric. [3] High temp = 25°C ~ 150°C, Low temp = -40°C ~ 25°C.
[*] If your module has a TLC2272 dual opamp, then the supply must be >=4.4V,
or use output 'OU1' and ignore the opamp output!
ACS758 Markings
The chip I have has the markings:
ACS758LCB-050B ( This is the default chip on breakout boards ).
The 050 means that the current capability is 50Amps. You can get other versions up to 200Amps!
The B in LCB means bi-directional i.e. ±50Amps -
You can get unidirectional (LCU) parts where you can only measure
current in one direction.
The L in LCB can be changed to K or E. It refers to the operational temperature range.
Module breakout boards
There are two flavours of breakout boards:
A three pin interface.
A four pin interface.
If you have a four pin interface it means on the back of the module
there is a buffer amplifier chip (TLC2722C). In addition there is a
low-pass capacitive resistive filter to filter out noise (which is
unavoidably generated from all hall effect devices) - but its rubbish - see below. The pin labelled
OU1 connects to the filter, while the pin OU2 buffers the filtered
output with a unity gain opamp configuration.
Warning: The minimum supply voltage for the TCL2272 (opamp) is 4V4.
TIP: Some boards are fitted with MAX4213 which is capable of 3V3 or 5V operation - but these are hard to find.
Note: Use OU1 for 3V3 operation i.e. ignore the opamp output.
So, you should use the OU2 output so that subsequent circuits do not affect the filter operation.
If you have a 3 pin interface it simply means there is no buffer
amplifier and you simply get the raw analogue output directly from the
ACS758 with no low pass filtering.
This is the rear view of the four pin acs758 module:
You can see the TLC2272C opamp used as a unity gain buffer.
The filter capacitors are R1 and C1. R1 is 120Ohm and C1 is probably
around 100pF (from other schematics) so the corner frequency is : ~13.2MHz - seems pointlessly
high to me!
TIP: The opamp
buffer is pointless unless you increase the capacitance (to reduce the
corner frequency). The TLC2272 is 4V4 only so for 3V3 systems use OU1.
If you don't have an opamp buffer on your board - who cares? - it does
virtually nothing!
ACS758 Block diagram
How the ACS758 Works
The ACS757 generates a voltage proportional to the magnetic field
caused in a conductor using the "hall effect". For chip types that are
bi-directional (like the one used here), the output voltage is set to VCC/2.
Changes in the magnetic field
cause this value to rise or fall from this quiescent point, indicating
positive or negative current flow. This allows AC current to be measured
and also allows large currents to be
detected.
Note: The device has an offset that you should null out using software - for a.c. measurements or calibrate for d.c.measurements.
Ratiometric Operation
The ACS75x devices are ratiometric meaning that as the power supply
changes so the ouput changes by the same ratio. This is why the zero
current output sits at VCC/2 i.e. the output does not depend on the
supply voltage value.
The device should have similar accuracy at different power supply
voltages (but this could be wrong at the upper and lower ends due to
opamp saturation). In the specification table in the datasheet and above
(see [2][2a]), it suggests contacting allegromicro systems if using the
device at any other voltage than 5V. I suspect this simply because they
have not tested it at other voltages.
A simple way to verify would be to measure a high current at 5V
operation and then compare to 3V3 operation. If they give the same
results then there is no problem.
ACS758 Accuracy
The basic accuracy of the device is specified for high temperature and low temperature as follows:
High temp = 25°C ~ 150°C, Accuracy is -1.2%
Low temp = -40°C ~ 25°C, Accuracy is +2.0%
For room temperature take the worst case accuracy of 2%, if feeling pessimistic and -1.2% if feeling optimistic!
ACS758 Resolution
The sensitivity of the device is 40mV/A, so every Ampere change
results in a 40mV output change. The resolution should be determined by how
many bits your ADC can measure but also see "Effect of noise on resolution".
If you use the Arduino ADC (10bit) then the resolution of the ADC
device assuming a 5V reference is 5/pow(2,10) = 4.88mV. So the basic
ampere resolution will be:
Note: Using the Arduino ADC results in a resolution of 122mA.
Warning: 122mA is not the resolution the device can support.
This resolution is not too bad if you are going to measure up to 50A. As a percentage of full scale it is:
(0.122/50)*100 = 0.25%
Using the Arduino ADC has better resolution than the
device can output. The only reason for using an ADC other than the Arduino ADC is for better gain and offset characteristics.
Effect of Noise on Resolution
Hall elements seem to have quite high noise output due to thermal and
shot noise, so the effective resolution is limited by this noise.
Dividing the noise by the sensitivity provides the smallest current that
can be measured by the ACS758:
Smallest current resolution = Noise/Sensitivity
Smallest current resolution = 10/40 [mV]/[mV/A] = 0.25A
You can see that the noisy value is 1/4 of the sensitivity so resulting in 0.25A.
This is specifically for the ACS758LCB-050B device.
Warning: The smallest current this chip can measure is 250mA.
Note: Other ACS7x chips have different noise/sensitivity characteristics.
In practice, for a 240V AC system it means you can't see device power
usage that consume less than 0.25*240 = 60W. This value changes to 30W
for a 120V a.c. system. The noise floor of 10mV means the chip can only
see changes greater than this value.
Looking at the different chips available - this is in fact the highest resolution one! See Conclusions for a different chip - and better resolution.
The INA219 has far better resolution for lower currents (3.2A ~ 15A). However the INA219 can not measure with voltages higher than 26VDC.
Test Kit Setup
It is important to safely measure high voltage so modifying an
existing case is the best idea. Here a mains timer unit was modified by
stripping out the timer part and putting the ACS758 in the space left.
The switch mechanism was left in place for easy switching of the power
line (through the micro switch).
The low volt digital wiring was taken out of the top of the case well
away from any mains voltage thus providing the Arduino access to the
analogue interface.
Internals of the mains timer
Mains timer with ACS758 installed
Note on the back of the module is a TLC2722 opamp that buffers OP2,
OP1 is from a capacitive RC filter (that may have wrong values 150R,
100pF - from a web schematic) - this filter output goes into the opamp
that is used as a buffer amplifier.
The diagram above does not show it but the plastic switch mechanism
was put back in to allow the microswitch to operate. Its useful having
an on/off switch. You should make sure the microswitch can handle the
max current.
Case closed, ACS758 installed
Measurements
The following screenshots show various current waveforms from zero current (for noise assessment), a
42W bulb and a blower heater on full power. As you can see even a 42W
bulb hardly registers above the noise - you can see a sine wave so it
does register - but only just.
ACS758 Zero input waveform
For zero input you can see that waveform is below centre. The offset
is -10mV (delta y = -20mV from cursors) at zero current (for this
specific ACS758 device). You can also see there is no current flow as
the waveform has no A.C. component.
ACS758 42W Bulb Waveform
The following waveform is for a 42W Bulb and barely registers above
the noise. The delta y of the cursors shows a peak to peak signal of
approximately 38mV.
So the peak voltage is 38.0/2 and peak current is 38.0/2/40 = 0.475.
Irms = 0.475/sqrt(2) =0.34Arms. So Power is 240Vrms * 0.34Irms =
80W.
This result looks a little off (about 100% off!) - the reason is
that the cursors are set to the outer noise levels and because the
signal is slow small compared to the noise, the noise result
significantly affects the result.
The following waveform shows the cursors centered in the middle of the
noise. To achieve this in a microcontroller either use an RC smoothing
circuit (accounting for the internal resistive load of the chip - 4k7)
or buffer it a and add a filter afterwards, then another buffer opamp.
An alternative is to use the Arduino Filter library saving any extra
hardware.
Here delta y is 23mV. So So the peak voltage is 23.0/2 and peak current is 23.0/2/40 = 0.288.
Irms = 0.288/sqrt(2) =0.2Arms. So Power is 240Vrms * 0.2Irms = 48W.
This is as close as you can get visually using the oscilloscope cursors. Smoothing would help.
ACS758 Blower Heater
The following waveform is for a domestic heater and shows that the
ACS758 is really only useful for measuring very high currents:
Because the noise is low compared to the actual signal, it is ignored
and the maximum and minimum measurements can be used instead.
Max - Min = 430 - -445 = 857mV.
So the peak voltage is 875/2 and peak current is 875.0/2/40 = 10.93.
Irms = 10.94/sqrt(2) =7.57Arms. So Power is 240Vrms *7.57Irms = 1817W.
ACS758 Maximum power
For practical systems it is useful to fix the voltage to the local
value (240Vrms for UK and 120Vrms for US) and then work out the rms
current and then the power used:
The maximum power this chip can measure (±50A
chip version) is:
The result you get from reading the analog input pin is a
continuously varying input value that changes from maximum to minimum at
a rate of 50/60Hz. To get the RMS (Root Mean Square) Current value,
requires a processor to identify the maximum and minimum values.
Note also that this max. and min. value should be periodically reset
in case the unit lowers its power level usage. If this happened (and no
reset was made) then only the previous high values would be used as the
output to indicate current being consumed!
Improving Operation with filters
Initial thoughts on making the chip work with low level currents mean
you'll want to filter the output. The recursive filter below filters
noise and provides a better measurement at low currents but affects the
higher current output too much.
After testing two filtering operations were compared against zero filtering:
Ten point rolling average.
Recursive averaging.
It turns out that you should not filter the input signal at all. The
reason is that the filter will average out the peak value pushing it
down and will be more pronounced at higher values.
At the higher values where 10Amps are being consumed using a
recursive filter with weight factor 0.4 (seemed best for filtering low
output), changes the output from 10.6A (peak) to 9.6A (peak) ~ 10%
difference.
Warning: Averaging using an algorithm is a bad idea (peak reduction).
If you don't filter the output then the error is due to the noise
from the device. Since this is 10mV and the 10.6A signal was from 850mV a
1.1% error.
Critical Measurement
For A.C. current measurement the critical parameter is the peak value
as this results in peak current and therefore rms current (average
current). In order to measure it as stated above filtering should not be
done as it drags down the peak value.
There are two things that affect the measured output:
Arduino Reference.
ACS758 Current Sensor Output range.
The other critical parameter is the Arduino reference voltage.
Assuming that the reference is 5V is a bad idea. On my Arduino Nano the
voltage is 4.7V so it is already 6% inaccurate.
TIP: It is critical to use a known reference for accuracy.
ACS758 Output Voltage Range
(ACS758LCB-050B)
ACS758 output voltage
ACS758 Delta from VCC/2 (V)
Ipeak (A)
Power (W)
2.5V + 0.01
0.01
0.125
21
2.5V + 0.1V
0.1
1.25
212
2.5V + 1V
1V
12.5
2121
MAX 2.5 + 2V
2V
50.0
4242
Note also
that the Arduino ADC is 2LSB inaccurate (see datasheet) anyway so using
an external ADC may be better.
For the bidirectional devices (used here) the full AC waveform is
imposed on a VCC/2 level. The peak value is detected by storing maximum
and minimum values. This is then halved and calculations made.
The dynamic range is affected by maximum current allowed and can be improved (see next).
Improved Accuracy using Single Ended ACS758
When measuring an A.C. current you only need the peak current. This
is detected by measuring the minimum and maximum values. The difference
is then halved. If you are only interested in AC current then having the
full waveform just reduces the ADC resolution by half.
Since you can assume that the excursions are equal either side of
zero it makes sense to use the devices that only show positive current
as an output. In the datasheet the unidirectional +50A device has a
sensitivity of 60mV/A (compared to 40mV/A for the bi-directional one)
i.e. it has improved output per Amp therefore it is more sensitive.
Example measurement Sketch
The following example uses the ACS758 for AC current with an Arduino
Uno or Nano. It simply reads the analog voltage from the chip into A0.
This example measures current over a 1 second interval extracting
maximum and minimum values. It then calculates Ipeak and power (assuming
a constant supply voltage - here 240V).
Recursive averaging is used here only to decide if the signal is high
enough to measure. Even then, low power devices will not show correct
current usage (resolution is too low) since the noise signal is comparable to the wanted low power output signal.
You must measure the reference voltage to get anywhere near an
accurate output - enter it into the program. Preferably use an external
ADC and external good reference voltage.
// acs758
//
// Copyright: John Main
//
// Only none allows correct current reading at high current.
// The noise value at this level is ignored as it is
// small compared to the signal.
//
////////////////////////////////////////////////////////////
// IMPORTANT: You must measure the power supply
// or use an external reference.
//
#define MEASURED_VCC 4.70
#define ACS758_SENSITIVITY 40e-3 // 40mV per AMP
#define ACS758_NOISE 10e-3 // 10mV noise
#define ACS758_OFFSET_LIM 35e-3 // +/-35mV Max offset.
#define MAINS_VOLTS_RMS 240 // 240 or 120 Usually.
#define V_PER_LSB (MEASURED_VCC/1024.0)
#define ACS758_NOISE_LSB (ACS758_NOISE/V_PER_LSB) // Noise in LSBs
#define MIN_LSB (ACS758_NOISE_LSB*1.5) // Ignore system noise
// ACS758 Starts at Vcc/2
staticintoffset=512;// Calculated at start.
///////////////////////////////////////////////
// Returns offset = average value.
intget_offset(void){
longavg=0;
for(inti=0;i<200;i++){
avg+=analogRead(A0);
delay(1);// Let analogue settle.
}
returnavg/200;
}
///////////////////////////////////////////////
// Store max min
//
voidassign_max_min(floatval,float*pmax,float*pmin){
if(*pmax<val)*pmax=val;
if(*pmin>val)*pmin=val;
}
///////////////////////////////////////////////
voidsetup(void){
Serial.begin(115200);
Serial.println("ACS758...");
offset=get_offset();
Serial.println("Offset ");Serial.print(offset);
}
//////////////////////////////////
voidloop(void){
staticunsignedlongupdate_time_was=millis();
staticfloatnmax=0,nmin=0,rmax=0,rmin=0,y=offset,w=0.4;
inta0;
a0=analogRead(A0);// Don't remove offset.
delay(1);// Let analogue settle.
// Recursive averaging.
// Used to detet low level signal in noise.
y=w*a0+(1-w)*y;
if(nmax<a0)nmax=a0;// No averaging.
if(nmin>a0)nmin=a0;// No averaging.
if(rmax<y)rmax=y;// Recursive averaging.
if(rmin>y)rmin=y;// Recursive averaging.
if(millis()-update_time_was>1000){// 1 sec. update rate.
update_time_was=millis();
// No averaging.
int__max=nmax;
int__min=nmin;
nmax=offset;
nmin=offset;
// Recursive averaging.
int_rmax=rmax;
int_rmin=rmin;
rmax=offset;
rmin=offset;
floatnavgIpeak=((__max-__min)/2*V_PER_LSB)/ACS758_SENSITIVITY;
floatnavgIrms=navgIpeak/sqrt(2);
floatnavgPower=navgIrms*MAINS_VOLTS_RMS;
// Output
if(_rmax-_rmin>MIN_LSB){// Ignore too low
Serial.println("\n------");
Serial.print(" max");Serial.println(__max);
Serial.print(" min");Serial.println(__min);
Serial.print(" Peak Current ");Serial.print(navgIpeak);
Serial.print("A\n Power ");Serial.print(navgPower);
Serial.println("W");
}else
Serial.println("Too low");
}
}
Conclusions
The ACS758 comes into its own when measuring very high currents, when
the current is significantly higher than the internal noise which
limits the available resolution. The minimum current resolution is 0.25A
for this device.
You will struggle to measure anything with devices that consume
anything below ~60W - for the minimum current resolution you need a
device with power usage greater than 0.25*240Vrms = 60W. For instance
you won't see a measurement for an 11W
LED bulb!
In a 240Vrms system the 50A version can measure up to 8kW, and with
the 200A version you can measure up to 33kW. If using 120Vrms then the
power measurement capability halves.
If you need lower current measurement then use the ACS712,
that can measure ±5A, ±20A, ±30A with different chip versions. If you
need accurate current at bench level voltages (below 26V) then use an INA219.
A PIR sensor lets your Arduino sense movement without contact. This tutorial covers PIR sensor basics, connecting one to an Arduino board and coding a motion detector.
Arduino Hall Effect Sensor: Add magnetic sensing superpowers to your Arduino projects with an easy-to-use hall effect sensor. With full code and layout...
Get started with an Arduino humidity sensor using the DHT11, which reports both humidity and temperature. Complete guide with full code for using this sensor
Comments
Have your say about what you just read! Leave me a comment in the box below.
Don’t see the comments box? Log in to your Facebook account, give Facebook consent, then return to this page and refresh it.