Type conversion(short to Q15)Dear all
Posted 30 July 2011 - 09:17 AM
I have sampled some data using a 16bit ADC the data is inshort(16-bit int) format, now I want to use the Cortex CMSIS DSP library to do some calculations likecalculating rms values.I have used the arm_rms_q15function, but the input to this function is in q15 format. How can I convertthe short and other int types to the data that has been used in this library?
Any ideas are welcome.
Posted 01 August 2011 - 01:23 PM
I don't know that library, but look at that wiki link !
Q15 is particularly designed for data ranging [-1;+1[ (like result of sin/cos).
For RMS calculation, I think the result should have the same scale as input data (could someone confirm please ?).
So, if your input data is unsigned, divide by 2 (to preserve the sign bit), transmit to RMS function, then mult by 2 for having same scale that original data. You loose 1-bit of precision.
If your input data is signed (2's complement), transmit as it is.
If your input data is signed (shift signed), sub 0x8000 then transmit.
For a better help, you should provide the physical representation of data returned from ADC, e.g. :
phy range : [0;5[ volt <==> data16 : [0x0000;0xFFFF] (unsigned)
or [-5;5[ volt <==> [0x8000;0x7FFF] (signed 2's complement)
or [-5;5[ volt <==> [0x0000;0xFFFF] (shift signed)