mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-01 13:38:38 -04:00
HAL_PX4: support voltage monitoring on multi-connector pin 5
This commit is contained in:
parent
8703d39475
commit
d7d87f827e
@ -19,6 +19,10 @@
|
||||
// for a range of known inputs from 1.3V to 5.0V
|
||||
#define PX4_AIRSPEED_VOLTAGE_SCALING (6.76f/4096.0f)
|
||||
|
||||
// the FMU battery mon port has some additional scaling to make it
|
||||
// safe for up to 18.68V.
|
||||
#define PX4_FMU_BATTERY_VOLTAGE_SCALING (18.68f/4096.0f)
|
||||
|
||||
// pin4 in the SPI port is analog input 13, marked as analog3 on the
|
||||
// PX4IO schematic v1.3, and is scaled quite strangely
|
||||
#define PX4_ANALOG3_VOLTAGE_SCALING (16.88f/4096.0f)
|
||||
@ -73,6 +77,9 @@ float PX4AnalogSource::read_latest()
|
||||
*/
|
||||
float PX4AnalogSource::voltage_average()
|
||||
{
|
||||
if (_pin == PX4_ANALOG_FMU_BATTERY) {
|
||||
return PX4_FMU_BATTERY_VOLTAGE_SCALING * read_average();
|
||||
}
|
||||
if (_pin == PX4_ANALOG_AIRSPEED_PIN) {
|
||||
return PX4_AIRSPEED_VOLTAGE_SCALING * read_average();
|
||||
}
|
||||
|
@ -14,6 +14,7 @@
|
||||
#define PX4_ANALOG_BATTERY_VOLTAGE_PIN 100
|
||||
#define PX4_ANALOG_BATTERY_CURRENT_PIN 101
|
||||
|
||||
#define PX4_ANALOG_FMU_BATTERY 10 // on multi-connector pin 5
|
||||
#define PX4_ANALOG_AIRSPEED_PIN 11
|
||||
#define PX4_ANALOG_ANALOG2_PIN 12 // on SPI port pin 3
|
||||
#define PX4_ANALOG_ANALOG3_PIN 13 // on SPI port pin 4
|
||||
|
Loading…
Reference in New Issue
Block a user