Hi,
I am having trouble with the conversion of the calibadc10 into a decimal number to display.
the code below aims to calculate two variables containing the units and two decimal points.
This code however gives me the following issues:
1) it never gives uneven decimals (it will never give 4.57V, only 4.56 or 4.58).
2) when the battery progressively discharges I get the following: 5.12 ... 5.10 ... 5.00 ... 5.8
I think the error might be in my (mis)understanding of the Picaxe maths. Could someone give me a pointer?
Also the only use for these variables is to create a string to sent to the LCD screen and to a web server (via a serial call to ESP8266). Is there a better way of doing this and save on code space?
Many Thanks
Riccardo
I am having trouble with the conversion of the calibadc10 into a decimal number to display.
the code below aims to calculate two variables containing the units and two decimal points.
Code:
getVoltage:
calibadc10 voltUnit
voltDec = Vref*50/voltUnit *2
voltUnit = Vref/voltUnit
voltUnit = voltUnit * 50
voltUnit = voltUnit * 2
voltDec = voltDec - voltUnit
voltUnit = voltUnit / 2
voltUnit = voltUnit / 50
1) it never gives uneven decimals (it will never give 4.57V, only 4.56 or 4.58).
2) when the battery progressively discharges I get the following: 5.12 ... 5.10 ... 5.00 ... 5.8
I think the error might be in my (mis)understanding of the Picaxe maths. Could someone give me a pointer?
Also the only use for these variables is to create a string to sent to the LCD screen and to a web server (via a serial call to ESP8266). Is there a better way of doing this and save on code space?
Many Thanks
Riccardo