-
Notifications
You must be signed in to change notification settings - Fork 8
RMS voltage calculation is incorrect #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @reinto1234 , Thanks for reporting this. You say you tested it "with a Waveform generator without resistors". Did you remove the voltage divider resistors on the SparkX breakout? Or have you designed your own board? Have you set _dividerResistance and _senseResistance correctly? Best wishes, |
Hello Paul, |
Hi Tobi, Could this be a grounding issue? Please post a link to your waveform generator. Is its output isolated? Is GND / 0V common between the waveform generator and the ACS37800 circuit? Does the 150mVp-p output have a DC bias? Cheers, |
That's the Datasheet: https://beyondmeasure.rigoltech.com/acton/attachment/1579/f-001b/0/-/-/-/-/file.pdf |
OK - thanks. What happens if you add a 75mV DC offset to the 150mVp-p? I suggest looking again at your GND path. I suspect the voltage going to the ACS37800 is negative for half of each wave, preventing the ACS37800 from measuring it? Please confirm if these are your connections:
|
If I add the Offset i run into a problem of the sensor: it doesnt calculate VRMS if 0V isn't crossed if I add: mySensor.setBypassNenable(false, true); Im really confused with the sensor since 3 days so if we resolve this this would help me really much. |
Do you have an oscilloscope? If you do, probe the voltage between VINP and GND/VINN. Does it look sinusoidal? Or is it clipped? Maybe try AC-coupling? Add a small capacitor (~10pF) between the waveform generator and VINP. Does that help? |
I have an oscilloscope, sine looks fine. The values stay the same. There is no offset. |
Hi Tobi, OK. Thank you. I will try to replicate this in the next ~2 days. Best wishes, |
Hello,
for getting the real VRMS there is a multiplication by sqrt(2) missing. I don't exactly know why but i tasted it with a Waveform generator without resistors and a Fluke. I don't get the correct VRMS values if I use the function written down here i Have to multiply with sqrt(2).
Here's how i changed the code:
ACS37800ERR ACS37800::readRMS(float *vRMS, float *iRMS)
{
ACS37800_REGISTER_20_t store;
ACS37800ERR error = readRegister(&store.data.all, ACS37800_REGISTER_VOLATILE_20); // Read register 20
if (error != ACS37800_SUCCESS)
{
if (_printDebug == true)
{
_debugPort->print(F("readRMS: readRegister (20) returned: "));
_debugPort->println(error);
}
return (error); // Bail
}
//Extract vrms. Convert to voltage in Volts.
// Note: datasheet says "RMS voltage output. This field is an unsigned 16-bit fixed point number with 16 fractional bits"
// Datasheet also says "Voltage Channel ADC Sensitivity: 110 LSB/mV"
float volts = (float)store.data.bits.vrms;
if (_printDebug == true)
{
_debugPort->print(F("readRMS: vrms: 0x"));
_debugPort->println(store.data.bits.vrms, HEX);
_debugPort->print(F("readRMS: volts (LSB, before correction) is "));
_debugPort->println(volts);
}
volts /= 65536; //Convert from codes to the fraction of ADC Full Scale (16-bit)
volts /= 1.19; //Convert from codes to mV (110 LSB/mV)
volts *= 250; //Convert to mV (Differential Input Range is +/- 250mV)
volts /= 1000; //Convert to Volts
volts *= sqrt(2); //Convert to RMS (AC voltage)
//Correct for the voltage divider: (RISO1 + RISO2 + RSENSE) / RSENSE
//Or: (RISO1 + RISO2 + RISO3 + RISO4 + RSENSE) / RSENSE
float resistorMultiplier = (_dividerResistance + _senseResistance) / _senseResistance;
volts *= resistorMultiplier;
if (_printDebug == true)
{
_debugPort->print(F("readRMS: volts (V, after correction) is "));
_debugPort->println(volts);
}
*vRMS = volts;
The text was updated successfully, but these errors were encountered: