how to reduce the response time of metering library

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to reduce the response time of metering library

1,111 Views
venkatkrishna
Contributor II

Hi,

         I am trying the twr_emeter demo in TWR-KM34Z50 board.While testing  the Voltage and Ampere readings were changing very slowly.It takes approximate 10 sec to stabilise.I nead to adjust the response time to 20ms(1 cycle of 50Hz).

Is there any parameter to adjust the response time and average counts?.Please help me to solve this.

Thanks/regards,

K.Venkat

Labels (1)
5 Replies

809 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Venkat!

Please, did you use the filter-based metering configuration tool for your configuration?

Did you have correctly set these parameters?

meterlibcfg.png

Please let me know if this helps.

Best Regards,

Iva

0 Kudos

809 Views
venkatkrishna
Contributor II

Hai Eva,

                 Thank you for your support.

1) I tried adjusting the HPF and LPF1 settings and i can able to get better response.

In HPF the least settiling time is 0.036sec and in LPF1 0.036sec is the least time.So the total settling time neaded for

correct reading is 0.72 sec.Am i correct? or the settling time of LPF2(least time) 0.217sec also come into the total time.

Please clarify me and help me to reduce this to 0.02 sec ie 20ms(one cycle time of 50hz)

2)In meterlib.h (democode)file i can able to see this.

/*! Metering library data structure definition - 2PH METER                    */

typedef struct

{

  double            umax;         /*!< maximal voltage measurement range      */

  double            imax;         /*!< maximal current measurement range      */

  Frac32            thrd;         /*!< sensitivity threshold                  */

  int               sens;         /*!< sensor: 1-proportional, 2-derivative   */

  tBIASFILTER_COEF  bias;         /*!< dc bias supressor filter coefficients  */    

  tBIASFILTER_COEF  intg;         /*!< integrator filter coefficients         */

  tBIASFILTER_DATA  uDcb1[2];     /*!< ph1-voltage dc bias supressor data     */

  tBIASFILTER_DATA  intd1;        /*!< ph1-current integrator filter data     */

  tBIASFILTER_DATA  iDcb1[2];     /*!< ph1-current dc bias supressor data     */

  tBIASFILTER_DATA  uDcb2[2];     /*!< ph2-voltage dc bias supressor data     */

  tBIASFILTER_DATA  intd2;        /*!< ph2-current integrator filter data     */      

  tBIASFILTER_DATA  iDcb2[2];     /*!< ph2-current dc bias supressor data     */

  tPHSHFILTER_COEF  hilb;         /*!< Hilbert & delay filter coefficients    */

  tPHSHFILTER_DATA  phSh1;        /*!< ph1-Hilbert & delay filter data        */

  tPHSHFILTER_DATA  phSh2;        /*!< ph2-Hilbert & delay filter data        */

  tAVERFILTER_COEF  aver;         /*!< averager filter coefficients           */

  tAVERFILTER_DATA  uRms1;        /*!< ph1-voltage RMS averager data          */

  tAVERFILTER_DATA  uRms2;        /*!< ph2-voltage RMS averager data          */

  tAVERFILTER_DATA  iRms1;        /*!< ph1-current RMS averager data          */

  tAVERFILTER_DATA  iRms2;        /*!< ph2-current RMS averager data          */

  tAVERFILTER_DATA  PAve1;        /*!< ph1-active power averager data         */

  tAVERFILTER_DATA  PAve2;        /*!< ph2-active power averager data         */

  tAVERFILTER_DATA  QAve1;        /*!< ph1-reactive power averager data       */

  tAVERFILTER_DATA  QAve2;        /*!< ph2-reactive power averager data       */

  tENERGY_DATA      Wh;           /*!< active energy                          */         

  tENERGY_DATA      VARh;         /*!< reactive energy                        */

} tMETERLIB2PH_DATA;

This is the config tool generated meterlib2ph_cgf.h file.

If i build this file the error saying "braced around scaler initializer" always reported.

Then i compared the meterlib1ph_cfg.h in the emeter demo code folder and found some lines

additional with respect o the above structure Which i noted you in bold strikes letters.Please

clarify me what is the use of those additional parameters and also explain the METERLIB_KWH_DR

/**************************************************************************************

* Filter-based metering algorithm configuration structure

**************************************************************************************/

#define METERLIB2PH_CFG                                                                  \

