Please note as of Wednesday, August 15th, 2018 this wiki has been set to read only. If you are a TI Employee and require Edit ability please contact x0211426 from the company directory.

Using the Stellaris or Tiva C Series LaunchPad in the FIRST Robotics Competition

From Texas Instruments Wiki
Jump to: navigation, search

The Stellaris and Tiva™ C Series LaunchPads are evaluation kits for the Tiva™ C Series ARM Cortex M4F based microcontrollers from Texas Instruments. The Stellaris LaunchPad is almost functionally identical to the Tiva™ C Series LaunchPad; it is just an earlier version.

This wiki page describes how FIRST Robotics teams can use either LaunchPad in the FIRST Robotics Competition (FRC). For more specific information about the Tiva™ C Series LaunchPad please visit the product page.

Note: For the MSP430F5529 LaunchPad included in the 2015 kit of parts, please refer to our updated page for the F5529.

Overview

Stellaris LaunchPad with GPIO Breakout BoosterPack

Both the Stellaris and the Tiva™ C Series LaunchPad can enumerate as a composite set of two USB HID gamepads by loading the usb_dev_cgamepad example application into the LaunchPad microcontroller (MCU) flash memory. With this example application, the LaunchPad looks and acts like any generic set of two USB game controllers or joysticks. Without any special drivers or APIs, the FRC Driver Station is able to utilize the LaunchPad as if it were a game controller. Data from the LaunchPad is accessed by the robot just as any other joystick.

The gamepad example application is specifically written to be compatible with the GPIO Breakout BoosterPack (BOOSTXL-IOBKOUT). While the Breakout BoosterPack isn't required for the gamepad example application, the BoosterPack makes creating a custom control interface very simple: Connecting external circuitry is made trivial with its screw terminals. Each terminal is labeled in a way that maps directly to the gamepad application. Each analog signal is passed through a unity-gain amplifier to ensure a low source resistance to the Analog to Digital Converter (ADC) on the MCU. Additionally, every signal is protected from Electrostatic Discharge (ESD) by series resistors and ESD diodes.

GPIO Breakout BoosterPack Board Drawing

BoosterPack and Gamepad Features

  • Enumerates as a composite set of two USB HID gamepads
  • 8 analog inputs with unity-gain amplifiers
    • X, Y, Z and X-Rotation for each gamepad
  • 22 digital inputs
    • 11 per gamepad
    • Internal pull-ups to +3.3V
  • 3.5 mm screw terminals for all inputs
    • 2 3.3V terminals
    • 4 ground terminals
  • 0.1" 1X3 user-installed header positions for every signal
    • Servo-style pin arrangement: Ground - Power - Signal
  • 3-switch DIP user switch
    • Can be used as mode switches
    • Mapped to buttons 14 - 16 on the A-side gamepad
  • ESD Protection on all signals and power rails
  • 0.125" mounting holes

Getting Started with the LaunchPad, Boosterpack, and Gamepad Firmware

This section outlines how to setup your LaunchPad with the GPIO Breakout BoosterPack and load the gamepad firmware for the first time.

Hardware Needed

Below is a list of the hardware components needed to get started.

  • Tiva™ C Series or Stellaris LaunchPad
    • Stellaris LM4F120 LaunchPad (EK-LM4F120XL)
    • Tiva™ C Series TM4C123G LaunchPad (EK-TM4C123GXL)
  • GPIO Breakout BoosterPack (BOOSTXL-IOBKOUT)
  • USB Micro-B plug to USB-A plug cable
    • Included with the LaunchPad kit

Software Needed

Below is a list of the software components needed to load the gamepad application on the LaunchPad.

Loading the Composite Gamepad Firmware

You should only have to load the firmware onto the LaunchPad once. These steps can be completed on any Windows computer running Windows 2000, XP, 7, or 8, including the Driver Station laptop.

  1. Plug the LaunchPad into the GPIO Breakout BoosterPack headers at the top-center of the board. Pay attention to the arrows indicating the proper orientation.
  2. Download and unzip the Stellaris ICDI Drivers and place the stellaris_icdi_drivers folder in an easily accessible location on your computer.
  3. Follow the Driver Installation Instructions and plug in the USB cable into the LaunchPad's DEBUG USB port and your computer when the instructions tell you to. Make sure the power select switch is in the DEBUG position.
  4. Download and install the LM Flash Programmer application.
  5. Download the usb_dev_gamepad.zip and extract the usb_dev_cgamepad_setup.exe. Run the executable and pick an easily accessible location for the usb_dev_cgamepad.bin file.
    • Please note that you are not installing an application, the executable just extracts the firmware file onto your computer.
  6. Open LM Flash Programmer and select either "LM4F120 LaunchPad" or "TM4C123G LaunchPad" under the Quick Set menu on the Configuration tab. Select the the LaunchPad that matches the one you are using.
  7. Select the Program tab and Browse for the usb_dev_gamepad.bin file that you downloaded previously.
  8. Verify that the following options are set:
    • Erase Entire Flash - (faster)
    • Verify After Program
    • Reset MCU After Program
    • Program Address Offset: 0x0
  9. Click Program and wait for the programmer to finish with a "Verify Complete - Passed" message at the bottom of the window.
  10. Unplug the USB cable from the DEBUG USB port and plug it into the DEVICE port. Switch the power select switch to the DEVICE position.
  11. Windows should recognize a new USB Composite Device and start installing the default drivers for the composite gamepads.
  12. You should now see a "Texas Instruments Tiva Dual Gamepad" in your device manager.

Using the LaunchPad and BoosterPack as an HID Gamepad

Once the gamepad firmware is loaded on to the LaunchPad, you can connect a variety of switches, buttons, and analog sensors (e.g. potentiometers) to the BoosterPack.

