Monday, May 20, 2013

25. Had to remove the servo of one of the Ailerons




24. Update Switch-out from Auto-Pilot Mode

1. In order to receive indication physically on Dev Board that we have switched out from Auto-Pilot Mode  we use the Blue LED (declared in ConfigUDB4.h file) present on it.

So in servoMix.c file we made the following changes:

void startupfuntion(void)
{
if (startflag == 0)
{
startflag =1;
currentvalue = mychannelvalue;
}
}

void checkmode(void)
{
diff = mychannelvalue-currentvalue;
if((diff>100) || (diff<-100))
//if (diff==1)
{
currentvalue = mychannelvalue;
if(LED_BLUE == 0)
LED_BLUE = 1;
else
LED_BLUE = 0;
if (flags._.GPS_steering == 1 && flags._.pitch_feedback == 1 && udb_flags._.radio_on == 1)
            {
 next_waypoint();
              currentvalue = mychannelvalue;
}
}
}

2. Also we declared our int variable - diff in defines.h file so that it may be used for other purposes too, and removed its static declaration:

extern int diff; //extern helps to access a variable/function defined in a single file and makes it available for all the other files in our program

3. In order to check what difference in servoMix.c file (diff) is coming in the - diff = mychannelvalue-currentvalue;, so that we may check whether vale in our condition - if((diff>100) || (diff<-100)) is within range or not. So we opened telemetry.c file and did the following changes:


// Yaw
// Earth Frame of Reference
// Ardustation does not use yaw in degrees
// matrix_accum.x = rmat[4] ;
// matrix_accum.y = rmat[1] ;
// earth_yaw = rect_to_polar(&matrix_accum) ; // binary angle (0 - 256 = 360 degrees)
// earth_yaw = (earth_yaw * BYTECIR_TO_DEGREE) >> 16 ; // switch polarity, convert to -180 - 180 degrees
// The Ardupilot GroundStation protocol is mostly documented here:
//    http://diydrones.com/profiles/blogs/ardupilot-telemetry-protocol
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, diff, (float)(voltage_milis.BB / 100.0), 
(int16_t)((udb_pwOut[THROTTLE_OUTPUT_CHANNEL] - udb_pwTrim[THROTTLE_OUTPUT_CHANNEL])/20),
earth_roll, earth_pitch,
mode
) ;
}
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 ;
}

We changed to diff from tofinish_line so that in Realterm Software we may see the diff value coming and set our condition accordingly.


4. And finally: What is the meaning of diff?

Diff is the decimal difference in milliseconds that comes between the up and down position of the switch we will use, on the transmitter, to switch-out from Auto-Pilot mode.