Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

What is default slave address for the ACS71020

Status
Not open for further replies.

nis2311

Member level 3
Member level 3
Joined
Nov 19, 2016
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,804
Hi,
i am trying to communicate with ACS71020 using I2C communication Basically I2C need Slave address. I want to know default slave address for the ACS71020KMABTR-090B3-I2C. In datasheet also not mentioned about default slave address.
 

As described in the datasheet, the I2C slave address is programmed by the voltage level at DIO0 and DIO1 at power on.
 

Thanks for your reply.
But in my application, the DIO0 is used for Voltage zero crossing and DIO1 for Over Current. If I Disable I2C slave address selection circuit means. Then what will be the slave address?.
 

Hi,

It's quite clear, isn't it?
DIO0 is used for Voltage zero crossing
--> Table17 --> value = "0"

DIO1 for Over Current.
--> Table18 --> value = "0"

Now you have "0-0"
--> table 16, value 0-0 --> address = 96 (decimal)

Klaus
 

Hi,
I am trying to communicate with the ACS71020 with STM32 MCU. I used 0xC0 as a Slave address, but the device not responding.

HAL_I2C_Mem_Read(&hi2c1,0xC0,0x20,1,&data,1,100);
Always i am getting '0' only. I made DIO0 & DIO1 pulldown externally. Help me to solve this problem.
 

I would do the following:

- Check with oscilloscope if the device is operated with the expected address and actually doesn't ACK the command.
- Check if your pull-down resistors actually set the required voltage level of < 0.1 VCC during power on.

- Consider that there's an EEPROM option to disable the DIO_x address circuit. If it has been set by someone, you'll need to scan the presently set I2C address by a test routine.
 

Hi,
Finally, I communicated with the ACS71020 using 0x60 (96 decimal) as a slave address. Random data is coming from the CHIP when I read the address 0x20 to get voltage. But I can't figure it out. In the datasheet mentioned to get the VRMS:-
"This field is an unsigned 15-bit fixed point
number with 15 fractional bits. It ranges from 0 to ~1 with a step
size of 1/215. This number should be multiplied by the overall full
scale of the voltage path in order to get to volts
"

How to get the RMS voltage data from the above procedure.
 

with a step size of 1/215
Please quote correctly. It's 1/2^15

If you get random data, there's possibly a problem with your hard- or software. Can you read other register values consistently?
 

sorry...It's 1/2^15
If I read other address like EEPROM data of the ACS71020 means, data is constant and matching. If I try to read only the voltage and current - the data are not constant. Help me to solve this problem....
 

Hi,

If I try to read only the voltage and current - the data are not constant.
Let me guess:
* the analog voltage input is not connected and thus floating
* or the input is connected and there is either true signal or noise

Klaus
 

Hi,
I interfaced with the ACS71020 with the Arduino board. But still, I can't' get the actual values.
This is my Arduino code:-
Code:
/* ACS71020 Arduino Programming Code
 * This code will work for Arduino UNO
 * Supply Voltage is 3.3V, ACS71020KMABTR-030B3-I2C
 * SCL Pin = A4 Analog Pin
 * SDA Pin = A5 Analog Pin
 * By using this code it is possible to read AC Voltage, AC Current, Active Power, Reactive Power, Power Factor and Frequency.
 * 
 */


#include <Wire.h>

#define kNOERROR 0
#define kREADERROR 1
#define kWRITEERROR 2

#define ADDRESS 0x60   // Slave Address = 96 (DIO_0 = DIO_1 = 0 (GND)), When DIO_0 = DIO_1 = 1 (connected to VCC through 10K pull up )Slave Address = 127 

const uint16_t LEDPin = 13;
const uint32_t WRITE = 0x00;
const uint32_t READ = 0x80;
const uint32_t COMMAND_MASK = 0x80;
const uint32_t ADDRESS_MASK = 0x7F;

double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
double AmpsRMS1 = 0;

unsigned long nextTime;
bool ledOn = false;
bool UseI2C = true;

// Setup the demo board.
void setup()
{
    pinMode(LEDPin, OUTPUT);
    digitalWrite(LEDPin, LOW);

	// Turn on the pullup so the determination of communication protocol can be made.
   // pinMode(ProtocolSelectPin, INPUT_PULLUP);

    if (UseI2C)
    {
        // Initialize I2C
        Wire.begin(); 
        Wire.setClock(100000);
    }
   
    Write(0x2F, 0x4F70656E);   // Unlock device
   // Write(0x1E, 0x00);   // Bypass_enable
    Write(0x25, 0x00);   // Numptsout
    Write(0x1C, 0x32);   // rms_avg, AC Voltage averaging done by writing the 50 decimal value in the rms_avg_1 register (0x1C)
    Write (0x1B, 0x0019C000);
     
    
    // Initialize serial
    Serial.begin(115200);
    // If the Arduino has built in USB, keep the next line
    // in to wait for the Serial to initialize
    while (!Serial);

 
    nextTime = millis();
}

/*
 * Every 500 milliseconds, read the ACS71020 and print out the values
 */
void loop()
{
    uint32_t vrms_irms;
    uint32_t vrms;
    uint32_t irms;
    uint32_t pactive;
    uint32_t paparent;
    uint32_t pimag;
    uint32_t pfactor;
    uint32_t numptsout;
    uint32_t vrmsavgonesec_irmsavgonesec;
    uint32_t vrmsavgonesec;
    uint32_t irmsavgonesec;
    uint32_t vrmsavgonemin_irmsavgonemin;
    uint32_t vrmsavgonemin;
    uint32_t irmsavgonemin;
    uint32_t pactavgonesec;
    uint32_t pactavgonemin;
    uint32_t vcodes;
    uint32_t icodes;
    uint32_t pinstant;
    uint32_t flags;
    float AC_Voltage;
    float factor_v;
    float AC_Current;
    float factor_i;
    float Power_Factor;
    float Power_Factor1;

        float div1 = 32767.00;
        float div2 = 32767.00;
        float pf,pf1,pact1,pact2,pact3,pact4,Active_Power,Active_Power_avg,Aparent_Power,papa1,pima1,Reactive_Power;
        int Frequency;
        
    // Every 1/2 second, toggle the state of the LED and read the ACS71020
    if (nextTime < millis())
    {
        Read(0x20, vrms_irms);
        Read(0x21, pactive);
        Read(0x22, paparent);
        Read(0x23, pimag);
        Read(0x24, pfactor);
        Read(0x25, numptsout);
        Read(0x26, vrmsavgonesec_irmsavgonesec);
        Read(0x27, vrmsavgonemin_irmsavgonemin);
        Read(0x28, pactavgonesec);
        Read(0x29, pactavgonemin);
        Read(0x2A, vcodes);
        Read(0x2B, icodes);
        Read(0x2C, pinstant);
        Read(0x2D, flags);

        vrms = vrms_irms;
          
        irms = (vrms_irms >> 16);
        pimag = pimag & 0x1FFFF;
       
        vrmsavgonesec = vrmsavgonesec_irmsavgonesec;
  
        irmsavgonesec = (vrmsavgonesec_irmsavgonesec >> 16);
 
        vrmsavgonemin = vrmsavgonemin_irmsavgonemin & 0x7FFF;
       
        irmsavgonemin = (vrmsavgonemin_irmsavgonemin >> 16) & 0x7FFF;
       
        pactavgonesec = pactavgonesec & 0x1FFFF;
       
        pactavgonemin = pactavgonemin & 0x1FFFF;
         
        
        factor_v = (vrmsavgonesec / div1);
        AC_Voltage = (factor_v * 240.00 * 1.795);
        Serial.print ("AC_Voltage (Vrms)=     ");
        Serial.println ( AC_Voltage  );
     

        float div = 32767.00;
        factor_i = (irms/div2);
        AC_Current = (factor_i*90.00*2);      // 2 is the conversion factor 
        Serial.print ("AC_Current (Arms) =  ");
        Serial.println ( AC_Current   );
       // delay(1000);
        
       if (pfactor<512)
        {
          Power_Factor = (pfactor/512.000);
          Serial.print ("Power_Factor =  ");
          Serial.println ( Power_Factor  );
        }
        else
         {
           pf1 = (2048- pfactor);
           Power_Factor = (pf1/512.000);
           if (Power_Factor >1)
           {
            Power_Factor = 1;
           }
           Serial.print ("Power_Factor =  ");
           Serial.println ( Power_Factor  );
         }


         if (pactive<32767)
        {
          pact1 = (pactive/32767.00);
          Active_Power = (pact1*6900*1.795);   // 1.795 is the converson factor
         
        }
        else
         {
           pact1 = (131071- pactive);
           pact2 = (pact1/32767.00);
           Active_Power = (pact2*6900*1.795);
           
         }

        
        if (pactavgonesec<32767)
        {
          
          pact3 = (pactavgonesec/32767.00);
          Active_Power_avg = (pact3*6900*1.795);
         Serial.print ("Active_Power_avg (Watt) =  ");
         Serial.println ( Active_Power_avg  );
         
        }
        else
         {
          
           pact3 = (131071- pactavgonesec);
           pact4 = (pact3/32767.00);
           Active_Power_avg = (pact4*6900*1.795);
           Serial.print ("Active_Power_avg (Watt)=  ");
           Serial.println ( Active_Power_avg  );
           
         }

      if (paparent<32767)
        {
          papa1 = (paparent/32767.00);
          Aparent_Power = (papa1*6900*1.795);
          Serial.print ("Aparent_Power (VA)=  ");
          Serial.println ( Aparent_Power  );
        }
        else
         {
          
           pact1 = (131071- pactive);
           pact2 = (pact1/32767.00);
           Active_Power = (pact2*6900*1.795);
           Serial.print ("Active_Power =  ");
           Serial.println ( Active_Power  );
           
         }

      if (pimag<65535)
        {
        
          pima1 = (pimag/65535.00);
          Reactive_Power = (pima1*6900*1.795);
          Serial.print ("Reactive_Power (VAR)=  ");
          Serial.println (Reactive_Power );
          
        }
        else
         {
          
           pact1 = (131071- pactive);
           pact2 = (pact1/32767.00);
           Active_Power = (pact2*6900*1.795);
           Serial.print ("Active_Power =  ");
           Serial.println ( Active_Power  );
           
         }
        
          Frequency = (32000.000/(numptsout*2));
          Serial.print ("Frequency (Hz) =  ");
          Serial.println (Frequency);
        
   
        nextTime = millis() + 500L;

        // Blink the LED every half second
        if (ledOn)
        {
            digitalWrite(LEDPin, LOW);
            ledOn = false;
        }
        else
        {
            digitalWrite(LEDPin, HIGH);
            ledOn = true;
        }
    }
}

/*
 * Read a register
 *
 *    address   - the address to be written
 *    value   	- the value that was read
 *    returns   - the error (0 otherwise)
 */
 
uint32_t Read(uint8_t address, uint32_t& value)
{
    uint16_t results = kNOERROR;

    if (UseI2C)
    {
        Wire.beginTransmission(ADDRESS);
        Wire.write(address);
        results = Wire.endTransmission();

        if (results == kNOERROR)
        {
            byte a,b,c,d;
            Wire.requestFrom(ADDRESS, 4);

            a = Wire.read();
            b = Wire.read();
            c = Wire.read();
            d = Wire.read();

            value = d;
            value = (value<< 8) | c;
            value = (value<< 8) | b;
            value = (value<< 8) | a;

 
            
            
        }
    }
    else
    {
      
    }

    return results;
}

/*
 * Write a register
 *
 *    address   - the address to be written
 *    value   	- the value to be written
 *    returns   - the error (0 otherwise)
 */
uint16_t Write(uint8_t address, uint32_t value)
{
    uint16_t results = kNOERROR;

    if (UseI2C)
    {
        Wire.beginTransmission(ADDRESS);
		// Send the address then the value (least significant byte first)
        Wire.write(address);
        Wire.write(value);    
        Wire.write(value >> 8);
        Wire.write(value >> 16);
        Wire.write(value >> 24);
        results = Wire.endTransmission();
    }
    else
    {
      
    }
    if (address < 0x10)
    {
        delay(30);  // If writing to EEPROM delay 30 ms
    }

    
    
    return results;  // one curly bracket need to close
}


float ConvertUnsignedFixedPoint(uint32_t inputValue, uint16_t binaryPoint, uint16_t width)
{
    uint32_t mask;

    if (width == 32)
    {
        mask = 0xFFFFFFFF;
    }
    else
    {
        mask = (1UL << width) - 1UL;
    }

    return (float)(inputValue & mask) / (float)(1L << binaryPoint);
}


float ConvertSignedFixedPoint(uint32_t inputValue, uint16_t binaryPoint, uint16_t width)
{
    int32_t signedValue = SignExtendBitfield(inputValue, width);
    return (float)signedValue / (float)(1L << binaryPoint);
}



 
int32_t SignExtendBitfield(uint32_t data, uint16_t width)
{
	// If the bitfield is the width of the variable, don't bother trying to sign extend (it already is)
    if (width == 32)
    {
        return (int32_t)data;
    }

    int32_t x = (int32_t)data;
    int32_t mask = 1L << (width - 1);

    x = x & ((1 << width) - 1); // make sure the upper bits are zero

    return (int32_t)((x ^ mask) - mask);
}


Chip Values:-
Power_Factor = 0.53
Active_Power_avg (Watt)= 0.00
Aparent_Power (VA)= 7.18
Reactive_Power (VAR)= 3.02
Frequency (Hz) = 285
AC_Voltage (Vrms)= 10.75
AC_Current (Arms) = 4.20
Power_Factor = 0.50
Active_Power_avg (Watt)= 0.76
Aparent_Power (VA)= 24.57
Reactive_Power (VAR)= 11.15
Frequency (Hz) = 103

Actual Values:-
Frequency (Hz) = 51.117Hz
AC_Voltage (Vrms)= 152.7VRMS
AC_Current (Arms) = 0.212A


We tried to change the conversion factor also, but the linearity of the voltage is not coming.
Please solve the problem as soon as possible.
 

Hi,

Please solve the problem as soon as possible.
Thanks a lot for this ...

But first you need to give all your informations: (for sure also - as soon as possible ;-))
* complete schematic of all around the metering IC( power, power supply, load connections microcontroler connections periferial parts...)
* wiring diagrams
* scope pictures of input voltage and input current in one screen

best if you could add
* photos of your application
* informations about the connected load (what is it? 1 phase? 3 phase? how connected?

Klaus
 
Hi,


Thanks a lot for this ...

But first you need to give all your informations: (for sure also - as soon as possible ;-))
* complete schematic of all around the metering IC( power, power supply, load connections microcontroler connections periferial parts...)
* wiring diagrams
* scope pictures of input voltage and input current in one screen

best if you could add
* photos of your application
* informations about the connected load (what is it? 1 phase? 3 phase? how connected?

Klaus
 

Attachments

  • 1.PNG
    1.PNG
    100.3 KB · Views: 309
  • ACS71020_Example.PNG
    ACS71020_Example.PNG
    94.2 KB · Views: 415
  • Caculator.PNG
    Caculator.PNG
    252.9 KB · Views: 291
  • Capture.PNG
    Capture.PNG
    437.8 KB · Views: 298
  • flowchar.PNG
    flowchar.PNG
    24 KB · Views: 319

Hi,


Thanks a lot for this ...

But first you need to give all your informations: (for sure also - as soon as possible ;-))
* complete schematic of all around the metering IC( power, power supply, load connections microcontroler connections periferial parts...)
* wiring diagrams
* scope pictures of input voltage and input current in one screen

best if you could add
* photos of your application
* informations about the connected load (what is it? 1 phase? 3 phase? how connected?

Klaus
Dear Klaus,
I have difficulty converting from the SPI readable value to the actual value. I have followed the formula given but found it was not right ... Can you help me, thank you very much.
I enclose you the material, the allegro source and the circuit I experiment with
 

Attachments

  • 1.PNG
    1.PNG
    100.3 KB · Views: 264
  • ACS71020_Example.PNG
    ACS71020_Example.PNG
    94.2 KB · Views: 273
  • Caculator.PNG
    Caculator.PNG
    252.9 KB · Views: 273
  • Capture.PNG
    Capture.PNG
    437.8 KB · Views: 236
  • flowchar.PNG
    flowchar.PNG
    24 KB · Views: 244

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top