I am reading a 0-5V range of voltage using readadc10 and need to multiply the word value (0-1024) by 0.488 (which happens to be 5/1024*100)
I use this :
readadc10 2, Voltage
let Temp = Voltage * 5 / 1024 * 100
A voltage that returns a word value of 311, therefore Voltage * 5 / 1024 = 1.512 but it truncates the result to 1.0 before dividing by 1024 so the result of Temp ends up being 100 when it should be 151. Is there a way to get around this truncation problem?
I can't simply make the formula :
let Temp = Voltage * 5 * 100 / 1024 because any value of "Voltage" over 131 will cause the Word to overflow
I use this :
readadc10 2, Voltage
let Temp = Voltage * 5 / 1024 * 100
A voltage that returns a word value of 311, therefore Voltage * 5 / 1024 = 1.512 but it truncates the result to 1.0 before dividing by 1024 so the result of Temp ends up being 100 when it should be 151. Is there a way to get around this truncation problem?
I can't simply make the formula :
let Temp = Voltage * 5 * 100 / 1024 because any value of "Voltage" over 131 will cause the Word to overflow