Test Software for the ACS764 with Arduino Uno

Hello,
I want to measure the current of a fuel cell prototype with aid of the ACS764.
For that purpose, a PCB board was designed to measure current and temperature (See attachments for schematics and layout).
The SW is running in ARDUINO UNO
The reason why I am asking your help is because I always receive the same value no matter if there is flowing current or not.
After many rounds of trouble shooting I can be sure that:
• a current is flowing through the sensor
• there are no short circuits
• the I2C-address of the ACS764 is correct (I am using this small SW test: http://playground.arduino.cc/Main/I2cScanner )

Taking the figure “Typical Application Diagram” of the Data sheet as reference, I have two small deviations, and those are:
• Vcc is 5 Volts
• I have a pull down 10KΩ resistor at pin 14 “FREEZE”

I have two type of responses.

The first one is a fixed value of 3 or 1. I got this answer when I run this Software

#include <Wire.h>       // load I2C-Library

void setup() {
  Wire.begin();         // I2C-Bus "activate"
  Serial.begin(9600);   // Enable the serial communication for debugging purposes
/*
  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x02));         //set average points as 1
  Wire.write(byte(0x00));
  Wire.write(byte(0x01));
  Wire.write(byte(0x01));
  Wire.endTransmission();
  
  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x04));         //set gain as 2
  Wire.write(byte(0x00));
  Wire.write(byte(0x00));
  Wire.write(byte(0x02));
  Wire.endTransmission();

  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x06));          //set overcurrent as 63% of CSR 
  Wire.write(byte(0x00));
  Wire.write(byte(0x00));
  Wire.write(byte(0x03));
  Wire.endTransmission();
  */
}

void loop() 
{

   int aux=0;
  // helpbyte
                                      
      Wire.beginTransmission(B1100000);   //start communication with slave #60
      Wire.write(byte(0x00));             //send command 0x00. MAY BE HERE IS MY MISTAKE BUT I REALLY TRIED EVERYTHING ELSE
      Wire.endTransmission();
      Wire.requestFrom(B1100000, 3); // expecting 3 Byte from slave #60
      delay(10);                  //waiting
      while(Wire.available())    // Until some bytes are in bus. P.S. Slave may send less than requested
      { 
        aux = Wire.read();    // overwrite the value and just keep the last significant byte
      }
      Serial.print("00: ");        
      Serial.println(aux);         // print the value
      delay(3000);      
}

The second type of answer is an “Echo” of the last parameter that was set up, in this case 255. I got this answer when I run a software like this

#include <Wire.h>       // load I2C-Library

void setup() {
  Wire.begin();         // I2C-Bus "activate"
  Serial.begin(9600);   // Enable the serial communication for debugging purposes
  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x02));         //set average points as 255
  Wire.write(byte(0x00));
  Wire.write(byte(0x01));
  Wire.write(byte(0xFF));
  Wire.endTransmission();

/*
  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x04));         //set gain as 2
  Wire.write(byte(0x00));
  Wire.write(byte(0x00));
  Wire.write(byte(0x02));
  Wire.endTransmission();

  Wire.beginTransmission(B1100000);
  Wire.write(byte(0x06));          //set overcurrent as 63% of CSR 
  Wire.write(byte(0x00));
  Wire.write(byte(0x00));
  Wire.write(byte(0x03));
  Wire.endTransmission();

  Wire.endTransmission();             //set parameters
  Wire.beginTransmission(B1100000);
  Wire.write(GAIN_RANGE, 4);
  Wire.endTransmission();
  Wire.beginTransmission(B1100000);
  Wire.write(FAULT_LEVEL, 4);
  Wire.endTransmission();
  Wire.beginTransmission(B1100000);
  Wire.write(0x00);
  Wire.endTransmission();
  */
}

void loop() 
{

   int aux=0;
  // helpbyte
                                      
      Wire.beginTransmission(B1100000);   //start communication with slave #60
      Wire.write(byte(0x00));             //send command 0x00. MAY BE HERE IS MY MISTAKE BUT I REALLY TRIED EVERYTHING ELSE
      Wire.endTransmission();
      Wire.requestFrom(B1100000, 3); // expecting 3 Byte from slave #60
      delay(10);                  //waiting
      while(Wire.available())    // Until some bytes are in bus. P.S. Slave may send less than requested
      { 
        aux = Wire.read();    // overwrite the value and just keep the last significant byte
      }
      Serial.print("00: ");        
      Serial.println(aux);         // print the value
      delay(3000);
      
}

What I am looking for is a test Software for the ACS764. May be my problem is the software. I really dont care if you provide me a C-function or library afterwards i can re-write this function into a “Arduino”-function or library.

Thank you very much in advance for your attention and do not hesitate to contact me if you need more details about my application.

Regards

Juan Gutierrez

Schematic_Sensor_v1.pdf (22.9 KB)

Sensor_v1.pdf (789 KB)

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

You can edit your post to add the code tags.

Weedpharma

Hello everybody,
I haven’t solved the problem but I already contacted the company Allegro in Germany and they suggested me to do some test. Attached is a small presentation about the results.

It seems that the sensor only reads the value stored at register 0x02. Values of register 0x04 and 0x06 can be read correctly without a problem.

Sadly I cannot proof my theory but I would say that the EEPROM of the sensor was burned when the sensor was soldered. My explanation is very weak but on the other hand, I cannot explain the strange behaviour of the sensor.

It seems that the arduino creates a valid SCL with a correct frequence and timing.

For an unknown reason the register 0x00 can not be accesed or it is not updated but why?

This is not what you want but perhaps can help you.

Regards
Juan Gutierrez

P.S. I contacted the Allegro company of germany and they didn’t help me so much, If you have the same problem perhaps you could have more luck if you address your local technical service.

Current Sensor Analysis english.pdf (303 KB)

As an update for anyone looking for assistance with this chip that may have given up, the problem reported here is due to a misunderstanding of both the datasheet and how the Wire library functions.

Most times, using the Wire library, when we want to request data from a register we script something like this:

Wire.beginTransmission(add);
Wire.write(reg);
...<payload>...
Wire.endTransmission(); //This defaults to Wire.endTransmission(1); or Wire.endTransmission(TRUE);
Wire.requestFrom(add,dataCount);

What we’re doing here is sending (ignoring ACKs) START–>ADDRESS/W–>Payload–>STOP–>START–>ADDRESS/R–><response*n>–>STOP.

This works for serial EEPROMs, the MCP23017, and most chips. Some chips, however, require a restart condition before they’ll respond with anything but an echo/error. The ACS764, which I have successfully used on a few boards using the Arduino language, requires a restart after pointing it to register 0x00 instead of the first STOP condition. To do this, we do the following:

Wire.beginTransmission(0x60); //Default address with A0, A1 pulled completely to Vss
Wire.write(0x00);
Wire.endTransmission(0); //The 0, or FALSE, signifies a RESTART in stop of a STOP.
Wire.requestFrom(0x60,3);

It will then respond with 0x00 (always 0’s), followed by “combined” data. You’ll need to isolate the last 9 bits. This can be as simple (though inefficient) as

Wire.read(); //Ignore the first response byte, it'll always be 0x00.
byte1=Wire.read()&0x01;
byte2=Wire.read();
rawCurrent=(byte1<<8)+byte2;

You’ll still have to compensate for leakage current in however you do your calculations on the response (I’ve found that I rarely get a true 0, but that could just be errors in the board layout.)

I hope this helps.