logo elektroda
logo elektroda
X
logo elektroda

Converting 50Hz AC with DC Offset to RMS: ADC Readings Methodology

Sunnysky 564 3
ADVERTISEMENT
  • #1 20864019
    Sunnysky
    Level 8  

    @ElektrodaBot how are adc readings of 50 Hz AC + DC offset converted to RMS
  • ADVERTISEMENT
  • #2 20864021
    ElektrodaBot
    AI OpenAI ChatGPT4
    Sunnysky wrote:
    how are adc readings of 50 hz Ac + DC offset converted to RMS
    Hello User:2917509,

    To convert ADC readings of an AC signal with a DC offset to RMS (Root Mean Square), you'll need to follow these general steps:

    1. Sampling: First, ensure that your ADC is sampling the AC waveform at a sufficient rate. According to the Nyquist theorem, you should sample at least twice as fast as the highest frequency component in your signal, but for accurate RMS readings, you'll typically want to sample much faster. For a 50 Hz signal, you might sample at least 10 times the frequency, so 500 Hz or more.

    2. Offset Removal: If there's a DC offset in your signal, this needs to be accounted for and removed because it will affect your RMS calculation. You can find the offset by averaging a large number of samples when the AC signal is known to be at zero or by using a digital high-pass filter.

    3. Rectification: Technically, for RMS calculation, rectification isn't necessary, but it can sometimes make it easier to visualize and understand the signal if you're troubleshooting. This isn't a step you'd typically process digitally for RMS calculations, though.

    4. Square the Samples: After you have removed the DC offset, square each sample value. This squares every value in the waveform, turning all the values positive and weighting the larger values more.

    5. Average the Squared Samples: Find the mean of these squared values by adding them all together and dividing by the total number of samples.

    6. Square Root: Finally, take the square root of this average. This will give you the RMS value of your AC waveform without the DC offset.

    Here is a sample code snippet that you could use to calculate the RMS value of an AC waveform with a DC offset in a microcontroller or a similar environment:

    Code: C / C++
    Log in, to see the code


    This code assumes you've filled the `adc_values` array with ADC samples of your AC waveform.

    Keep in mind that the accuracy of your RMS calculation will highly depend on the number of samples and the precision with which you can measure and calculate the average and the square root.

    Would you like to elaborate on the specifics of your setup, or do you have any other questions?
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
  • ADVERTISEMENT
  • #3 20864028
    Sunnysky
    Level 8  

    @ElektrodaBot Since RMS is equivalent to DC average, any DC error in your measurement reduces the accuracy of the RMS result. So it is biased for symmetrical full swing and subtracted for necessity.

    A bandgap voltage reference exists around 1.25V.

    The ADC Vref uses Vdd for full scale taking advantage of rail to rail Op Amp outputs unlike the asymmetrical saturated full scale output of BJT Op Amps.

    But you must scale DC bias to Vdd/2 in order to retain symmetry and resolution.

    The full range of 4096:1 equivalent to signed values of +/- 2048:1.



    Any difference from this DC offset and not subtracting the DC from your RMS result is a reduction of resolution and signal to noise ratio.
  • #4 20864035
    ElektrodaBot
    AI OpenAI ChatGPT4
    Sunnysky wrote:
    (...)


    But you must scale DC bias to Vdd/2 in order to retain symmetry and resolution.


    The full range of 4096:1 equivalent to signed values of +/- 2048:1.



    Any difference from this DC offset and not subtracting the DC from your RMS result is a reduction of resolution and signal to noise ratio.
    You're correct in stating that any DC error in the measurement process can significantly impact the accuracy of the RMS value. The inclusion of a DC offset in the signal is specifically problematic because the RMS value of a waveform should reflect only the power of the AC components, not any superimposed DC level.

    Given that you're using a bandgap reference voltage of around 1.25V, and your ADC's reference voltage (Vref) is based on the supply voltage (Vdd), you're right in emphasizing the need to center the AC signal around Vdd/2. This ensures full utilization of the ADC's dynamic range, which is crucial for maximizing resolution and signal-to-noise ratio.

    To ensure that the DC offset is accurately accounted for and removed before the RMS calculation, you might want to follow a revised version of the steps I previously outlined:

    1. Scale the Input: Scale your input signal so that it is centered around Vdd/2. This could be done with a simple voltage divider or more complex circuitry, depending on your specific application requirements.

    2. Sampling: Sample the waveform at a sufficiently high rate to capture the waveform accurately, as previously discussed.

    3. Calculate DC Offset: Calculate the DC offset either by averaging a set of samples when you know the signal has no AC component or by employing a digital filter to separate AC and DC components.

    4. Remove DC Offset: For each sample point, subtract the calculated DC offset to center the AC waveform around zero, which will facilitate an accurate RMS calculation.

    5. Square, Average, Square Root: Proceed with squaring each sample, averaging these squared values, and then taking the square root to obtain the RMS value, just as before, but with the DC offset removed.

    When coding this, you can add a step to account for the DC offset calculation:

    Code: C / C++
    Log in, to see the code


    Note that when you scale the input to be centered around Vdd/2, you'll also need to adjust your ADC read function to interpret this correctly, which might involve adjusting the ADC configuration if it supports differential inputs or otherwise accounting for the expected mid-scale offset.

    Would you like to discuss these steps in more detail or do you have any specific components, schematics, or part of your circuit you'd like to dive deeper into?
    You can call me in any topic by writing @ElektrodaBot. Disclaimer: Some answers provided by the ElektrodaBot may be inaccurate. Elektroda not responsible for accuracy, reliability or completeness of the information presented. All ElektrodaBot responses should be verified by the user. OpenAI can monitor and save information entered after calling ElektrodaBot.
ADVERTISEMENT