{                                                                                     \

  U_MAX,                                                                              \

  I_MAX,                                                                              \

  FRAC32(((+0.5000)/(U_MAX*I_MAX/2.0))),                                              \

  FRAC32((+0.0200)/I_MAX),                                                            \          

  1,                                                                                  \

  {{0l,0l,0l},{0l,0l,0l}},{{0l,0l,0l},{0l,0l,0l}},                                    \

  {{FRAC32(+0.99921521804155),FRAC32(-0.99921521804155),FRAC32(-0.99843043608309)}},  \

  {{FRAC32(+0.13165249758740),FRAC32(+0.13165249758740),FRAC32(-1.0)}},               \

  {{0l,0ll},{0l,0ll}},                                                                \

  {0l,0ll},                                                                           \

  {{0l,0ll},{0l,0ll}},                                                                \

  {{0l,0ll},{0l,0ll}},                                                                \

  {0l,0ll},                                                                           \

  {{0l,0ll},{0l,0ll}},                                                                \

  {  49,                                                                              \

    {                                                                                 \

      FRAC32(0.0),FRAC32(-0.02767909511717),FRAC32(0.0),FRAC32(-0.03031520404553),    \

      FRAC32(0.0),FRAC32(-0.03350628280924),FRAC32(0.0),FRAC32(-0.03744820311487),    \

      FRAC32(0.0),FRAC32(-0.04244130157922),FRAC32(0.0),FRAC32(-0.04897073735245),    \

      FRAC32(0.0),FRAC32(-0.05787451260303),FRAC32(0.0),FRAC32(-0.07073552031589),    \

      FRAC32(0.0),FRAC32(-0.09094567403011),FRAC32(0.0),FRAC32(-0.12732394894731),    \

      FRAC32(0.0),FRAC32(-0.21220658747347),FRAC32(0.0),FRAC32(-0.63661977126234),    \

      FRAC32(0.0),FRAC32(+0.63661977126234),FRAC32(0.0),FRAC32(+0.21220658747347),    \

      FRAC32(0.0),FRAC32(+0.12732394894731),FRAC32(0.0),FRAC32(+0.09094567403011),    \

      FRAC32(0.0),FRAC32(+0.07073552031589),FRAC32(0.0),FRAC32(+0.05787451260303),    \

      FRAC32(0.0),FRAC32(+0.04897073735245),FRAC32(0.0),FRAC32(+0.04244130157922),    \

      FRAC32(0.0),FRAC32(+0.03744820311487),FRAC32(0.0),FRAC32(+0.03350628280924),    \

      FRAC32(0.0),FRAC32(+0.03031520404553),FRAC32(0.0),FRAC32(+0.02767909511717),    \

      FRAC32(0.0)                                                                     \

    },                                                                                \

     25,                                                                              \

    {                                                                                 \

      FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),        \

      FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),        \

      FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),        \

      FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),FRAC16(0.0),        \

      FRAC16(-1.0)                                                                    \

    }                                                                                 \

  },                                                                                  \

  {                                                                                   \

    {                                                                                 \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,  \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l            \

    },                                                                                \

    0ll,                                                                              \

    {                                                                                 \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l      \

    },                                                                                \

    0l                                                                                \

  },                                                                                  \

  {                                                                                   \

    {                                                                                 \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,  \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l            \

    },                                                                                \

    0ll,                                                                              \

    {                                                                                 \

      0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l,0l      \

    },                                                                                \

    0l                                                                                \

  },                                                                                  \

  {                                                                                   \

    {FRAC32(+0.00130728645170),FRAC32(+0.00130728645170),FRAC32(-0.99738542709660)},  \

    {FRAC32(+0.00130728645170),FRAC32(+0.00130728645170),FRAC32(-0.99738542709660)},  \

  },                                                                                  \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {0ll,0ll,0l,0ll},                                                                   \

  {                                                                                   \

    FRAC48((+0.0000/(U_MAX*I_MAX))),FRAC32(+1.0000),  METERLIB_KWH_DR(   10000),      \

    {0ll,0ll,0ll},0ll,0l,FRAC16(-1.0),                                                \

    {FRAC32(+0.00779293629195),FRAC32(+0.00779293629195),FRAC32(-0.98441412741610)},  \

    {0ll,0ll,0ll},{0ll,0ll,0ll}                                                       \

  },                                                                                  \

  {                                                                                   \

    FRAC48((+0.0000/(U_MAX*I_MAX))),FRAC32(+1.0000),METERLIB_KVARH_DR(   10000),      \

    {0ll,0ll,0ll},0ll,0l,FRAC16(-1.0),                                                \

    {FRAC32(+0.00779293629195),FRAC32(+0.00779293629195),FRAC32(-0.98441412741610)},  \

    {0ll,0ll,0ll},{0ll,0ll,0ll}                                                       \

  }                                                                                   \

}

#endif  /* __METERLIB2PH1_CFG_H */

Thanks/regards,

K.Venkat

0 Kudos

809 Views
ivadorazinova
NXP Employee
NXP Employee

Hi Venkat.

I apologize for my late response.

Transfer delays on cascade of the filter is equal to the sum of all transfer delays.

So, if the signal passes through two filters - every has 36ms and then the result is equal to 2*36ms = 72ms

If it passes through three filters, where two of them has 36ms and the one has 217ms = then result is (36+36+217)ms.

In general, if you need low transfer delay, the filter must quickly converge,  but this convergence will affect very negatively transfer and phase characteristic. Thus you will quickly measure but with a large measurement error.

If you need quickly measure and accurately is suitable to use FFT algorithms, there is not settling time. The result is accurate and stable already after the first calculation.

Please, see for more details

FFT-Based Algorithm for Metering Applications

http://cache.nxp.com/files/32bit/doc/app_note/AN4255.pdf

Kinetis-M One-Phase Power Meter Reference Design

http://cache.nxp.com/files/32bit/doc/ref_manual/DRM143.pdf

Filter-Based Algorithm for Metering Applications

http://cache.nxp.com/files/32bit/doc/app_note/AN4265.pdf

I hope this helps you.

Best Regards,

Iva

0 Kudos

809 Views
venkatkrishna
Contributor II

Hi Iva,

           Thank you for your suggestion.

I am trying FFT and simple peak detection method to get quick response.I will update the result soon.

Thanks/regards,

K.Venkat

809 Views
venkatkrishna
Contributor II

Hai Eva,

                 I am using the demo code only.I have this config tool.

1)How to change in the existing demo code.

2)Is there any parameter regarding the response time.

   I want the urms and irms results in very next cycle  Pls help me.

3)Where to download the meterlib.c.

Thanks/regards,

K.Venkat

0 Kudos