Owne / ardupilot-mega

Automatically exported from code.google.com/p/ardupilot-mega
0 stars 0 forks source link

low battery even on battery disconnection #320

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. enable the battery failsafe event
2. do not connect voltage sensor to battery

What is the expected output? What do you see instead?
For saftey, the UAV should not run a battery failsafe event if no battery is 
connected.

In my code I've made the following changes to events.pde and call the new 
function from init_ardupilot....

#if BATTERY_EVENT == 1
void read_battery(void)
{

......existing code here...

        if (abs(BATTERY_VOLTAGE(analogRead(BATTERY_PIN1)) - battery_voltage1 ) > 1)
                init_battery();

       #if BATTERY_TYPE == 0
        if(battery_voltage3 < LOW_VOLTAGE && battery_voltage3 > 9)
            low_battery_event();
        battery_voltage = battery_voltage3; // set total battery voltage, for telemetry stream
                battery_remaining = max((battery_voltage-9.6)/0.003,0);
    #endif

    #if BATTERY_TYPE == 1
        if(battery_voltage4 < LOW_VOLTAGE && battery_voltage4 > 12)
            low_battery_event();
        battery_voltage = battery_voltage4; // set total battery voltage, for telemetry stream
                battery_remaining = max((battery_voltage-12.8)/0.004,0);
    #endif  
}
#endif

#if BATTERY_EVENT == 1
void init_battery(void)
{
        for(int8_t i = 0; i<5; i++){
            battery_voltage1 = BATTERY_VOLTAGE(analogRead(BATTERY_PIN1)) * .5 + battery_voltage1 * .5;
            battery_voltage2 = BATTERY_VOLTAGE(analogRead(BATTERY_PIN2)) * .5 + battery_voltage2 * .5;
            battery_voltage3 = BATTERY_VOLTAGE(analogRead(BATTERY_PIN3)) * .5 + battery_voltage3 * .5;
            battery_voltage4 = BATTERY_VOLTAGE(analogRead(BATTERY_PIN4)) * .5 + battery_voltage4 * .5;
        }
}
#endif

Original issue reported on code.google.com by whitm...@gmail.com on 17 Apr 2011 at 3:17

GoogleCodeExporter commented 8 years ago
Please see comments for issue 298 and don't enable BATTERY_EVENT unless you 
want to have low voltage/high discharge failsafe events occur (even if you 
don't have a battery connected).  They are no longer tied to battery 
monitoring, or you might say battery monitoring is no longer tied to 
BATTERY_EVENT.

Original comment by dewei...@gmail.com on 21 Apr 2011 at 3:57