johnmobley
New Member
I have a problem with some math operations. I understand what is going on, but I dont know how to overcome the problem.
I have an ADC value that I need to convert to a corresponding weight. In the real world the formula for this is:
ADC / 1.023 = Weight
I know that I can not work with decimals with the PICAXE so I multilpied the formula by 1000 to get rid of the decimal for a formula of:
(ADC * 1000) / 1023 = Weight
This works great upto an adc value of 65. At an adc value of 66 I get an overflow issue. I know that this happens because the "word" range is 0-65535 and my formula creates a value of 66000. I am using readadc10 and so my adc range is going to go to 1023 and this is going to leave most of my range unreadable/unusable.
What can I do to overcome this issue other than sacrificing accuracy?
I have an ADC value that I need to convert to a corresponding weight. In the real world the formula for this is:
ADC / 1.023 = Weight
I know that I can not work with decimals with the PICAXE so I multilpied the formula by 1000 to get rid of the decimal for a formula of:
(ADC * 1000) / 1023 = Weight
This works great upto an adc value of 65. At an adc value of 66 I get an overflow issue. I know that this happens because the "word" range is 0-65535 and my formula creates a value of 66000. I am using readadc10 and so my adc range is going to go to 1023 and this is going to leave most of my range unreadable/unusable.
What can I do to overcome this issue other than sacrificing accuracy?