aboutsummaryrefslogtreecommitdiff
path: root/src/modules/px4iofirmware/registers.c
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2014-07-21 13:31:35 +0200
committerLorenz Meier <lm@inf.ethz.ch>2014-07-21 13:31:35 +0200
commit956c084f31af9ec2aa80d61eee17e7506b4c7172 (patch)
treea68a36f274a8dd8026ec4ac20ed32b3bad800e65 /src/modules/px4iofirmware/registers.c
parentafff12374240240ec2bbf2ba043b37cca8b3298a (diff)
downloadpx4-firmware-956c084f31af9ec2aa80d61eee17e7506b4c7172.tar.gz
px4-firmware-956c084f31af9ec2aa80d61eee17e7506b4c7172.tar.bz2
px4-firmware-956c084f31af9ec2aa80d61eee17e7506b4c7172.zip
Fit IO voltage estimation using a new dataset, cross-validated with a second unit. Pending testing
Diffstat (limited to 'src/modules/px4iofirmware/registers.c')
-rw-r--r--src/modules/px4iofirmware/registers.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/modules/px4iofirmware/registers.c b/src/modules/px4iofirmware/registers.c
index fcd53f1f1..7fbb0ecf1 100644
--- a/src/modules/px4iofirmware/registers.c
+++ b/src/modules/px4iofirmware/registers.c
@@ -739,30 +739,17 @@ registers_get(uint8_t page, uint8_t offset, uint16_t **values, unsigned *num_val
{
/*
* Coefficients here derived by measurement of the 5-16V
- * range on one unit:
+ * range on one unit, validated on sample points of another unit
*
- * V counts
- * 5 1001
- * 6 1219
- * 7 1436
- * 8 1653
- * 9 1870
- * 10 2086
- * 11 2303
- * 12 2522
- * 13 2738
- * 14 2956
- * 15 3172
- * 16 3389
+ * Data in Tools/tests-host/data folder.
*
- * slope = 0.0046067
- * intercept = 0.3863
+ * slope = 0.004585267878277 (int: 4585)
+ * intercept = 0.016646394188076 (int: 16646
*
- * Intercept corrected for best results @ 12V.
*/
unsigned counts = adc_measure(ADC_VBATT);
if (counts != 0xffff) {
- unsigned mV = (4150 + (counts * 46)) / 10 - 200;
+ unsigned mV = (16646 + (counts * 4585)) / 1000;
unsigned corrected = (mV * r_page_setup[PX4IO_P_SETUP_VBATT_SCALE]) / 10000;
r_page_status[PX4IO_P_STATUS_VBATT] = corrected;