Large multiplication
Posted: Mon May 30, 2011 4:24 pm
Hello all,
I'm somewhat in a jam.
I have a multiplication to do however it only works partially:
T2 = 11 * (C6 +24) * (200 - TEMP) * (200 - TEMP) / 2^20
I have made a C Code box with the following lines:
long t2;
t2 = 11 * (FCV_C6 + 24); This parts is alwas 561
t2 = t2 * (200-FCV_TEMP); TEMP can be anywhere from -150 to 199
t2 = t2 * (200-FCV_TEMP);
t2 = t2 >> 20;
FCV_T2 = t2;
The problem is that the calculation works untill TEMP = -55. As soon as the TEMP is lower as -55 the T2 goes to 0
My question is; Can a PIC18F4685 actally handly such a calculation?
If it does, what am I doing wrong?
Thanks
Henk
I'm somewhat in a jam.
I have a multiplication to do however it only works partially:
T2 = 11 * (C6 +24) * (200 - TEMP) * (200 - TEMP) / 2^20
I have made a C Code box with the following lines:
long t2;
t2 = 11 * (FCV_C6 + 24); This parts is alwas 561
t2 = t2 * (200-FCV_TEMP); TEMP can be anywhere from -150 to 199
t2 = t2 * (200-FCV_TEMP);
t2 = t2 >> 20;
FCV_T2 = t2;
The problem is that the calculation works untill TEMP = -55. As soon as the TEMP is lower as -55 the T2 goes to 0
My question is; Can a PIC18F4685 actally handly such a calculation?
If it does, what am I doing wrong?
Thanks
Henk