mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
RM: Enabled optional modules and got the battery module working again.
Changed the hardcoded (ick) battery lines for RM. Also removed the reference to PIOS_ADC_GetPin(4) as that pin is no longer available. Finally changed the default FlightBatterySettings to work out of the box for the standard recommended sensors.
This commit is contained in:
parent
a33f415866
commit
f3327e3993
@ -55,9 +55,6 @@
|
||||
// Configuration
|
||||
//
|
||||
#define SAMPLE_PERIOD_MS 500
|
||||
#define BATTERY_BOARD_VOLTAGE_WARNING 4.5
|
||||
#define BATTERY_BOARD_VOLTAGE_CRITICAL 3.5
|
||||
#define BATTERY_BOARD_VOLTAGE_ERROR 1.0
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
@ -104,9 +101,6 @@ MODULE_INITCALL(BatteryInitialize, 0)
|
||||
static void onTimer(UAVObjEvent* ev)
|
||||
{
|
||||
static FlightBatteryStateData flightBatteryData;
|
||||
static bool BoardPowerWarning= false;
|
||||
// prevent that the initial ramp up of the power supply rail is identified as a power failure.
|
||||
static bool BoardPowerOk = false;
|
||||
FlightBatterySettingsData batterySettings;
|
||||
|
||||
FlightBatterySettingsGet(&batterySettings);
|
||||
@ -114,17 +108,11 @@ static void onTimer(UAVObjEvent* ev)
|
||||
static float dT = SAMPLE_PERIOD_MS / 1000.0;
|
||||
float energyRemaining;
|
||||
|
||||
if(HAS_SENSOR(FLIGHTBATTERYSETTINGS_SENSORTYPE_BOARDVOLTAGE) )
|
||||
flightBatteryData.BoardSupplyVoltage=((float)PIOS_ADC_PinGet(4)) * PIOS_ADC_VOLTAGE_SCALE * 6.1;
|
||||
else
|
||||
flightBatteryData.BoardSupplyVoltage = -1;
|
||||
|
||||
//calculate the battery parameters
|
||||
if(HAS_SENSOR(FLIGHTBATTERYSETTINGS_SENSORTYPE_BATTERYVOLTAGE) )
|
||||
flightBatteryData.Voltage = ((float)PIOS_ADC_PinGet(0)) * PIOS_ADC_VOLTAGE_SCALE * batterySettings.SensorCalibrations[FLIGHTBATTERYSETTINGS_SENSORCALIBRATIONS_VOLTAGEFACTOR]; //in Volts
|
||||
else
|
||||
flightBatteryData.Voltage = -1;
|
||||
|
||||
|
||||
if(HAS_SENSOR(FLIGHTBATTERYSETTINGS_SENSORTYPE_BATTERYCURRENT))
|
||||
{
|
||||
@ -188,38 +176,6 @@ static void onTimer(UAVObjEvent* ev)
|
||||
}
|
||||
}
|
||||
|
||||
if(HAS_SENSOR(FLIGHTBATTERYSETTINGS_SENSORTYPE_BOARDVOLTAGE) )
|
||||
{
|
||||
// power ia disconnected from the board (it is powered by usb)
|
||||
if(flightBatteryData.BoardSupplyVoltage!= -1 && flightBatteryData.BoardSupplyVoltage < BATTERY_BOARD_VOLTAGE_ERROR)
|
||||
{
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_POWER, SYSTEMALARMS_ALARM_ERROR);
|
||||
BoardPowerWarning=false;
|
||||
BoardPowerOk = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(BoardPowerOk && flightBatteryData.BoardSupplyVoltage < BATTERY_BOARD_VOLTAGE_CRITICAL)
|
||||
{
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_POWER, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
BoardPowerWarning=true;
|
||||
}
|
||||
else if (BoardPowerOk && flightBatteryData.BoardSupplyVoltage < BATTERY_BOARD_VOLTAGE_WARNING)
|
||||
{
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_POWER, SYSTEMALARMS_ALARM_WARNING);
|
||||
BoardPowerWarning=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if there was any previous warning/critical condition, notify the problem leaving the warning
|
||||
if(BoardPowerWarning)
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_POWER, SYSTEMALARMS_ALARM_WARNING);
|
||||
else
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_POWER);
|
||||
BoardPowerOk |= flightBatteryData.BoardSupplyVoltage > BATTERY_BOARD_VOLTAGE_WARNING;
|
||||
}
|
||||
}
|
||||
}
|
||||
FlightBatteryStateSet(&flightBatteryData);
|
||||
}
|
||||
|
||||
|
@ -259,12 +259,12 @@ extern uint32_t pios_packet_handler;
|
||||
// PIOS_ADC_PinGet(4) = VREF
|
||||
// PIOS_ADC_PinGet(5) = Temperature sensor
|
||||
//-------------------------
|
||||
#define PIOS_DMA_PIN_CONFIG \
|
||||
{ \
|
||||
{GPIOC, GPIO_Pin_0, ADC_Channel_10}, \
|
||||
{GPIOC, GPIO_Pin_1, ADC_Channel_11}, \
|
||||
{NULL, 0, ADC_Channel_Vrefint}, /* Voltage reference */ \
|
||||
{NULL, 0, ADC_Channel_TempSensor}, /* Temperature sensor */ \
|
||||
#define PIOS_DMA_PIN_CONFIG \
|
||||
{ \
|
||||
{GPIOC, GPIO_Pin_1, ADC_Channel_11}, \
|
||||
{GPIOC, GPIO_Pin_2, ADC_Channel_12}, \
|
||||
{NULL, 0, ADC_Channel_Vrefint}, /* Voltage reference */ \
|
||||
{NULL, 0, ADC_Channel_TempSensor}, /* Temperature sensor */ \
|
||||
{GPIOC, GPIO_Pin_2, ADC_Channel_12} \
|
||||
}
|
||||
|
||||
|
@ -52,12 +52,12 @@ FLASH_TOOL = OPENOCD
|
||||
MODULES = Sensors
|
||||
MODULES += Attitude/revolution
|
||||
MODULES += ManualControl Stabilization Actuator
|
||||
#MODULES += Battery
|
||||
MODULES += Battery
|
||||
MODULES += Altitude/revolution
|
||||
MODULES += GPS FirmwareIAP
|
||||
#MODULES += Airspeed/revolution
|
||||
#MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner
|
||||
#MODULES += CameraStab
|
||||
MODULES += AltitudeHold VtolPathFollower FixedWingPathFollower PathPlanner
|
||||
MODULES += CameraStab
|
||||
MODULES += Radio
|
||||
MODULES += Telemetry
|
||||
PYMODULES =
|
||||
|
@ -39,7 +39,7 @@
|
||||
#define PIOS_INCLUDE_BL_HELPER
|
||||
|
||||
/* Enable/Disable PiOS Modules */
|
||||
//#define PIOS_INCLUDE_ADC
|
||||
#define PIOS_INCLUDE_ADC
|
||||
#define PIOS_INCLUDE_DELAY
|
||||
#define PIOS_INCLUDE_I2C
|
||||
#define PIOS_INCLUDE_IRQ
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
<field name="VoltageThresholds" units="V" type="float" elementnames="Warning, Alarm" defaultvalue="9.8, 9.2"/>
|
||||
|
||||
<field name="SensorType" units="" type="enum" elementnames="BatteryCurrent,BatteryVoltage,BoardVoltage" options="Disabled,Enabled" defaultvalue="Disabled"/>
|
||||
<field name="SensorCalibrations" units="" type="float" elementnames="VoltageFactor, CurrentFactor" defaultvalue="1.0, 1.0"/>
|
||||
<field name="SensorType" units="" type="enum" elementnames="BatteryCurrent,BatteryVoltage" options="Disabled,Enabled" defaultvalue="Enabled,Enabled"/>
|
||||
<field name="SensorCalibrations" units="" type="float" elementnames="VoltageFactor, CurrentFactor" defaultvalue="1.0, 1.0"/>
|
||||
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user