CAUTION Before making any connections to the BoosterPack, make sure the LaunchPad is disconnected from the computer and is no longer powered.

The BoosterPack is organized with screw terminals on both the left (A-Side) and right (B-Side) sides of the board. Two gamepads will enumerate when plugged into the computer, one for the A-Side and one for the B-Side. At the moment, however, the device strings that appear in the Driver Station joystick list are identical. You can press the built in LaunchPad buttons SW1 and SW2 to exercise buttons A1 and B1, respectively, to determine which gamepad is which in the device list.

Materials

You will need the following materials to start creating a basic custom human interface:

  • Various buttons, switches, or potentiometers
  • Small flat-head screwdriver
  • Stranded wire (approximately 18 to 24 AWG)
  • Wiring tools (strippers, soldering iron, etc.)

Adding Digital Buttons

Button Schematic Drawing

Each gamepad has 11 buttons that are accessible through the screw terminals on the BoosterPack: labeled A1 - A11 and B1 - B11. These terminals are connected to General Purpose Input/Output (GPIO) pins on the LaunchPad Microcrontroller (MCU). These GPIOs are set by the firmware as digital inputs with internal pull-up resistors enabled. A button is registered as "pressed" when the digital input goes LOW (AKA ground or 0V). The pull-up resistors pull the inputs HIGH (+3.3V) internally, so by default the inputs will all be HIGH (released) until pulled LOW externally. Therefore, to add a switch or button that triggers a "pressed", all you need to do is wire the switch so that it completes the circuit between the input and ground (GND). See the figure to the right for a schematic drawing.

Adding Analog Axes

Potentiometer Schematic Drawing
Gamepad Axis Mapping

Each gamepad has 4 axes that are accessible through the screw terminals on the BoosterPack: labeled AX, AY, AZ, AR, BX, BY, BZ, and BR. These terminals are connected through a unity-gain amplifier to the Analog to Digital Converter (ADC) on the LaunchPad MCU. The purpose of the unity-gain amplifier is to provide a low impedance source for the ADC which has a maximum analog source resistance requirement of 500Ω. Because of the amplifier, you can connect a wide range of analog sensors, e.g. potentiometers (pots), with varying output impedances. In order to reduce overall power consumption (at the low end) and reduce the susceptibility to noise (at the high end) it is recommended that pots are valued from 5kΩ - 100kΩ.

The ADC on the MCU is capable of measuring a 0 - +3.3V range at a resolution of 12 bits. The gamepad firmware takes the 12-bit measurements and truncates the least two significant bits, essentially creating a 10-bit measurement. The voltage resolution can easily be calculated:

Voltage Resolution = (ADC Voltage Range)/(2^(ADC Bits) - 1)

Voltage Resolution = (3.3 V)/(2^10 - 1) = 3.22 mV

Knowing the voltage resolution is useful if you are connecting a sensor that may not span the entire ADC input range, or if the sensors resolution is higher than the ADC.

When using a linear taper pot that is wired the same as in the Potentiometer Schematic Drawing, you can simply determine the angular resolution by dividing the pot's degrees by the ADC resolution. For example, a pot with 300° of motion will have an angular resolution of:

Angular Resolution = (Total Degrees)/(2^(ADC Bits) - 1)

Angular Resolution = (300°)/(2^10 - 1) = 0.29°

The gamepad firmware takes the 10 bit measurement and converts it into a signed number between -512 and 511 before sending it through the gamepad data structure. The diagram to the right shows how the measured voltage and data values are mapped to the gamepad axes. Note that the Driver Station will convert the gamepad data into a signed number between -1.0 and +1.0.

Terminal Mapping

The gamepad firmware makes the following mappings between the BoosterPack terminals and the USB gamepad data structure:

BoosterPack Gamepad Mapping
A-Side B-Side
BoosterPack LaunchPad Gamepad BoosterPack LaunchPad Gamepad
AX X-Axis X-Axis
AY Y-Axis Y-Axis
AZ Z-Axis Z-Axis
AR X-Rotation X-Rotation
A1 SW1 Button 1 B1 SW2 Button 1
A2 Button 2 B2 Button 2
A3 Button 3 B3 Button 3
A4 Button 4 B4 Button 4
A5 Button 5 B5 Button 5
A6 Button 6 B6 Button 6
A7 Button 7 B7 Button 7
A8 Button 8 B8 Button 8
A9 Button 9 B9 Button 9
A10 Button 10 B10 Button 10
A11 Button 11 B11 Button 11
S1 LED Red Button 14
S2 LED Blue Button 15
S3 LED Green Button 16

Note: User switches S1, S2, and S3 are mapped to buttons 14, 15, and 16 on the A-side only. They are also shared with the tri-color LED on the LaunchPad. One possible use for the user switches can be to select a mode in the robot code that isn't changed very often.

Mounting

When mounting the BoosterPack, it is recommended that nylon standoffs and screws be used to raise the board off of the mounting surface. The 0.125" diameter mounting holes fit #4 sized screws well.

The GPIO Breakout BoosterPack has the following dimensions:

GPIO Breakout BoosterPack Board Dimensions

With the LaunchPad installed, the vertical dimension is increased by ~1.0" to 4.75".

Modifying the Gamepad Firmware

It will eventually be possible to modify the gamepad firmware to change mapping, use I2C, SPI, or UART based sensors, preprocess sensor data, and more. The source code to the example application will be released in the near future and will make it easy to tweak the inner workings while maintaining the simple gamepad interface to the Driver Station and robot.

More information will be placed in this section when the source code is released.

Using the LaunchPad on the Robot

Coming Soon.

Frequently Asked Questions (FAQ)

Coming Soon.

Additional Information and Resources