ACS756 Current Measurement Tests

ACS756_breakout (1024x768)

Like many hobbyists, I have a project where I need to measure AC line voltage and a couple of loads.

I started out trying to avoid doing anything complicated for power measurement… but I soon hit issues and the simple approach became increasingly more complicated, less accurate, and less reliable.

So, it’s time to reset that part of the project and evaluate a few approaches.


  • Monitor AC line voltage  from 80 to 150 VAC RMS
  • check for low and high voltage conditions
  • stretch goal:  identify short duration brown-outs and voltage spikes, the type caused by sudden switching of loads

Monitor AC current on 2 separate loads on the same AC circuit (phase)

  • Measure instantaneous current from 0 to 10 Amps, with 0.5 Amp accuracy
  • Detect low current and overcurrent conditions
  • Stretch goal: identify surges during load switching


  • Size, I have some flexibility but an initial goal is to have the power and logic boards fit into a 4” x 8” space.
  • Standard U.S. single phase AC power
  • will be installed outdoors in an IP-67 enclosure

I have some aversion to messing with AC line voltage, and generally I work with little more than TTL levels.  So, I opted for an isolated approach,  that is:  the AC line voltages are completely separated from the microcontroller and other logic.

This will allow me to have the AC sensing circuitry on a separate board allowing me to poke and prod the microcontroller without concern of any shock hazard.

 Here’s a typical setup for the hall-effect sensor, and here’s a breakout board mounted in an enclosure to make using it on the bench with AC line voltage a bit safer.

{insert picture of ACS756 breakout}

I initially tested it out using a heavy DC power supply and load… it worked fine, was moderately accurate, and simple.

ACS756_Current_Measurement (1)


 usable, but not great…

Test Results:

{ put in table here }

For AC current tests the system configuration is

ACS756_Current_Measurement (1)


Test Results:

… the results were a mess… random numbers all over the place!



  • When no current is flowing through the ACS756, the output is about 2.5V.
  • When we run positive current (the + output of the line is connected to the + on the ACS756), the output of the sensor goes up.
  • If we run negative current (the – output of the line is connected to the + on the ACS756), the output of the sensor goes down.

In this test we ran alternating current through the device, causing the ACS756 to provide a sine wave like output.

The readings were somewhat random, as it depended on where in the wave the Arduino took the sample.

{ put in table here }

Here’s the code for the tests.

The basic test is just reading an analog input and printing the results to the serial port:

int analogPin = 3; // Connect output of ACS756 to analog pin 3
 // outside leads to ground and +5V
int val = 0; // variable to store the value read
void setup()
 Serial1.begin(9600); // setup serial
 pinMode(13, OUTPUT); 
 digitalWrite(2, HIGH);
void loop()
 digitalWrite(13, !digitalRead(13));
 val = analogRead(analogPin); // read the input pin
 Serial1.println(val); // debug value

The second test takes a large sample of readings and selects the largest value before printing the results to the serial port:

int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
 // outside leads to ground and +5V
int reading = 0; // variable to store the value read
long maxVal = 0;
int samples = 10000; // how many samples per reading

void setup()
 Serial1.begin(9600); // setup serial
 pinMode(13, OUTPUT); 
 digitalWrite(2, HIGH);

void loop()
 maxVal = 0;
