How to test twrkm35z75m_meterlibph_test example project in TWRKM35z75M board?

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

How to test twrkm35z75m_meterlibph_test example project in TWRKM35z75M board?

1,759 Views
GanesanGuru
Contributor IV

Hi all, @xiangjun_rong 

I've been trying to learn twrkm35z75m_meterlibph_test project with SDK_2.x_TWR-KM35Z75M with metering library. There, phase V / I samples are read from AFE and passed to the metering algorithm via METERLIB1PH_ProcSamples(). 

Yet, I can't find any AFE converted values are being used in twrkm35z75m_meterlibph_test examples, as in contrast, in twrkm35z75m_afe_polling example project - I can see API's like AFE_Init, AFE_SetChannelConfig, AFE_DoSoftwareTriggerChannel,AFE_GetChannelConversionValue,etc.

Also, in example,twrkm35z75m_meterlibFFT1ph_test even the fsl_afe driver is not added. Why is it so? Without driver for AFE, how can the meter example has been developed?!So can someone explain how to setup and how does the example project work?!

Testing Environment:

  1. OS - Ubuntu 
  2. IDE - MCUXpresso IDE
  3. SDK - SDK_2.14.0_TWR-KM35Z75M built using online SDK builder with metering middleware enabled
  4. Project - demo_apps/twrkm35z75m_meterlibph_test
0 Kudos
Reply
2 Replies

1,751 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

Thank you, I will download SDK and have a test soon.

BR

XiangJun Rong

1,736 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

The twrkm35z75m_meterlibph_test example is a simulator rather than actual system.

Pls refer to the code especially fill_buffers(), which assign the voltage and current array with a predefined sine table.

 

while(1)

{

/* ADC sampling simulation (function fills-up both U and I buffers) */

adc_samples = fill_buffers(u_re, i_re);

 

#if AFE_MODE == 1 /* asynchronous or synchronous processing? */

/* performs interpolation only for asynchronous processing */

fcn_out = METERLIBFFT1PH_Interpolation(&ui, ORD2, ORD2, adc_samples);

#endif

 

/* main calculation (FFT, I-signal conditioning, scaling, averaging) */

METERLIBFFT1PH_CalcMain(&ui);

 

/* gets 16 FFT magnitudes (auxiliary output only) */

METERLIBFFT1PH_GetMagnitudes(&ui, 16);

..............

}

The function body of api function fill_buffers():

unsigned long fill_buffers (frac24 *u, frac24 *i)

{

unsigned long samp = INP_SAMPLES;/* integer or power-of two input samples */

long *pu,*pi; /* pointers to U and I data table */

 

#if AFE_MODE == 1 /* Asynchronous S/W triggered continuous conversion mode */

pu = sinus65_24bit; /* set pointer to the beginning of U-LUT, 65 points */

pi = sinus65_24bit_45deg;/* set pointer to the beginning of I-LUT,65 points,45� shift */

#else /* Synchronous H/W triggered single conversion mode */

pu = sinus32_24bit; /* set pointer to the beginning of U-LUT, 32 points */

pi = sinus32_24bit_45deg;/* set pointer to the beginning of I-LUT,32 points,45� shift */

#endif

for (unsigned long cnt = 0; cnt < samp; cnt++)

{

u[cnt] = (*pu++); /* copy U-binary values from LUT to the U-output buffer */

i[cnt] = (*pi++); /* copy I-binary values from LUT to the I-output buffer */

}

return (samp);

}

 The array sinus32_24bit[] is from inputdata.h

 

/* sinus 32 points, 1-st harmonic only, scaled to 24-bit */

frac24 sinus32_24bit[]={

0 ,

1636536 ,

3210181 ,

4660461 ,

5931642 ,

6974873 ,

7750063 ,

8227423 ,

8388607 ,

8227423 ,

.....

}

The array sinus32_24bit_45deg[] is from inputdata.h

frac24 sinus32_24bit_45deg[]={

5931642 ,

6974873 ,

7750063 ,

8227423 ,

8388607 ,

8227423 ,

7750063 ,

6974873 ,

5931642 ,

4660461 ,

........

}

For an actual system, the two array should be from sample of U and I.

 

Hope it can help you

BR

XiangJun Rong