REMOVE the XBee, WX, or other RADIO MODULE BEFORE your proceed! This tutorial uses the indicator lights for the XBee/WX socket to demonstrate how to toggle pins, and if you leave the radio module plugged in, you will damage both the radio module and Flight Controller!
The Parallax Flight Controller has 3 status LEDs for a radio module plugged into the XBee/WX socket. If there is no radio module plugged into that socket, the LEDs can be turned on and off by the on-board Propeller Microcontroller. Here is part of the schematic for the Flight Controller. If you look carefully, there are 3 LEDs connected to P21, P22, and P23:
Setting P21 and P22 low will turn on those two LEDs, and Setting P23 high will turn on that LED.
Now you are ready to edit the firmware on the flight controller to turn LEDs off and on. First, you need to add a few functions to the Flight Controller Firmware.
A list of files will appear on the left side of the window.
int main() // Main function { Initialize(); // Set up all the objects
// Functions to set a pin's direction void FCsetAsInput( int pinNumber ) { DIRA &= ~( 1 << pinNumber ); } void FCsetAsOutput( int pinNumber ) { DIRA |= ( 1 << pinNumber ); } // Functions to set the state of an output pin void FC_low( int pinNumber ) { OUTA &= ~( 1 << pinNumber ); } void FC_high( int pinNumber ) { OUTA |= ( 1 << pinNumber ); } unsigned int FC_toggle( int pinNumber ) { OUTA ^= ( 1 << pinNumber ); return (OUTA >> pinNumber ) & 1; } // Function to read an input pin unsigned int FC_input( int pinNumber ) { int mask = 1 << pinNumber; // Set up mask return (INA & mask) >> pinNumber; // Return input state }
// Set up the 3 pins attached to the LEDs as outputs FCsetAsOutput(21); FCsetAsOutput(22); FCsetAsOutput(23);
void InitSerial(void) { S4_Initialize(); S4_Define_Port(0, 115200, 30, TXBuf1, sizeof(TXBuf1), 31, RXBuf1, sizeof(RXBuf1)); S4_Define_Port(1, 57600, XBEE_TX, TXBuf2, sizeof(TXBuf2), XBEE_RX, RXBuf2, sizeof(RXBuf2)); // Unused ports get a pin value of 32 S4_Define_Port(2, 19200, 19, TXBuf3, sizeof(TXBuf3), 20, RXBuf3, sizeof(RXBuf3)); S4_Define_Port(3, 115200, PIN_MOTOR_AUX2, TXBuf4, sizeof(TXBuf4), 32, RXBuf4, sizeof(RXBuf4)); S4_Start(); }
The pins in the code above are not necessary for flight, but this does disable communication through the XBee/WX socket.
if( Radio.Aile < 0 ) // Check the right transmitter stick { FC_low(21); // Turn the red LED on FC_high(22); // Turn the left blue LED off } else { FC_high(21); // Turn the red LED off FC_low(22); // Turn the left blue LED on } if( Radio.Elev < 0 ) // Check the right transmitter stick { FC_low(23); // Turn the right blue LED off } else { FC_high(23); // Turn the right blue LED on }
DO NOT CONNECT YOUR ELEV-8's Battery. Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.
Replace the Radio.Aile and Radio.Elev with some other variables: