0
\$\begingroup\$

In my project I'm using the current sensor ACS712 30A for measuring current. I tested on Proteus 8.6 sp3 and it works OK, but in practice (using protoboard) the sensor is showing current without any loads connected.

Here's the part of my code that deals with the ACS712 obs: I'm measuring AC current and using 220 V as voltage.

while(1)
{
  char ACS[15];                      
  char Corrente [15];
  pino1 = 0;
                        
  for (i = 0; i < samples; i++)    
  {
    pino1 = pino1+ (ADC_Read(0) - 511.95);      
  }

  current = pino1;
  current = current / samples;
  current = current * current;
  current = sqrt(current);
  current = current / 8.6f;                      
           
  FloatToStr(current, Corrente);
  potencia = (current * 220);                 
  FloatToStr(potencia, ACS); 
  Lcd_Cmd(_LCD_CLEAR);
  Lcd_Cmd(_LCD_CURSOR_OFF);                       
  Lcd_Out(1, 1, "AMP =");
  Lcd_Out(1, 7, Corrente);                             
  Lcd_Out(2, 1, "P =");
  Lcd_Out(2, 5, ACS);
  Lcd_Out(2, 16, "W");
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ "it's accusing current without any loads connected." - how much current is it 'accusing'? \$\endgroup\$ Jul 17, 2019 at 19:43

1 Answer 1

1
\$\begingroup\$
   pino1 = pino1+ ( ADC_Read(0) - 511.95  );

If ADC_Read(0) is 0 or not, pino1 = samples × -511.95. This will account for your numbers, which should equal 59.5A (assuming ADC_Read(0) = 0).

Additionally:

   current = pino1;
   current = current / samples;
   current = current * current;
   current = sqrt(current);
   current = current / 8.6f;                      

So current = current * current; and current = sqrt(current); do nothing.

I'll assume current = current / 8.6f;, factors out the -511.95.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.