Gathiyo / arducopter

Automatically exported from code.google.com/p/arducopter
0 stars 0 forks source link

Low priority error with battery/current readings #284

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
defines.h (line 283):
#define BATTERY_VOLTAGE(x) (x*(g.input_voltage/1024.0))*VOLT_DIV_RATIO
#define CURRENT_AMPS(x) 
((x*(g.input_voltage/1024.0))-CURR_AMPS_OFFSET)*CURR_AMP_PER_VOLT

It should be:
#define BATTERY_VOLTAGE(x) (x*(g.input_voltage/1023.0))*VOLT_DIV_RATIO
#define CURRENT_AMPS(x) 
((x*(g.input_voltage/1023.0))-CURR_AMPS_OFFSET)*CURR_AMP_PER_VOLT

analogRead() retuns values from 0 to 1023 
(http://www.arduino.cc/en/Reference/AnalogRead).

Example: 

g.input_voltage = 5
x = 1023 (we read the maximum value)

x*(g.input_voltage/1024.0) = 1023*(5/1024.0) = 4.9951 (wrong, it should be 
5.0000)

I know... the result is almost the same but it's not 100% correct.

Original issue reported on code.google.com by modc...@gmail.com on 29 Nov 2011 at 7:23

GoogleCodeExporter commented 8 years ago
Thanks!

Original comment by jasonshort on 29 Nov 2011 at 9:09

GoogleCodeExporter commented 8 years ago
Thanks!
Jason

Original comment by jasonshort on 7 Jan 2012 at 5:17

GoogleCodeExporter commented 8 years ago
Thanks!
Jason

Original comment by jasonshort on 7 Jan 2012 at 5:19