Become a subscriber (Free)

Join 29,000 other subscribers to receive subscriber sale discounts and other free resources.
:
:
Don't worry -- youre-mail address is totally secure. I promise to use it only to send you MicroZine.

ACS758

The ACS758 is a very high current capability measuring device that uses a hall effect sensor to detect current.

Because it uses a magnetic field to detect the current there is no direct connection from the measured source to the low voltage side of the circuit. It has so called galvanic isolation built in. 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

thumbnail acs758


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. The magnetic interface provides that automatically and is isolation rated for voltages up to 700VRMS.

It can therefore safely measure high volts. However you must take all high voltage safety precautions when using voltages over 30V. 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.

ACS758 Datasheet

Download the ACS758 sensor Datasheet here.

Allegro ACS758 Specification

(ACS758LCB-050B)
  Parameter
Value
  Voltage Supply (VDD)
3V0 ~ 5V5
  Abs.Max VDD
-0.5V ~ 8V0
  Measurement range
±50A
  Interface
Analogue
  Active current (mA) (typ,max)
10, 13.5
  Conductor resistance 100µΩ
  Zero current output voltage
VCC/2
  Output offset (@25°C, High T, Low T)[3]mV ±5, ±15, ±35
  Sensitivity 40mV/A
  Noise
10mV
  Magnetic offset error [1]
100mA
  Propagation delay (Current change to op)
1µs
  Rise time (step response 10% to 90%)
3µs
  Error (High Temp, low Temp)[3]
-1.2%, 2%
  Accuracy best at [2][2a] 5V supply
  Output load resistance
4k7
  Output load capacitance (max)
10nF
  Overcurrent for 1s (@25°C,150°C) 1200A, 600A
  Isolation Voltage  (VDC or VPK, VRMS)
900V, 700Vrms
  Package Thermal resistance 7°C/W
  Max junction Temp. 165°C
  Operating temperature
-40°C ~ 150°C
        [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.

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. B has the largest range.

ACS758 Block diagram

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 can null out using software.

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 becuase 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:
   
    40[mV/A] sensitivity gives 1.0/40 Amps/mV

    (1.0/40)[A/mV]*4.88[mV] = Amps/LSB = 1.0/8.1 = 0.122A/LSB

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

    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.

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 microswitch).

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:

Internal 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.

mains timer moddified with acs758 installed

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 - completed ACS758 installed

Mains timer moded with ACS758 inside

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 Zero Current waveform

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.

ACS578 42W bulb waveform

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 42W Bulb cursors set in middle of noise on oscilloscope

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:

ACS758 measuring Blower heater current

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

The maximum power this chip can measure (±50A chip version) is:

    Ipeak  = +50A
    Irms   = Ipeak/sqrt(2) = 50/sqrt(2) = 35.36Arms
    Power = Vrms * Irms = 240 * 35.36 = 8485W ~ 8kW

For the ±200A chip version you can measure:

    Ipeak  = +200A
    Irms   = Ipeak/sqrt(2) = 200/sqrt(2) = 141.42Arms
    Power = Vrms * Irms = 240 * 141.42 = 33941W ~ 33kW

Measuring RMS Current

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:

  1. Ten point rolling average.
  2. 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.52121
  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
static int offset = 512; // Calculated at start.

///////////////////////////////////////////////
// Returns offset = average value.
int get_offset(void) {
long avg=0;

   for (int i=0; i<200; i++) {
      avg += analogRead(A0);
      delay(1);   // Let analogue settle.
   }

   return avg/200;
}

///////////////////////////////////////////////
// Store max min
//
void assign_max_min(float val, float *pmax, float *pmin) {
   if (*pmax < val) *pmax = val;
   if (*pmin > val) *pmin = val;
}

///////////////////////////////////////////////
void setup(void) {
   Serial.begin(115200);
   Serial.println("ACS758...");

   offset = get_offset();
   Serial.println("Offset "); Serial.print(offset);
}

//////////////////////////////////
void loop(void) {
static unsigned long update_time_was = millis();
static float nmax=0, nmin=0, rmax=0, rmin=0, y=offset, w=0.4;
int a0;

   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;

      float navgIpeak =( (__max-__min)/2 * V_PER_LSB) / ACS758_SENSITIVITY;
      float navgIrms  = navgIpeak/sqrt(2);
      float navgPower = 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.



New! Comments

Have your say about what you just read! Leave me a comment in the box below.




Privacy Policy | Contact | About Me

Site Map | Terms of Use



Visit our Facebook Page:
To Visit Click Here


Recent Articles

  1. How the HMC5883L 3-axis digital magentomter works

    HMC5883L - How make a digital compass, Find out the differences between the HMC5883L and the QMC5883L and whether they are compatible.

    Read more

  2. Arduino absolute value - abs() - secrets revealed...

    Secrets of Arduino absolute value abs() - Why it might fail, Why it may cause problems...and how to fix it.

    Read more

  3. Arduino Analog Output...Easy analog output generation

    Arduino Analog Output: How to create the most accurate PWM analog ouput and how to create analog PWM sine waves.

    Read more

  4. ACS758 secrets...

    Using the ACS758 to measure very high current

    Read more

  5. Arduino Voltage Reference Capabilities

    Arduino Voltage reference: Both the Uno and Nano have a built-in voltage reference: Find out how to make it more accurate. In addition find out how to use it to measure the supply voltage 1V8 ~ 5V5

    Read more

  6. DigitalWrite and equivalent fast macros. Speed up your code!

    Find out how digitalWrite() works...Now use 17x Faster macros!

    Read more

Readers Comments

"I wanted to thank
you so so so much
for all the information
you have provided in
your site it's

SUPERB and FANTASTIC."

- Ranish Pottath

"This site really is
the best and my favorite.
I find here many useful
projects and tips."

- Milan

bursach<at>gmail.com<

"Awesome site,
very, very easy and nice
to navigate!"


- Matt
matt_tr<at>
wolf359.cjb.net


Learn Microcontrollers

"Interested in
Microcontrollers?"

Sign up for The
Free 7 day guide:

FREE GUIDE : CLICK HERE


"I am a newbie to PIC
and I wanted to say
 how great your
site has been for me."


- Dave

de_scott<at>bellsouth.net

"Your site is a great
and perfect work.
congratulations."


- Suresh

integratredinfosys<at>
yahoo.com

"I couldn't find the correct
words to define
yourweb site.

Very useful, uncovered,
honest and clear.

Thanks so much for
your time and works.
Regards."


- Anon

Back to Top