LEARN.PARALLAX.COM
Published on LEARN.PARALLAX.COM (https://learn.parallax.com)
Home > IO on the ELEV-8 Flight Controller

IO on the ELEV-8 Flight Controller

If you can blink an LED, you can rule the world! Or at least illuminate it slightly 🙂 This tutorial will help you add code to the Parallax ELEV-8 Flight Controller that will allow it to interact with other devices or electronics.  This tutorial contains intermediate and advanced elements that will help you use any unused pins on your Parallax Flight Controller as general-purpose input/output pins.  Once you understand how to control an LED or read the state of an input pin, you can extend that knowledge to applications such as triggering a camera shutter or data logger.  Although this tutorial will use specific hardware, many of the concepts can be used with a wide range of hardware.

Hacking Cautions

It is possible to complete this tutorial by simply using what comes with the ELEV-8 v3 kit and making changes to the code.  The code you add to the firmware to learn how to toggle inputs and outputs is only meant to be used temporarily.  If you choose to add additional electronics or hardware more permanently to your ELEV-8 v3 and/or make changes to the firmware, you will need to take special care that:

  • The pins “toggled” by edits to the firmware are not used for any other purpose.
  • Any added hardware is firmly and safely fastened to the ELEV-8 v3’s chassis
  • If hardware is added, special care is taken not to exceed the battery or Flight Controller’s current and voltage capabilities.
  • You thoroughly safety test your ELEV-8 v3 before fully flying it after it has been modified.

IO Parts and Prep

Preparation – Safety First!

  • Make sure your ELEV-8 is OFF with the BATTERY DISCONNECTED AND REMOVED.
  • REMOVE THE PROPELLERS from the ELEV-8 v3 quadcopter’s motors. They are NOT needed for this tutorial.
  • REMOVE the XBee, WX, or telemetry radio module if you have one plugged into the top of your Parallax Flight Controller.  This tutorial will blink status LEDs on the Flight Controller that are connected to the radio module socket.  Driving those LEDs with a radio module connected could permanently damage the radio module.

This tutorial will show you how to write and edit Propeller C code and the Flight Controller firmware using the SimpleIDE software. You will compile your code and load it into the Propeller microcontroller on the Flight Controller, then see the results.

Before you start:

  • Set up SimpleIDE – even though this tutorial is for the Parallax Flight Controller.
  • Make sure you understand how to load firmware onto the Flight Controller.  If you overwrite your firmware by completing this tutorial, you can always re-upload after you’ve completed this tutorial.
  • Make sure you save your current firmware (or at least know which downloaded version you last installed on your Flight Controller)!

What you will need:

A complete, tested, configured ELEV-8 v3 (Parallax Item #80300 or Item #80330) that has a receiver with at least 6 channels, such as:

  • A Spektrum AR610 6-Channel receiver (Parallax Item #80206 or comes with Item #80208), or
  • A Spektrum AR8000 8-Channel receiver (comes with Parallax Item #730-80300)
  • Any compatible transmitter/receiver pair with at least one spare (6 or more total) channel(s)

Optional Mounting Hardware:

If you wish to mount hardware, sensors, or lights to the bottom chassis plate of your ELEV-8 v3, you will need hardware and/or adhesive, such as:

  • #4-40 screws, locknuts, standoffs, and spacers (Available in hardware packs here or here)
  • Right angle (L-shaped) brackets (Parallax Item #720-00011)
  • Zip ties
  • Hot glue
  • Double-sided foam tape

Optional Accessories for Connecting the Flight Controller to External Hardware:

If you wish to complete the optional activities in this tutorial, including connecting your flight controller to an external development board, you will need:

  • An LED
  • A breadboard
  • A 100- or 220-ohm resistor
  • 3-pin cables from Parallax (8″ – Item #800-00080, 12″ – Item #800-00120, )
  • 3-pin long header (Parallax Item #451-00303)
  • Female-to-Female jumper cables (Parallax Item #800-00046) OR Female-to-Male jumper cables (Parallax Item #800-00048)

Optional Cable to Power Additional Hardware From the Power Distribution Board:

One of the easiest ways to add functionality to your ELEV-8 v3 (or any other sUAV) is to attach a development board such as an ActivityBoard, Board of Education, or Arduino + Parallax Sheild.  It is even possible to power any of these boards directly from the ELEV-8 v3’s by building a custom adapter cable:

  • A barrel connector cable (Digikey Item #CP-2185-ND or similar will fit the ActivityBoard, Board of Education, and Arduino UNO)
  • A short 3-pin cable (Parallax Item #451-00303)
  • A soldering iron and solder (Available as a kit: Parallax Item #700-10011)
  • Tools for cutting and stripping wire (Available here, here, or here)
  • Electrical tape and/or heat shrink tubing

 

AND and OR

AND and OR

Since binary digits represent “On” and “Off”, we can use operators with them that reflect real-world operations – think about switches and light bulbs.

If we have two switches and a light bulb to tell us if something is on or off, we can represent concepts like AND and OR.  Let’s start with AND.

Look carefully at the diagram below.  In order for the light to come on, BOTH switches have to be turned on:

If we AND to binary numbers, a bit has to be 1 in both numbers for the bit to be a 1 in the new number.

The symbol for AND’ing two numbers is “&“.  Here is an example of two binary numbers being AND’ed together:

The only digits that remain as 1’s are the digits where there was a 1 in both numbers.

OR can be used similarly.  Take a look at the diagram below.  Only one of the switches needs to be on to turn on the light:

If we OR two binary numbers, only one of the bits has to be a 1 for the bit to be a 1 in the new number.

The symbol for OR’ing two numbers is “|“.  Here is an example of two binary numbers being OR’ed together:

Try this

  • Open a new PropellerC project in SimpleIDE.
  • Copy the following code and paste it into the main window:
/*
AND and OR operators example
*/

#include "simpletools.h"                           // Include simpletools library

unsigned int numberA;                              // Declare variables
unsigned int numberB;
unsigned int numberC;

int main()                                         // Main function
{
  while(1)
  {
    // Prompt user to enter two binary numbers    
    print("Enter a binary number (up to 8 digits): ");
    scan("%b\n", &numberA);                      
    print("Enter another binary number (up to 8 digits): ");
    scan("%b\n", &numberB);                      

    // Display the results AND'ed together
    print("\n\nAND example:\n");
    print("\t  %08b\n\t& %08b\n\t__________\n", numberA, numberB);

    numberC = numberA & numberB;                   // AND the numbers together

    print("\t= %08b", numberC);

    // Display the results OR'ed together
    print("\n\nOR example:\n");
    print("\t  %08b\n\t| %08b\n\t__________\n", numberA, numberB);

    numberC = numberA | numberB;                   // OR the numbers together

    print("\t= %08b\n\n", numberC);                
  }
}
  • Click “Program > Run With Terminal”

You should se something like this:

  • Try different combinations of numbers until you have a better understanding of how the AND and OR operations work with binary numbers.

Pin Control Registers

Now that we know a litle bit about shifting, inverting, AND’ing and OR’ing, we can start using that knowledge to turn the pins of the Propeller microcontroller on and off or read them as inputs.  The Propeller multicore microcontroller has 32 GPIO pins, which stands for “General Purpose Input/Output.”  Because it is a 32-bit processor, it can fit all of those pins into a single port.  Other microcontrollers have multiple ports, often labeled PORTA, PORTB, etc.  On the Propeller, there is only a port A.  

 

The port has several pin control registers:

  • DIRA – sets the directions of each of the pins as an input (0) or an output (1)
  • OUTA – sets the state of each pin high (1) or low (0)
  • INA – can be read to determine the state of each pin as an input

Setting Pin Direction

If we want to set pins 0-15 as inputs and pins 16-31 as outputs, we could type this line of code into our program:

DIRA = 0b11111111111111110000000000000000;

So, how do we change one pin at a time?  This is where using shifting, inverting, AND’ing and OR’ing come in handy.  

Let’s set pin P3 as an output and leave all of the other pins as they are.  This means we need bit 4 to be a 1.  This code will do just that – it sets P3 to a 1 without changing any of the other pins:

DIRA = DIRA | 0b00000000000000000000000000001000;

Here’s why this works:  If you take any bit and OR it with a zero (0), it will stay the same.  If you OR the number with a one (1), it will become a one (1).

Now let’s try to make the line of code simpler and more useful:

DIRA |= (1 << 3);

Two things were simplified.  The first is replacing DIRA = DIRA | …. with DIRA |=.  It’s a shorthand trick that gives the same result.  This can be done with other operands too: +=, -=, *=, &=, |= are just a few.  You can find a complete list by going here and scolling down to “Assignment Operators”.  The other thing that was simplified was to create the binary number 1000 by taking the number 1 and left shifting it 3 places.  This means that if we want to build a useful function, we could do this:

DIRA |= ( 1 << pinNumber );

This will set whatever number we assign to pinNumber as an output.

Let’s try setting a pin as an input.  This means that we need a specific pin to be a 0, and we need to leave every other pin alone.  If we AND something with a 1, it will stay the same, and if we AND it with a zero, it will become a zero.  This means that to set pin P3 to be an input, we would type:

DIRA = DIRA & 0b11111111111111111111111111110111;

We can create the big long binary number by inverting 00000000000000000000000000001000, and we can create that number by shifting a 1 to the left 3 places:

DIRA = DIRA & ~( 1 << 3 );

And if we replace the 3 with pinNumber and use the shorthand operator:

DIRA &= ~( 1 << pinNumber );

Now we have a way to set an input and to set an output.  We can build two useful functions:

void FCsetAsInput( int pinNumber ) { DIRA &= ~( 1 << pinNumber ); }
void FCsetAsOutput( int pinNumber ) { DIRA |= ( 1 << pinNumber ); }

Setting a pin high or low

We can use the same tricks we used to set pins as inputs or outputs on a different register, the OUTA register, so set the state of an output pin.

If we replace the DIRA with OUTA in the the functions we wrote earlier, we can build two new useful pin setting functions:

void FCsetPinLow( int pinNumber ) { OUTA &= ~( 1 << pinNumber ); }
void FCsetPinHigh( int pinNumber ) { OUTA |= ( 1 << pinNumber ); }

Reading an input

This one gets a little trickier.  Instead of setting a register, we are reading it.  Look at the picture at the top of this page again.  Each pin corresponds to a bit in the INA register, so if we were to read the INA register, we might get something that looks like this:

10101010011011111011101010111101

If we are only interested in pin P3, we need to create a mask and then AND the INA register with that mask:

To create the mask, we can shift 1 to the left 3 positions, and to get the result, we can shift it to the right 3 positions.  Now we can create a function that reads the input of any pin:

int FCreadPin( int pinNumber )
{
  int mask = 1 << pinNumber;                        // Set up mask
  return (INA & mask) >> pinNumber;                 // Return input state
}

Set an Output with the Flight Controller

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.

Try This

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.

  • Using SimpleIDE, open the flight controller firmware.
  • With elev8-main.side open, click on the “Open Project Manager” icon in the lower left corner of the window:

A list of files will appear on the left side of the window.  

  • Click on elev8-main.cpp to make sure you are editing that file.
  • Scroll down until you find the following code (around line 195):
int main()                                    // Main function
{
  Initialize(); // Set up all the objects
  • Copy the following code and paste it into elev8-main.cpp BEFORE the main() function:
// 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
}
  • Copy the following code and paste it into a blank line AFTER the Initialize(); function:
// Set up the 3 pins attached to the LEDs as outputs
FCsetAsOutput(21);
FCsetAsOutput(22);
FCsetAsOutput(23);
  • Next, find the following code (near line 530):
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();
}
  • Change all of the highlighted values to 32.  This prevents the flight controller from trying to use any of those extra pins for serial communication.  

The pins in the code above are not necessary for flight, but this does disable communication through the XBee/WX socket.

  • Finally, find a blank line after the line UpdateFlightLEDColor(); (near line 660), and paste in the following code:
  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
  }
  • Save your project.

DO NOT CONNECT YOUR ELEV-8’s Battery.  Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.

  • Plug your ELEV-8 v3 Flight Controller into your computer and select the corresponding port from the drop-down menu.
  • Click the Upload to EEPROM button.
  • Turn on your transmitter.
  • Move the right stick around to turn the on-board LEDs off and on.

 

Your Turn

Replace the Radio.Aile and Radio.Elev with some other variables:

  • Radio Channels
    • Radio.Thro       (-1024 to +1024)
    • Radio.Rudd
    • Radio.Aile
    • Radio.Elev
    • Radio.Gear
    • Radio.Aux1
    • Radio.Aux2
    • Radio.Aux3
  • Sensors
    (3-axis gyroscope, 3-axis accelerometer, 3-axis magnetometer, altimeter/pressure sensor, thermometer, and voltmeter connected to the battery)

    • sens.Temperature (-32768 to +32767, units of 1/16th of a °C, zero = 25°C)
    • sens.GyroX       (-32768 to +32767, units of 1/16th of a °/second)
    • sens.GyroY
    • sens.GyroZ
    • sens.AccelX      (-32768 to +32767, units of 1/4096th of 1 g [9.8 m/s2])
    • sens.AccelY
    • sens.AccelZ
    • sens.MagX        (-32768 to +32767, units of 1/4096th of a gauss)
    • sens.MagY
    • sens.MagZ
    • sens.Alt         (approx. -1200000 to +30000000, units in mm above sea-level)
    • sens.AltRate     (units in mm/second, shouldn’t exceed ±120000)
    • sens.Pressure    (0 to +4096000, units of 1/4096th of an hPa, zero = 260 hPa)
    • BatteryVolts     (units of 1/100th of a volt, 1200 = 12.00 V)
  • Motor Speeds
    (Width of PWM pulse sent to ESCs in 1/8th ÎĽs, not actual motor speeds)

    • Motor[1]         (+8000 to +16000)
    • Motor[2]
    • Motor[3]
    • Motor[4]
  • System Counter
    • counter          (starts at zero, goes up by 1 every 4 milliseconds)

Read Inputs with the Flight Controller

The receiver and ESC pins on the Parallax Flight Controller can be used for a number of different purposes.  In addition to reading the signals coming in from the reciever and sending servo pulses to the ESCs, they can be driven high or low or be read as an input.

To read a pin, we will need to utilize 2 more of the functions, FCsetAsInput(); and FC_input(); we added to the Flight Controller firmware on the previous page:

FCsetAsInput( int pinNumber );
int pinState = FC_input( int pinNumber );

The first function, FCsetAsInput();, when used near the the beginning of the firmware’s code, sets a pin to be an input.  The second function reads the pin, and its result can be placed in a variable to be used later.  The diagram below shows the pin numbers and names available in the firmware:

Try This

  • If you have not completed the last page, you must follow the instructions on that page first.
  • Using SimpleIDE, open the flight controller firmware.
  • With elev8-main.side open, click on the “Open Project Manager” icon in the lower left corner of the window:

A list of files will appear on the left side of the window.  

  • Click on elev8-main.cpp to make sure you are editing that file.
  • Find the following code that you added on the last page (near line 200):
// Set up the 3 pins attached to the LEDs as outputs
FCsetAsOutput(21);
FCsetAsOutput(22);
FCsetAsOutput(23);
  • Add these three lines to it:
FCsetAsInput(1);
FCsetAsInput(2);
FCsetAsInput(3);
  • Finally, find the code that you added after the line UpdateFlightLEDColor(); (near line 660).
  • Delete the changes you made in the previous page.
  • Add the following code:
  if( FC_input(1) == 1 )  // Check the P1 pin
  {
    FC_low(21);      // Turn the red LED on
  } else { 
    FC_high(21);     // Turn the red LED off
  }

  if( FC_input(2) == 1 )  // Check the P2 pin  
  {
    FC_low(22);      // Turn the left blue LED on
  } else {
    FC_high(22);     // Turn the left blue LED off
  }

  if( FC_input(3) == 1 )  // Check the P3 pin  
  {
    FC_high(23);     // Turn the left blue LED on
  } else {
    FC_low(23);      // Turn the left blue LED off
  }
  • Save your project.

DO NOT CONNECT YOUR ELEV-8’s Battery.  Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.

  • Disconnect the 3 pin cables that connect Aux1, Aux2, and Aux3 between the Receiver and Flight Controller on your ELEV-8 v3, and save one of the cables for this activity.

  • Take the top cover plate off of your ELEV-8 v3 – this will allow you easily see the LEDs you are toggling and access different pins to connect the a spare 3-pin cable.
  • Plug your ELEV-8 v3 Flight Controller into your computer and select the corresponding port from the drop-down menu.
  • Click the Upload to EEPROM button.
  • Look carefully at the diagram showing the side of the Flight Controller with the receiver connections and the video below.
  • Using a spare 3-pin cable, connect the white wire on the spare 3-pin cable to the middle pin and leave the red and black wires hanging to the side.
  • Use the other end of the 3-pin cable to jumper to the top pin, making connections to P1, P2, or P3:

When you make connections, the corresponding indicator LEDs on the Flight Controller board will turn on.

Connecting external devices

You can do more than just blink the LEDs attached to the ELEV-8 Flight Controller – you can connect the flight controller to an external LED, or even another development board like the Activity Board or an Arduino!

Although this part of the tutorial is optional, it is helpful to see how the flight controller can be programmed to control an external accessory such as a data-logging sensor.

Connect an external LED

Instead of turning on an LED on the Flight Controller itself, let’s try turning on an external LED – this will demonstrate that the pins on the flight controller can be connected to external devices.

  • If you have not completed the previous pages in this tutorial, you must follow the instructions on those pages first.
  • Using SimpleIDE, open the flight controller firmware.
  • Verify that you care editing elev8-main.cpp file.
  • Find the following code that you added on the last page (near line 200):
// Set up the 3 pins attached to the LEDs as outputs
FCsetAsOutput(21);
FCsetAsOutput(22);
FCsetAsOutput(23);
FCsetAsInput(1);
FCsetAsInput(2);
FCsetAsInput(3);
  • Delete those lines of code and add:
FCsetAsOutout( PIN_MOTOR_AUX1 );
  • Next, find the code that you added after the line UpdateFlightLEDColor(); (near line 660).
  • Delete the changes you made in the previous page.
  • Add the following code:
  if( Radio.Gear < -512  )  // Check the gear(mode) switch position
  {
    FC_low( PIN_MOTOR_AUX1 );      // Turn the external LED of
  } else { 
    FC_high( PIN_MOTOR_AUX1 );     // Turn the external LED on
  }
  • Save your project.

DO NOT CONNECT YOUR ELEV-8’s Battery.  Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.

  • Using jumper wires or another 3-pin cable with a a long 3-pin header, connect the signal and ground pins from the PIN_MOTOR_AUX1 pin to the breadboard:

  • Plug your ELEV-8 v3 Flight Controller into your computer and select the corresponding port from the drop-down menu.
  • Click the Upload to EEPROM button.
  • Once the program has loaded, turn on your transmitter.
  • When you flip the gear switch, the LED will blink on and off.

Build a cable to power another development board from the Power Distribution Board

If you wish to connect another development board such as an Activity Board or an Arduino to your ELEV-8 v3, you will need a way to power that board.

  • Gather your materials.
  • Cut one end off of the 3-pin cable and cut off or remove the white wire entirely.
  • Strip the ends of the wires on both the 3-pin cable and the barrel plug cable:

  • If you plan to heat-shrink the connections, slide pieces of heat shrink over the ends of the 3-pin cable.
  • Using a soldering iron, connect the wire with the white stripe on the barrel plug to the red wire on the 3-pin cable:

  • Again using a soldering iron, connect the solid black wires from the barrel plug and the 3-pin cable together.
  • Apply to heat to the heat-shrink or use electrical tape to prevent the soldered connections from touching and shorting:

  • Connect the 3-pin end to the Power Distribution Board on the ELEV-8 v3.
  • (Optional) Using 4-40 hardware, zip-ties, or adhesive, mount your development board to your ELEV-8 v3.
  • Plug the barrel plug into your development board.

Connecting an Activity Board to the Flight Controller

Although this example is specific to an Activity Board, the same concepts can be used to connect and Arduino or even a BASIC Stamp development board.

In this example of two-way communication, when the gear (mode) switch is flipped on, the Flight Controller sets one of its pins high.  This pin, which is connected to an Activity Board, tells the Activity Board to begin its program.  The Activity Board then turns on 3 LEDs in 3 seconds.  Then, the Activity Board sets one of its pins, which is connected back to the Flight Controller, high.  When the Flight Controller detects that that pin is high, it turns on one of its on-board LEDs.

This application is especially useful because the Activity Board has an SD card slot and is able to do data-logging with any sensor that you are able to attach to it.  Click here for a tutorial on using the Activity Board to record data to an SD card.

  • If you have not completed the previous pages in this tutorial, you must follow the instructions on those pages first.
  • Using SimpleIDE, open the flight controller firmware.
  • Verify that you care editing elev8-main.cpp file.
  • Delete the code that you added on the last activity (near line 200):
// Set up the 3 pins attached to the LEDs as outputs
FCsetAsOutput(23);
FCsetAsOutput(PIN_MOTOR_AUX1);
FCsetAsInput(PIN_MOTOR_AUX2);
  • Next, find the code that you added after the line UpdateFlightLEDColor(); (near line 660).
  • Delete the changes you made in the previous activity.
  • Add the following code:
  if( Radio.Gear < -512  )             // Check the gear(mode) switch position
  {
    FC_low( PIN_MOTOR_AUX1 );          // Turn off the Activity Board trigger
  } else { 
    FC_high( PIN_MOTOR_AUX1 );         // Turn on the Activity Board trigger
  }

  if( FC_input(PIN_MOTOR_AUX2) == 1 )  // Check if the Activity Board is sending a signal
  {
    FC_low(23);                        // Turn on the on-board LED
  } else {
    FC_high(23);                       // Turn off the on-board LED
  }
  • Save your project.

DO NOT CONNECT YOUR ELEV-8’s Battery.  Make sure the propellers have been removed from your ELEV-8 quadcopter before continuing.

  • Plug your ELEV-8 v3 Flight Controller into your computer and select the corresponding port from the drop-down menu.
  • Click the Upload to EEPROM button.
  • In SimpleIDE, click “File > New Project” and open a new C (not C++) project.
  • Delete the blank template and type in the following code:
#include "simpletools.h"                      // Include simple tools

int main()                                    // Main function
{
  // Add startup code here.
  while(1)
  {
    low(26);                 // make sure all LEDs
    low(27);                 // and the Flight Controller
    low(3);                  // trigger are off
    low(10);
 
    if(input(11) == 1)       // Did the flight controller send
    {                        // a high signal?
      high(26);              // Turn on the first LED
      pause(1000);           // Wait 1 second
      high(27);              // Turn on the second LED
      pause(1000);           // Wait 1 second
      high(3);               // Turn on the third LED
      pause(1000);           // Wait 1 second
      high(10);              // Send a signal to the Flight Controller
      
      while(input(11) == 1); // Wait until the Flight Controller stops
    }                        // sending a high signal
  }  
}
  • Connect the Activity Board to your computer.
  • Make sure the correct port is selected, and click the to EEPROM button.
  • Once the program has loaded, use jumper wires to connect your Activity Board to your Flight Controller as shown:

  • Connect the power cable you built earlier from the Power Distribution Board to the Activity Board.
  • Turn on your transmitter.
  • Connect the battery.
  • Flip the gear (mode) switch on your transmitter to trigger the code and observe the two boards communicating with each other.

Safety Test after IO Hacking

Now that you have modified the hardware and/or firmware for the ELEV-8 v3, it is necessary to test its functionality to make sure it is safe to fly. Yes, do this every time you made hardware and/or firmware modifications!

DO NOT SKIP THIS PROCEDURE!  Flying with untested firmware is dangerous and can cause severe injury or property damage or loss.

If you have not done so already, REMOVE YOUR PROPELLERS before proceeding!

If your ELEV-8 v3 fails to pass any of the steps below, STOP – disconnect the ELEV-8 v3’s battery and return to prior steps to begin troubleshooting the problem.

  • The propeller blades should NOT be installed on the motors. If they are installed, remove them now.
  • Place your ELEV-8 v3 on a hard, flat surface.
  • Turn on your transmitter.
  • Open the Parallax GroundStation on your computer.
  • Connect your ELEV-8 v3 to your computer with its USB cable.

Pay close attention to the RGB LED on the Flight Controller.  During this process, it should continue to flash/alternate colors.  Except during power-up, arming and disarming, if the LED stops flashing, there is a problem with your code and it is not safe to fly.

  • Verify that the GroundStation software shows that the ELEV-8 v3 is connected.
  • Pick up your ELEV-8 v3 and make sure that the GroundStation is displaying it’s orientation correctly and smoothly.
  • Move the sticks around on your transmitter and make sure that the GroundStation is displaying them properly.
  • Disconnect your ELEV-8 v3 from your computer.
  • Connect your ELEV-8 v3’s battery.
  • Arm your ELEV-8 v3.
  • Make sure all 4 motors are spinning.
  • Move your transmitter sticks around.  Continue moving them around for at least 90 seconds (1.5 minutes).  Make sure that your motors are changing speeds appropriately.

The Propeller microcontroller on the Flight Controller has a system clock that takes approximately 53 seconds to roll back over to zero and start again.  Testing for 90 seconds ensures that the rollover will not cause a lock-up.

  • Check your Gear switch to make sure that your ELEV-8 v3 is changing modes appropriately.
  • Disarm your ELEV-8 v3.  Make sure the motors stop.

If your ELEV-8 v3 passed all of the above tests, it should be safe to re-install the propeller blades when you are ready to fly.  

For your first flight with modified firware and hardware, follow all safety precautions.  
Fly gently, close to the ground, and away from any people, objects, or structures until you are confident that your ELEV-8 v3 is performing normally.

 

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024


Source URL:https://learn.parallax.com/courses/io-on-the-elev-8-flight-controller/
Links