Now we are working to create a program where we will guide our aircraft in case of insufficient battery. For this purpose we have added a voltage divider circuit, using 1k (R1) and .33k (R2) ohm resistances, to our existing UDB4 board and made the following changes in the telemetry.c file:
#define batt_min_value 88
///////////////////////// battery health testing code
if(udb_analogInputs[0].value<batt_min_value)
{
init_flightplan( 1 );
}
//////////////////////////////////////////////////////
Here udb_analogInputs[0].value is real-time or current value that comes on one of our Analog pins of PIC controller (from AN15 to AN 18). If it goes below a certain value (for 3S LIPO battery - below 3.6 Volts each or net 10.8 Volts) then the program will switch to Return to Land (RTL) mode.
In order to read what exact value that will come at full charge i.e. 12.48 Volts on the Analog Pins we replaced our diff in telemetry.c with udb_analogInputs[0].value so that we may set our batt_min_value:
// The Ardupilot GroundStation protocol is mostly documented here:
// http://diydrones.com/profiles/blogs/ardupilot-telemetry-protocol
///////////////////////// battery health testing code
if(udb_analogInputs[0].value<batt_min_value)
{
init_flightplan( 1 );
}
//////////////////////////////////////////////////////
if (udb_heartbeat_counter % 40 == 0) // Every 8 runs (5 heartbeat counts per 8Hz)
{
serial_output("!!!LAT:%li,LON:%li,SPD:%.2f,CRT:%.2f,ALT:%li,ALH:%i,CRS:%.2f,BER:%i,WPN:%i,DST:%i,BTV:%.2f***\r\n"
"+++THH:%i,RLL:%li,PCH:%li,STT:%i,***\r\n",
lat_gps.WW / 10 , long_gps.WW / 10 , (float)(sog_gps.BB / 100.0), (float)(climb_gps.BB / 100.0),
(alt_sl_gps.WW - alt_origin.WW) / 100, desiredHeight, (float)(cog_gps.BB / 100.0), desired_dir_deg,
waypointIndex, udb_analogInputs[0].value, (float)(voltage_milis.BB / 100.0),
(int16_t)((udb_pwOut[THROTTLE_OUTPUT_CHANNEL] - udb_pwTrim[THROTTLE_OUTPUT_CHANNEL])/20),
earth_roll, earth_pitch,
mode
) ;
}
We will be able to monitor it on Happy Killmore GCS software as we did our diff variable earlier (Switch-out from Auto-Pilot Mode : Another function for #UAV)
Also, if init_flightplan( 1 ); is set to one as here, then we will be able to switch to RTL mode or else not as we can see in the flightplan-waypoints.c file:
// In the future, we could include more than 2 waypoint sets...
// flightplanNum is 0 for main waypoints, and 1 for RTL waypoints
void init_flightplan ( int16_t flightplanNum )
{
if ( flightplanNum == 1 ) // RTL waypoint set
{
currentWaypointSet = (struct waypointDef*)rtlWaypoints ;
numPointsInCurrentSet = NUMBER_RTL_POINTS ;
}
else if ( flightplanNum == 0 ) // Main waypoint set
{
currentWaypointSet = (struct waypointDef*)waypoints ;
numPointsInCurrentSet = NUMBER_POINTS ;
}
Unfortunately, the problem is that when you detect a voltage drop, it is normally too late, and you dont have enough juice to come back. This because the discharge curve of the lipo battery drops suddenly when no power is left.
ReplyDeleteimho, a potentially better way to get this, is to monitor the milliamps/h you are sucking from the battery during its whole discharge process(assuming that it was fully charged in the beginning) and trigger RTH (return to home) when you still are sure you can get there (also maybe considering how far you are, and wind direction and quota).
@mgua
Its exactly what we are planning, as soon as the battery drops below a certain limit our program will switch back to RTL mode. The voltage divider will help us monitor that.
Delete