Friday, June 14, 2013

32. How to #monitor the #Voltage and #Mode of #UAV Battery

We replaced some variables in ardustation programming in telemtry.c and then monitored it in HappyKill More GCS program in the Serial Data:

// 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) && (mode ==3))
{
BATT_FLAG =1;
}
//////////////////////////////////////////////////////

if(mode<3)
{
BATT_FLAG =0;
}


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,DS

T:%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,
(BATT_FLAG+1) // So that flag is not discarded if it is 0
) ;
}
else if (udb_heartbeat_counter % 10 == 0)  // Every 2 runs (5 heartbeat counts per 

8Hz)
{
serial_output("+++THH:%i,RLL:%li,PCH:%li,STT:%i,***\r\n",
(int16_t)((udb_pwOut[THROTTLE_OUTPUT_CHANNEL] - 

udb_pwTrim[THROTTLE_OUTPUT_CHANNEL])/20),
earth_roll, earth_pitch,
mode
) ;
}
return ;
}

These can be viewed in the serial data screen of the Happy Kill More GCS program.