// delay(500);
// digitalWrite(13, !digitalRead(13));
 for (int counter = 1; counter < samples; counter++) { 
 reading = analogRead(analogPin); // read the input pin
 if (reading > maxVal)
 maxVal = reading;
 Serial1.println(maxVal); // debug value

Soldering Equipment

I was using the Hakko FX-951 units, but upgraded to JBC.
Here’s the JBC DIT and JBC compact with micro-tweezers.JBC

At the back-right is a DS-983A solder dispenser.
On the left is the intake for the fume extractor. Soldering_setup

The rework equipment, a CSI-474A desoldering gun, and a CSI-825A+ hot air unit.


Nav Beacon – Control Board

The control board design is complete, ready to etch it and see if it works… With 127 components (352 connections) there’s probably a Vdd or Gnd trace missing somewhere.


And the top and bottom layouts, without the copper pours.  To control noise on the digital lines, the bottom layer will be as continuous a copper pour as possible.






Mantis Scope arrived!

New Mantis Compact inspection scope arrived, with articulated boom arm.  The Mantis on the left with the standard binocular AmScope on the right.


This scope provides a great 3D view, without peering through little eye pieces.  The Mantis provides a much sharper image than the Amscope’s optics.  And you can shift sligtly while looking through the Mantis and change your perspective of the board, this is very handy for getting a better perspective when working on small devices.

The AmScope is still handy for high magnification (up to 200x), but most inspection work is in the 4x –  8x range, and the Mantis is great for that.

The optional articulating arm provides good reach across the workbench, and was a worthwhile option.


Nav Beacon – breadboarded

Here’s the main controller, on the breadboard, and the readings from the Vref and SPI ADC.

Uses a PIC18F26K22 as the main controller, reads settings from BCD switches and controls SSD relays via a pair of MCP23S08 SPI chips, beacon and marker lamp currents are measured using 50 Amp ACD756 hall-effect sensors, their output is digitized using an MCP3004 ADC set to take differential readings.




Microchip’s C18 V3.45 Compiler is Junk

As I continue to use the Microchip C18 compiler I find more and more issues. Microchip’s idiots appear to have left the peripherals lib out of the linker for the PIC18F2x/45K50 chips.
After changing over to use the K22 series of microcontrollers (specifically the PIC18F26K22), I found that the SPI libraries are missing from the linker. The USART libraries are there, but not the SPI.
Programs using SPI compile just fine, but won’t link…

Keep it up Microchip, and you may yet convince everyone to use Atmel.

So, I switched to an older compiler, version 3.40, and it works fine.

Here’s the code:

* Uses SPI to read an MCP3004, and writes the results to the serial port.

#include <p18F26K22.h>
#include <usart.h>
#include <stdio.h>
#include <stdlib.h>
#include <spi.h>
#include <delays.h>

#pragma config FOSC = INTIO7 //, MCLRE = ON
#pragma  WDTEN = 0;  // Disable the watchdog timer

IRCF<2:0>: Internal RC Oscillator Frequency Select bits(2)
111 = HFINTOSC ? (16 MHz)
110 = HFINTOSC/2 ? (8 MHz)
101 = HFINTOSC/4 ? (4 MHz)
100 = HFINTOSC/8 ? (2 MHz)
011 = HFINTOSC/16 ? (1 MHz)(3)
unsigned char msb1, msb2, lsb1, lsb2;

int ch_data;

/* SPI pins
* 14 SCK
* 15 SDI = MISO
* 16 SDO = MOSI */
#define ADC_CS PORTCbits.RC2 // pin 13 = chip select for ADC

void main(void)
OSCCONbits.IRCF = 0b101; //change Fosc to 4Mhz

ANSELC = 0; //Analog ports set to digital

// Have to explicitly set the IO on the SPI pins
TRISCbits.RC2 = 0; // Chip Select ADC_CS
TRISCbits.RC3 = 0; // SCK 1
TRISCbits.RC4 = 1; // SDI 1
TRISCbits.RC5 = 0; // SDO 1

ADC_CS = 1; // disable chip

// Open the USART configured as 8N1, 2400 baud, in polled mode


// write a break and Hello to the serial port.
putrs1USART(“\n\n\n\n\n\n\r !!! hello !!! \n\r”);

while (1) {

ADC_CS = 0; // pull chip select low RA4

msb1 = ReadSPI1();
lsb1 = ReadSPI1();

ADC_CS = 1; // disable chip
ch_data = msb1;
ch_data = ch_data << 8;
ch_data = ch_data + lsb1;

// write the data to the serial port
printf(“MSB,LSB %d,%d combined: %d\r\n”,msb1,lsb1,ch_data);


PIC18F26K22 – Blink

Here’s a fancier version of the usual blink routine that also demonstrates the various options for setting the internal oscillator.

* A more complicated Blink program for the PIC18F26K22
* Set the clock:
* 111 = HFINTOSC ? (16 MHz)
* 110 = HFINTOSC/2 ? (8 MHz)
* 101 = HFINTOSC/4 ? (4 MHz)
* 100 = HFINTOSC/8 ? (2 MHz)
* 011 = HFINTOSC/16 ? (1 MHz)(3)
* Use the PLL to quadruple the frequency.
* OSCTUNEbits.PLLEN = 1;
* connect LEDs to RA0 - RA5
* The program clock speed can be measured on pin RA6
#include /* MCU header file ***********/

#pragma config WDTEN = OFF
#pragma config FOSC=INTIO7 // ;Internal oscillator block
#pragma config PLLCFG = ON
#pragma config PRICLKEN = ON
#pragma config IESO = OFF
#pragma config PWRTEN = OFF // ;Power up timer disabled

int counter;
void main (void)
OSCCON = 0x62; // Fosc = 8MHz
OSCCONbits.SCS0 = 0;
OSCCONbits.SCS1 = 0;
OSCTUNEbits.PLLEN = 1; // Use the PLL to up the clock to 32Mhz

counter = 1;
TRISA = 0; /* configure PORTB for output */
while (counter <= 255)
PORTA = counter; /* display value of ‘counter’ on the LEDs */


« Older Entries