This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/EVM430-F6779: Help with THD measurements

Part Number: EVM430-F6779
Other Parts Discussed in Thread: TIDM-THDREADING

Tool/software: TI C/C++ Compiler

Dear all,

We are using EVM430-F6779 for power metering applications. Although we are getting correct values for Voltage, Current and power, we are facing issues with the VTHD and ITHD measurements. The raw value we are getting for ITHD measurements are 12217. We are unable to interpret the value. Could you please provide support in interpreting this value. Below are the details we are using for the code and application.

Code: TIDM-THDREADING

THD Measurement: IEC_THD_F_SUPPORT

Appliance: Variable Frequency Drives

Code snippet for the THD calculation (Using the default code and no changes were made, File name: metrology-foreground.c)

x = (int64_t) phase->readings.fundamental_V_rms*phase->readings.fundamental_V_rms;
    y = (int64_t) phase->readings.V_rms*phase->readings.V_rms;
    /* Prevent tiny errors in x and y from leading to tiny negative values for THD */
    if (x >= y)
        return 0;
    z = y - x;
#if defined(IEC_THD_F_SUPPORT)
    z = isqrt64(z);
    z /= phase->readings.fundamental_V_rms;
    z *= 10000;
    y = z >> 32;
#endif

Kindly let us know if any information is needed.

  • Hello,

    Thanks for your detailed post. Are you applying any harmonics or just the fundamental? What values are shown in the GUI for Voltage THD and Current THD? By raw value, do you mean the value returned by the evaluate_current_thd() function is equal to 12217? What's the raw value for the Voltage THD?

    In the code shared above, everything above Lines 10 and 11 match the equations found at the top of page 13 in Total Harmonic Distortion Measurement For Energy Monitoring user's guide. On Line 10, this appears to scale up the number by multiplying it by 10000. This is most likely because you can't represent decimals using integers, so it has to be scaled up. Now, Line 11 shifts the result by 32 bits to the right. This is because the result from the "isqrt64()" function returns a 64-bit value where the lower 32 bits are fractional values. Thus, the earlier scaling by 10000 preserved some fractional values before they were shifted to the right for the final value.

    Regards,

    James

**Attention** This is a public forum