mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 13:55:40 +08:00
[boards] ardone2: correct voltage scale, thx Eric
This commit is contained in:
@@ -89,14 +89,9 @@ void electrical_periodic(void) {
|
|||||||
// we know from spec sheet that ADCIN0 has no prescaler
|
// we know from spec sheet that ADCIN0 has no prescaler
|
||||||
// so that the max voltage range is 1.5 volt
|
// so that the max voltage range is 1.5 volt
|
||||||
// multiply by ten to get decivolts
|
// multiply by ten to get decivolts
|
||||||
electrical.vsupply = 10 * electrical_calculate_voltage(raw_voltage, 1.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
float electrical_calculate_voltage(int raw, float range_max)
|
//from raw measurement we got quite a lineair response
|
||||||
{
|
//9.0V=662, 9.5V=698, 10.0V=737,10.5V=774, 11.0V=811, 11.5V=848, 12.0V=886, 12.5V=923
|
||||||
float step_size = 1.5/(pow(2,10)-1);
|
//leading to our 0.13595166 magic number for decivolts conversion
|
||||||
float R = ( 1.5 / range_max );
|
electrical.vsupply = raw_voltage*0.13595166;
|
||||||
float output = (float)raw * ( step_size / R );
|
|
||||||
|
|
||||||
return 6.6 + (3 * output); // todo improve this line to get more accurate voltage readings
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,5 @@
|
|||||||
#include "subsystems/electrical.h"
|
#include "subsystems/electrical.h"
|
||||||
|
|
||||||
void electrical_setup(void);
|
void electrical_setup(void);
|
||||||
float electrical_calculate_voltage(int raw, float range_max);
|
|
||||||
|
|
||||||
#endif /* ELECTRICAL_RAW_H_ */
|
#endif /* ELECTRICAL_RAW_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user