This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Trouble using ADC data with DSP

All,

I have a task to acquire a block of ADC samples, process them, and display the rms result. I have successfully setup the processor on a nucleo STM32F401 development board, and can read ADC data plus compute the rms of that dataset.

My trouble occurs when I process the data using arm_biquad_cascade_df1_f32. The rms output is always "1.#INF". I have checked the initialization code, the arrays, etc. The processed data array is >400 samples long and generally becomes +- infinity after a couple hundred data points.

As indicated, the code functions correctly, including performing the same rms function on the sample array. So if I had a 2 V DC signal on the ADC pin, the rms would read approximately 2482 ( [2482/4095] * 3.3V = 2V).

I suspect my problem lies with either the coefficients (I don't believe the polarity on a1 or a2 need to be flipped, but I could be wrong), which were calculated using matlab ellip function,

www.mathworks.com/.../ellip.html

or in my attempt to convert ADC int32 data to float. I have read several forums, which I can list if desired, but I am still not successful. I have 2 arrays; the first is a reference to compare and the second is my original array.

applicable ADC code:
float32_t temp_f = 0.0;
temp_f = HAL_ADC_GetValue(&hadc1);
ADC_samples_ref[BLOCKSIZE] = temp_f;
ADC_samples_L[BLOCKSIZE] = ((temp_f-2048)/4095) * S1_Gain; //S1_Gain is the filter gain from matlab

applicable processing code:
arm_biquad_casd_df1_inst_f32 S1;
float32_t *S1_pState[4*NUMSTAGES];
const float32_t S1_coeffs[5*NUMSTAGES] = {numbers}; // I'm omiting these numbers in this thread
arm_biquad_cascade_df1_init_f32(&S1, NUMSTAGES, (float32_t *) &S1_coeffs[0], *S1_pState);

arm_rms_f32(ADC_samples_ref, BLOCKSIZE, &ref_rms); // used only to troubleshoot and validate filters work

arm_biquad_cascade_df1_f32(&S1, (float32_t *) &ADC_samples_L[0], (float32_t *) &low_proc[0], BLOCKSIZE);
arm_rms_f32((float32_t *) &low_proc[0], BLOCKSIZE, &low__rms);

I hope this is enough information for assistance; I'm trying to avoid posting large blocks of code. Please let me know if you see a problem, particularly with how I'm creating the floating array, which as I said is where I suspect I have a problem if not the matlab coefficients.

0