Allergro ACS758

Im putting together an ammeter using the bidirectional 150A version.

http://www.dfrobot.com/image/data/SEN0098/ACS758%20datasheet.pdf

Using the sample code.

/*
50A Current Sensor(AC/DC)(SKU:SEN0098) Sample Code
This code shows you how to get raw datas from the sensor through Arduino and convert the raw datas to the value of the current according to the datasheet;
Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing) is used to make the outputting current value more reliable;
Created 27 December 2011
By Barry Machine 
www.dfrobot.com
Version:0.2
*/


const int numReadings = 30;
float readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
float total = 0;                  // the running total
float average = 0;                // the average

float currentValue = 0;

void setup()
{
  Serial.begin(57600);
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;       
}
void loop()
{   
    total= total - readings[index];          
    readings[index] = analogRead(0); //Raw data reading
    readings[index] = (readings[index]-510)*5/1024/0.04-0.04;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;
    Serial.println(currentValue);
    delay(30);
}

readings[index] = (readings[index]-510)*5/1024/0.04-0.04;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;

In the math I understand that the sensitivity for my sensor is 13.3mv/amp or 0.0133/amp. What I dont understand is the last bit of comment , the second 0.04-offset val;.. Im lost here..Any idea's
There's also a problem because what ever value is inputted in the 0.04-0.04 equation ,that same number is what shows up in the serial monitor ,when the unit is at rest ,no current flowing. Im guessing Im missing something obvious.

Im using DC current on this :.

I messed around with it. Im getting within range of two other ammeter by +400ma
How I got to that was tweeking the value 510
Scale is zero, and the readings are getting "reasonable", but does this affect the scale upto 150amp.

readings[index] = (readings[index]-508.96)*5/1024/0.0133-0.0133;

Initially when I read through this I was under the assumption that 510 was 510mv ,as in a 510mv offset..

/*
50A Current Sensor(AC/DC)(SKU:SEN0098) Sample Code
This code shows you how to get raw datas from the sensor through Arduino and convert the raw datas to the value of the current according to the datasheet;
Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing) is used to make the outputting current value more reliable;
Created 27 December 2011
By Barry Machine 
www.dfrobot.com
Version:0.2
*/

#include <LiquidCrystal.h>
 LiquidCrystal lcd(2,3,4,5,6,7);

int RawData = A0;
const int numReadings = 30;
float readings[numReadings];      // the readings from the analog input
int index = 0;                  // the index of the current reading
float total = 0;                  // the running total
float average = 0;                // the average

float currentValue = 0;

void setup()
{
  Serial.begin(57600);
  lcd.begin(20, 4);
   lcd.clear();
  for (int thisReading = 0; thisReading < numReadings; thisReading++)
    readings[thisReading] = 0;       
}
void loop()
{   
    total= total - readings[index];          
    readings[index] = analogRead(RawData); //Raw data reading
    readings[index] = (readings[index]-508.96)*5/1024/0.0133-0.0133;//Data processing:510-raw data from analogRead when the input is 0; 5-5v; the first 0.04-0.04V/A(sensitivity); the second 0.04-offset val;
    total= total + readings[index];       
    index = index + 1;                    
    if (index >= numReadings)              
      index = 0;                           
    average = total/numReadings;   //Smoothing algorithm (http://www.arduino.cc/en/Tutorial/Smoothing)    
    currentValue= average;
    Serial.println(currentValue);
    lcd.setCursor(0,1);
   lcd.print(currentValue);
   lcd.setCursor(10,1);
   lcd.print("     AMPS  ");
    delay(30);
}

I just opened a package myself and was wondering about this code to.
I have the 50 Amp version. I do not find a 150A version.
Does it work for you now with this code?
Do you understand the formulla now? I don't :fearful:

Best regards
Jantje