LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wrong AC Current reading?

Hello guys! I'm using two analog inputs voltage & current with serial communication from arduino to labview. I use ACS712 for the current sensor. The readings I get are ranging from -6 to +5 from the AC signal after the calculations. If I take the RMS, I will get around 3.9 - 4.0. I use 230AC supply with load 229ohms so I should get around 1.004? The value I get should be near to 1 but I'm getting 3.9 RMS?

I've double checked the hardware(connection) and software(calculations) and I don't think there is anything wrong? What should I do? This value I'm getting is totally far from 1A that I should be getting!

I'm taking the reading from Analog input 0 to divide 1023 then * 5000. Then I minus the 2500 offset and divide 185.

 

Here is my code:

 

const int analogIn0 = A0;
const int analogIn1 = A1;
int mVperAmp = 185; // use 100 for 20A Module and 66 for 30A Module
int RawCurrentValue= 0;
int RawVoltageValue= 0;
int ACSoffset = 2500;

int Denominator = 0;
float AcVoltage = 0;
float Voltage0 = 0;
float Voltage1 = 0;
float Amps = 0;

void setup(){
 Serial.begin(9600);
}

void loop(){
 
 RawCurrentValue = analogRead(analogIn0);
 RawVoltageValue = analogRead(analogIn1);

 Denominator = 10000/130000;
 
 Voltage0 = (RawCurrentValue / 1023.0) * 5000;
 Voltage1 = (RawVoltageValue / 1023.0) * 5000;
 AcVoltage = (Voltage1 / Denominator ) ;
 Amps = ((Voltage0 - ACSoffset) / mVperAmp);
 
 
Serial.print(Amps);
Serial.print(", ");
Serial.println(AcVoltage);

}

 

 

Really appreciate if you guys can help!

 

0 Kudos
Message 1 of 12
(3,842 Views)

I'm sure someone here will still try to help anyways, but is this problem related to the LabVIEW part of your system at all, or even NI equipment?

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 12
(3,832 Views)

Hi James,

 

lamela is using an Arduino to measure some signals and send to result of this measurement via serial port to a PC running LabVIEW.

And lamela tends to forget about the correct forum to ask his/her questions…

 

@lamela: Maybe you should ask in an Arduino forum?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 12
(3,826 Views)

Gotcha, ok.

 

lamela, have you tried printing values along the way (before, during, and after calculations) to better understand what the calculations are doing? You should print the raw value themselves, so that you can tell whether the problem lies in your calculations or in the raw signals.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 4 of 12
(3,811 Views)

You've probably already heard this before to, but is there a reason you aren't using LIFA, or the newer LINX?

0 Kudos
Message 5 of 12
(3,764 Views)

@Hooovahh wrote:

You've probably already heard this before to, but is there a reason you aren't using LIFA, or the newer LINX?


He's got bigger problems.

 

Note his statement:    I use 230AC supply with load 229ohms so I should get around 1.004

I really hope he isn't working with 230 VAC !

 

0 Kudos
Message 6 of 12
(3,736 Views)

Is he using the Arduino as a fuse?

 

Lynn

Message 7 of 12
(3,730 Views)

@johnsold wrote:

Is he using the Arduino as a fuse?

 

Lynn


I like to run all of my signals through an NI-USB 6008 (AI0 > AO0, AI1 > AO1), so that I have a cheap fuse that doubles as a probe!

/s

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 8 of 12
(3,722 Views)

Thanks for the replies!

I've serial printed the 3 values, the RawCurrentValue, the Millivolt and the Current reading. I verified that the Millivolt values are correct, so I assume the rawcurrentvalue shouldn't be the problem though.. I should be getting a current close to 1.

The values of the RawCurrentValue is ranging from 290-705. Millivolt is ranging from 1400-3450 and current is from -5.96 to 5.16. 

I don't think the calculation to measure the current is wrong either? What should I do? I already asked in the arduino forum but there is still no solution yet..

 

0 Kudos
Message 9 of 12
(3,684 Views)

Your calculations look reasonable, assuming that the coefficients in your original post are accurate.

 

Do you have an alternative means of measuring the current? Maybe it really is 5 A peak.

 

Lynn

0 Kudos
Message 10 of 12
(3,608 Views)