My ADC conversion code (Courtesy This Post)
I am using dsPIC30F.
The first statement generates a code which runs in 25 cycles which is reasonable for me.
But the second line takes around 350 cycles which seems not a informed choice.
I am not that much familiar in fixed or floating point methods.
But from my reading it seems to me that there should be some economical methods to multiply by 2.2698... in fixed point library.
to multiply by 2.2698.. first I left shift once - which completes the multiplication by 2
now I need to multiply by .2695... using Q15 functions and then add.
How to do this?
Can I get a optimum method to implement my task with the help of DSP features of dsPIC30F controller.
Thanks
Rich (BB code):
// Pressure sensor is for 600bar in 0to 5V out - so to get a decimal place I am using 6000 !
PressureinBarWithOneDeciPlace=((((((unsigned long)ADCResultofPSensor*2)+1) *6000) +1024) /2048);
LoadInKNWithOneDeciplace= (unsigned int)((float)PressureinBarWithOneDeciPlace*2.2698006535F);
The first statement generates a code which runs in 25 cycles which is reasonable for me.
But the second line takes around 350 cycles which seems not a informed choice.
I am not that much familiar in fixed or floating point methods.
But from my reading it seems to me that there should be some economical methods to multiply by 2.2698... in fixed point library.
to multiply by 2.2698.. first I left shift once - which completes the multiplication by 2
now I need to multiply by .2695... using Q15 functions and then add.
How to do this?
Can I get a optimum method to implement my task with the help of DSP features of dsPIC30F controller.
Thanks