aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-05-01 15:06:13 +1000
committerAndrew Tridgell <tridge@samba.org>2013-05-04 19:18:47 +1000
commit44015d69154062d42ecc3aa0c9b25d7019bd5a71 (patch)
treeef8374c54c093d43ce0c07b82245a3590fda20fb /src
parent5b3844621ca1c0a6181e49166c5c12f3000f6802 (diff)
downloadpx4-firmware-44015d69154062d42ecc3aa0c9b25d7019bd5a71.tar.gz
px4-firmware-44015d69154062d42ecc3aa0c9b25d7019bd5a71.tar.bz2
px4-firmware-44015d69154062d42ecc3aa0c9b25d7019bd5a71.zip
px4io: return raw ADC value for current
we don't know how to scale it as we have no info on what sensor is attached. As we are returning a uint16_t it is better to let the FMU sort it out or we'll just lose precision.
Diffstat (limited to 'src')
-rw-r--r--src/modules/px4iofirmware/protocol.h4
-rw-r--r--src/modules/px4iofirmware/registers.c16
2 files changed, 9 insertions, 11 deletions
diff --git a/src/modules/px4iofirmware/protocol.h b/src/modules/px4iofirmware/protocol.h
index 8d8b7e941..b80551a07 100644
--- a/src/modules/px4iofirmware/protocol.h
+++ b/src/modules/px4iofirmware/protocol.h
@@ -115,7 +115,7 @@
#define PX4IO_P_STATUS_ALARMS_PWM_ERROR (1 << 6) /* PWM configuration or output was bad */
#define PX4IO_P_STATUS_VBATT 4 /* battery voltage in mV */
-#define PX4IO_P_STATUS_IBATT 5 /* battery current in cA */
+#define PX4IO_P_STATUS_IBATT 5 /* battery current (raw ADC) */
/* array of post-mix actuator outputs, -10000..10000 */
#define PX4IO_PAGE_ACTUATORS 2 /* 0..CONFIG_ACTUATOR_COUNT-1 */
@@ -155,8 +155,6 @@
#define PX4IO_P_SETUP_PWM_ALTRATE 4 /* 'high' PWM frame output rate in Hz */
#define PX4IO_P_SETUP_RELAYS 5 /* bitmask of relay/switch outputs, 0 = off, 1 = on */
#define PX4IO_P_SETUP_VBATT_SCALE 6 /* battery voltage correction factor (float) */
-#define PX4IO_P_SETUP_IBATT_SCALE 7 /* battery current scaling factor (float) */
-#define PX4IO_P_SETUP_IBATT_BIAS 8 /* battery current bias value */
#define PX4IO_P_SETUP_SET_DEBUG 9 /* debug level for IO board */
/* autopilot control values, -10000..10000 */
diff --git a/src/modules/px4iofirmware/registers.c b/src/modules/px4iofirmware/registers.c
index 6c09def9e..9f9c50048 100644
--- a/src/modules/px4iofirmware/registers.c
+++ b/src/modules/px4iofirmware/registers.c
@@ -138,8 +138,6 @@ volatile uint16_t r_page_setup[] =
[PX4IO_P_SETUP_PWM_ALTRATE] = 200,
[PX4IO_P_SETUP_RELAYS] = 0,
[PX4IO_P_SETUP_VBATT_SCALE] = 10000,
- [PX4IO_P_SETUP_IBATT_SCALE] = 0,
- [PX4IO_P_SETUP_IBATT_BIAS] = 0,
[PX4IO_P_SETUP_SET_DEBUG] = 0,
};
@@ -516,12 +514,14 @@ registers_get(uint8_t page, uint8_t offset, uint16_t **values, unsigned *num_val
/* PX4IO_P_STATUS_IBATT */
{
- unsigned counts = adc_measure(ADC_VBATT);
- unsigned scaled = (counts * r_page_setup[PX4IO_P_SETUP_IBATT_SCALE]) / 10000;
- int corrected = scaled + REG_TO_SIGNED(r_page_setup[PX4IO_P_SETUP_IBATT_BIAS]);
- if (corrected < 0)
- corrected = 0;
- r_page_status[PX4IO_P_STATUS_IBATT] = corrected;
+ /*
+ note that we have no idea what sort of
+ current sensor is attached, so we just
+ return the raw 12 bit ADC value and let the
+ FMU sort it out, with user selectable
+ configuration for their sensor
+ */
+ r_page_status[PX4IO_P_STATUS_IBATT] = adc_measure(ADC_IN5);
}
SELECT_PAGE(r_page_status);