sayzer
- 11th May 2006, 07:14
Is it too early to call this a bug? Or the bug is in my head?
Attached is an excel file (file extension needs to be changed to xls).
There is a match-table in the file. The red cells are incorrect math results from PIC. All other values provide the correct math result.
(16F877 with PBP2.46)
- All variables are word size.
- 20Mhz OSC and 10-bit ADC res.
'
'This is only the loop part.
'
Loop:
ADCIN 1,TempRead
IF tempread>51200 THEN tempread=51200 'Min. temp.
IF tempread<41600 THEN tempread=41600 'Max. temp.
XF=( TempRead /64)-650 'This is the formula with 1 unit increments.
XB=303 'This is the initial matching Temp value.
FOR XA=0 to 150
XB=XB-2 'Each 64 unit increment/decrement is 2˚C
if XF =XA then XF =XB 'We get the actual temp in Celsius.
next XA
Lcdout $fe,1,”Temp:”, #XF
GoTo loop
For example, if the TempRead value is 44864, then I get the XF as 199 which is correct.
However, if the TemRead value is 46464 then I get XF as 3 which is incorrect. I should be getting 149.
From 46464 to 48000 all results are incorrect. Remaining values are correct.
Should we call this a bug, I am not sure.
------------------------
Attached is an excel file (file extension needs to be changed to xls).
There is a match-table in the file. The red cells are incorrect math results from PIC. All other values provide the correct math result.
(16F877 with PBP2.46)
- All variables are word size.
- 20Mhz OSC and 10-bit ADC res.
'
'This is only the loop part.
'
Loop:
ADCIN 1,TempRead
IF tempread>51200 THEN tempread=51200 'Min. temp.
IF tempread<41600 THEN tempread=41600 'Max. temp.
XF=( TempRead /64)-650 'This is the formula with 1 unit increments.
XB=303 'This is the initial matching Temp value.
FOR XA=0 to 150
XB=XB-2 'Each 64 unit increment/decrement is 2˚C
if XF =XA then XF =XB 'We get the actual temp in Celsius.
next XA
Lcdout $fe,1,”Temp:”, #XF
GoTo loop
For example, if the TempRead value is 44864, then I get the XF as 199 which is correct.
However, if the TemRead value is 46464 then I get XF as 3 which is incorrect. I should be getting 149.
From 46464 to 48000 all results are incorrect. Remaining values are correct.
Should we call this a bug, I am not sure.
------------------------