Dear all I have sampled some data using a 16bit ADC the data is in short(16-bit int) format, now I want to use the Cortex CMSIS DSP library to do some calculations like calculating rms values.I have used the arm_rms_q15 function, but the input to this function is in q15 format. How can I convert the short and other int types to the data that has been used in this library? Any ideas are welcome.
Then my numbers represent values in q15 format like this 1 equals 1/32768 or 3.051758E-06 2 equals 2/32768 or 6.10352E-06 3 equals 3/32768 or 9.15527E-06 4 equals 4/32768 or 1.2207E-05 5 equals 5/32768 or 1.52588E-05 6 equals 6/32768 or 1.83105E-05 7 equals 7/32768 or 2.13623E-05 8 equals 8/32768 or 2.44141E-05
But why I’m still getting zero from running the rms function? Please do not answer me by another question!? Char temp[100]; q15_t qdata[8]={1,2,3,4,5,6,7,8}; q15_t qres; arm_rms_q15(qdata,8,&qres);
and if I convert the result to float I still get zero
arm_q15_to_float(&qres,&res,1); sprintf(temp,"rms=%d f=%lf",qres,res);
Your input numbers are too few/small. The function arm_rms_q15 underflows when computing the RMS. After having computed the sum of the squares, it divides the result with 32768 before computing the square root.
But why I’m still getting zero from running the rms function?
You're not --- because you did not get zero before.
And why exactly do you think you have to printf() a float (not even a double) with %lf?
View all questions in Keil forum