NOTICE: The Processors Wiki will End-of-Life on January 15, 2021. It is recommended to download any files or other content you may need that are hosted on processors.wiki.ti.com. The site is now set to read only.

TInk

From Texas Instruments Wiki
Jump to: navigation, search

Welcome to TInk[edit]

Welcome to the official page for TInk, The TI Balancing Tank Project. TInk was a project done by the TI Santa Barbara interns in the summer of 2013.

The TI Balancing Tank Project[edit]

Project Goal[edit]

Using a Stellaris launchpad, SensorHub booster pack, and a CC3000 wifi interface, design a robotic tank that can be remotely controlled over wifi using an HTML5-enabled browser interface. When driven into a wall, the robot will automatically detect that it has 'gone vertical' and begin balancing itself on its back wheels. Subsequent drive commands will be obeyed in this vertical position.

Hardware Overview[edit]

Tank Chassis[edit]

The tank chassis consists of three sub-components:

  1. Universal Plate Set
  2. Track & Wheel Set
  3. Twin-Motor Gearbox

All of these products are produced by Tamiya and can be purchased from their online store. Instruction on how to build the twin motor gearbox are available here.

Mount the gearbox one hole back from the rear of the tank.  Mount the front axle as forward as possible.  Mount the bottom wheels as shown in the picture below. Finally, place the treads around the wheels.

Battery, USB Regulator Power Source & Battery Holder[edit]

Tink is powered by a 3.7V 18650 rechargeable lithium ion battery. The tank itself has a 18650 battery holder that is attached to the chassis, right behind the front axle. A battery holder and corresponding battery can be found at various suppliers but links to recommended ones are provided.

Tink’s board needs a 5V power source through USB. In order to provide this, a USB power source regulator must be used along side the lithium ion battery.

The Battery holder has two wires, a black wire and a red wire. The red wire is soldered to the IN+ corner of the USB regulator and the black wire is soldered to the IN- corner of the USB regulator. There is another red wire that is soldered to the IN+ corner of the USB regulator, but the other end goes to the VIN pin of the motor driver.  This is further explained in the Motor Driver Section.

LM4F120 Stellaris Launchpad[edit]

TInk has an LM4F120 ARM micro-controller with a USB 2.0 interface. This LaunchPad has:

  • 32-bit ARM Cortex-M4 based MCU with a floating point unit
  • 256 KB Flash
  • 32 KB SRAM
  • 2 KB EEPROM on-chip memory

These features give developers a lot of options. TInk takes advantage of all the space and processing power on the LaunchPad. The floating point unit is used to do PWM calculations. The efs file system, used to house the webpage that TInk serves up, is stored in the abundant SRAM. Lastly, The vast amounts of Flash memory are used to store movement data during semi-autonomous operation. The launchpad is on top of the motor driver. It has the sensor hub and the CC3000 on top of it.

SensorHub Booster Pack[edit]

The SensorHub Booster Pack houses several pieces of hardware. First it has a 9 axis motion sensor with a magnetometer, a gyroscope, and an acceleration. The SensorHub also has an infrared temperature sensor, a pressure sensor, a humidity sensor and an infrared light sensor.

Of these sensors, only the 9 axis motion sensor is used in the TInk project. At one tme the temperature sensor was used but it caused too many problems and the functionality was removed.  The communication that is done from the SensorHub to the Stalleris is through I2C and those pins are PB6 through PB7. There are also two pins used for interrupts for the two types of data. Pin PB2 is used for incoming of motion data and pin PE0 was used for incoming temperature data.

CC3000EM Module

CC3000EM Wifi Adapter
[edit]

The CC3000EM provides the Wifi connection for TInk. This module attaches to the RF headers on theSensorHub BoosterPack that attaches to the LaunchPad and communicates through the SPI interface. Pins A2 through A5 from the Stalleris are used for the SPI interface to the CC3000. The CC3000 is placed on top of the Sensor Hub on the RF headers.

Motor Driver[edit]

This motor driver is a low voltage booster pack. The parts are TI made and grouped together by a third party. The motor driver takes two inputs for each motor that drive the tank in a certian direction. On page eight of the TI dual H-Bridge motor driver user guide there is a table of inputs that are mapped to outputs and a direction. The outputs are forward, reverse, coasting and brake.

The pins that go with one motor are PB0 and PB1 and the motor has pins PB4 and PB5 in the Stalleris launchpad. Those pins are going to be directly mapped to the same pins in the motor driver. Those pins will have to be wired to pins AIN1, AN2, BN1 and BN2 with A and B being the two different motors. The pins that say Motor_A and Motor_B are what will be connected to the two different motors using two wires for each motor. Also there need to be a wire directly connected from the battery holder to the VIN next to Motor_B.

Software Overview
[edit]

Code Composer Studio
[edit]

Code Composer Studio (CCS) is the microprocessing development environment produced by Texas Instruments. CCS is available freely to developers. CCS has many tools that are useful for embedded development. TInk was made entirely with CS version 5.4. CCS is available to download here.

TI Real Time Operating System[edit]

TI-RTOS Multiple Tasks

TI Real Time Operating System (TI-RTOS) is a micro-controller real time operating system developed by Texas Instruments. There are many benefits to a real time operating system over a traditional synchronous micro-controller operating system. TI-RTOS allows more utilization of the ARM processor by running asynchronous processes in one program. In the TInk project there are four tasks, which run at different times. These tasks are the HTTP Server task, the Websocket task, the Control task, and the Idle task. The Idle task is in every TI-RTOS application. Each task has their own time to run based on their priority. For TInk, the Control task has the highest priority of 5. The Websocket task has a priority of 4 and the HTTP Server task has a priority of 3. The idle task is the lowest priority and runs when there is nothing else that needs to be done. TI-RTOS also supports most drivers form Stellarisware. TInk was developed using TI-RTOS version 1.10.00.23. TI-RTOS is available here. 

Pulse Width Modulation Driver
[edit]

A Pulse Width Modulation (PWM) Driver is not included with TI-RTOS. A PWM driver needs to be installed. Follow closely, a mistake could corrupt your TI-RTOS install.

  1. First make a backup of your TI-RTOS install.
  2. Next unzip the TI-RTOS folder that is available here, save it over the original.
  3. Now TInk should have PWM funcitonality.

SensorLib[edit]

The SensorLib Library provides the backend for use of the SensorHub and the many sensors that it houses. There are functions in the sensor library that initialize the SensorHub. These are called at startup of Tink. There are function calls that take data from the SensorHub, through the I2C bus and translate that information into numbers that one can understand. These calls are done in the control task in the Tink project. The data is placed in a queue for use in steering and balancing operations. Then the data is placed in a secondary queue for a different use. This data is then taken from the queue by the WebSocket task which sends the data over Wifi to be displayed to the user.

HTTP Server[edit]

TInk Web Interface

The HTTP Server serves up the HTML page to those who browse to it. The task is set to serve up to the page the one controlling Tink and no one else so that way control is not interrupted by others.

Websocket
[edit]

HTTP is a very useful protocol but it is based on a request and response system. When controlling TInk it is more useful to be able to send commands down to it in real time in order to control the tank with minimal lag. This is where WebSockets come in. WebSockets allow for bidirectional communication between a client and host.

TInk uses a fairly simple communication protocol. TInk sends up motion data. It is sent as a string. Index 0 of the string has 'D' to signify data. An acknowledgement packet is sent back.  This acknowledgement is a string with the single character 'A'. PWM commands are sent down to TInk. These commends are strings of length 4. Index 0 of the string is the character 'C', to signify control. Index 1 is the direction the tank is to be moving. The character 'F' is sent for forward and 'R' is sent for reverse. Index 2 of the string is turning data.  'L' for left, 'R' for right. Index 3 of the string is speed. There are 10 speeds (0 - 9) to choose from.

HTML5 Webpage
[edit]

TInk serves up a webpage in order for users to drive the tank. This page is HTML5 based and functions on most modern browsers. The page is dynamic and adjusts it's size based on the screen of the device it is loaded up on. All of the graphics are HTML5 canvas elements. This allows for light weight code that looks like a native app. HTML can request information from a browser and that is what TInk does. There is code that asks the browser if the device has a touch screen and if the device supports motion events. Based on the responses to these queries, the page looks and functions slightly differently. On a PC, the page displays keyboard controls. On tablets and smartphones, the page takes tilt data from the device and uses that for controlling TInk.

Applications[edit]

TInk has several applications. {{#ev:youtube|I-0c4I7Gc8I|Drive-By-Tilt|right}}

Drive[edit]

TInk, like any other tank, can be driven. But, unlike any other tank, Tink has two different methods of control.

Drive-By-Tilt[edit]

TInk can be controlled by tilting your smartphone or tablet with support for HTML5 canvas and websockets. There are several devices that TInk is known to work with: iPhone/iPad/iPod Touch with iOS 4.2+ and Android devices using Firefox. The Firefox browser is available on the Google Play Store. TInk does not function on Windows Phone 7 and has not been tested on Windows Phone 8.

Drive-By-Keyboard[edit]

TInk can also be driven using your traditional keyboard interface. This form of control should work with any desktop or laptop with a keyboard running a modern browser that supports HTML5 canvas.

No Sensor Feedback[edit]

Currently, TInk is driven without any sensor feedback. This means that each motor is given the same amount of power when driven straight. This may sound appropriate but due to differences in manufacturing each motor performs slightly differently. Thus, giving each motor the same power leads to a slight curve in the tank’s motion.

Semi-Autonomous With Sensor Feedback[edit]

Functionality for semi-autonomous control that corrects the motor differences through use of sensor data has been implemented. This has not been integrated into the main TInk project at this time but will be in the future.

Balance
[edit]

Once in the vertical position, TInk can balance itself on its hind axle. At the present time, this is a separate app from the main TInk program.

SfSoGB1gcv0|TInk Balance Progress}} CqnyA51CdHA|TInk Balancing}}

Smart Config[edit]

Smart Config is a TI provided app for configuring the CC3000 to connect to Wifi access points.  There is an included version of this that runs when button one is held down on the LaunchPad. There have been difficulties getting this to function so a separate app was created to allow for easier configuration. This app will need to be flashed onto the LaunchPad separately from TInk. The app is called EasyConfig and it is designed for use with the CC3000EM module. Once the app is loaded up, follow these instructions:

  1. Start with the Stellaris turned off.
  2. If the CC3000EM has been configured in the past continue to step 3. If this is the first time configuring the CC3000, go to step 4.
  3. Hold down switch 2 (SW2).
  4. Turn on the Stellaris. Press switch 1 (SW1).
  5. The CC3000 is now Smart Config mode (the blue LED should be blinking). There is an app available for smart phones on their respective app stores (iOS and Android) called SmartConfig.  Run this app to configure the CC3000 to an access point.
  6. The CC3000 should be configured now. TInk can now be reloaded onto the Stellaris and should function.


Current Project Status[edit]

Development on the project has ended. Most of the goals that were set at the start of the project were achieved. There are some reliability issues to still squash but the tank functions for the most part, and is a fun gadget to play around with.

Known Problems[edit]

There are several known problems with the current version of TInk.

Server Instability[edit]

Sometimes the webpage fails to load. This often leaves the server in a state where a power cycle is required.

Web Socket Instability[edit]

The Websocket stops functioning at times. It gets stuck in a loop in the hci event handler. Rebooting the system does fix this. This problem happens frequently. Fixes with the temperature sensor my have fixed this problem.

I2C Bus Corruption[edit]

The I2C bus is sometimes not cleared. This chokes up the bus and it does not function properly. A power cycle fixes this problem

Sensor Hub Sleeping[edit]

The sensor hub at times does not return any real time data because it goes to sleep and never wakes back up. 

Balancing Integration[edit]

The balancing and autonomous behavior have not been integrated into the main project. They can be run as separate projects on the same hardware though.

Server Failure When Running Motors Near Full Power[edit]

There is an issue when running the motors at very high speeds (near or at %100). Over time (usually a few seconds) this will cause the Server to get stuck in the hci event handler and be unresponsive. The only way to fix this is to perform a power cycle. Through testing, power issues have been ruled out. It could be interference from the motors causing hardware issues with the CC3000EM.

CCS Project[edit]

The CCS projects for TInk will be posted to this wiki in the near future. Importing the project into CCS and loading it onto TInk hardware will give it the full functionality of the TInk bot. Projects are available for balancing and corrected driving as well as the Wifi easyconfig.

Project Hurdles[edit]

Hardware Design Notes[edit]

Power Issues[edit]

We had power issues using the LIPO battery booster pack. It is a booster pack made by a 3rd party using all TI parts. The battery boosterpack is based on old revision that was never meant to be released. It had many issues but, the one that affected the project most was everything turned off when the motor driver was on at random instances, so what we did was scrap the booster pack and use the lithium battery for power.

It was later found that there was not a common ground between the Stellaris and the lithium battery. There would be a voltage difference of about .3 V. To fix that, a wire was added from the contact on the battery to the ground on the Stellaris.

CC3000EM Wifi Inrush[edit]

The CC3000 is available in two flavors. The booster pack version is the latest and works great. Originally the CC3000 was released as an EM module to be placed on top RF headers, such as the ones on the Sensor Hub Booster Pack. This original model has the exact same spec as the boosterpack model but had one flaw, a very large inrush at startup. This inrush causes problems with the LaunchPad, the brownout switch goes off and causes an infinite reboot cycle. This problem is well documented and people have found a solution: external power. The brownout switch on the Stellaris was removed and a diode was added, pointing to the CC3000 voltage header and then connected that to the VBUS of the Stellaris for more current to stop the dip that the board initially sustains. With that fix, the boot cycle issue is no longer a problem.

Motor Inrush
[edit]

Early on in the project the team had planned on using a battery boosterpack. This boosterpack powered the whole tank, including the motors. The battery couldn't push out enough juice for the motors to run along with the Wifi with enough power. Due to this the power source was changed to the lithium ion battery. In order to isolate the 5V USB launchpad power source from the inrush and back EMF generated by the motors, the motor driver's motor voltage is routed directly from the battery's positive terminal, bypassing the USB regulator. This solved the motor inrush problem.

Application Software Notes[edit]

SensorLib Integration[edit]

Integrating the SensorLib Library was not trivial.  We wanted the control task to have the primary access to the sensor data. So the control task calls SensorLib calls to get the data from the SensorHub that is then analyzed and used for steering and balancing. First the data is placed in a queue so that it can be processed and averaged. Then the data is placed in a secondary queue for the websocket task to access. This is because extra calls to collect data for the websocket task would be inefficient.

Later in the project there were issues with the queue being filled.  It was found that the collection of temperature data was causing this problem.  All temperature data collection calls were removed and now the queue is consistantly filled with data.

HTTP Server Integration[edit]

The HTTP server portion of TInk was very early example code from another TIer. There were integration problems early on which caused the webpage to not load. An easy solution for this was to set the priority of the HTTP server task higher in order to make sure the webpage is served up properly.

WebSocket Integration[edit]

WebSocket code was implemented from a third party source. The code worked on its own but, when added to TInk, there were major stability issues. We found that increasing the priority of the WebSocket Task over the HTTPserver corrected it for the most part. Also, adding a gate so that neither task could access Wifi driver calls at the same time added another layer of safety. There was also a memory leak when the websocket did not disconnect properly. This was fixed by freeing up the memory when there was a sudden disconnect of the websocket.  

Driving Straight[edit]

Gyro Calibration Period

As TInk uses two motors to drive, the mechanical differences between the two prevent the tank from driving in a straight line when the two motors are given the same amount of power. While this is less of an issue when driving by tilt, its effects are apparent when using the keyboard to control the tank.
Note: feature has not yet been integrated into the main project.
Solution:
Using the integrated data from the gyroscopes on the sensor hub to determine the rotational position of the tank, TInk can correct its own motion (ie. if the data indicates the tank was facing right, more power is given to the motor that would make it turn left.) A one-second calibration period is necessary to determine the inherent offset apparent in the gyro data (see graph at left.) To mitigate the effects of gyro drift, there are running counts for the number of corrections Tink has made to the right and left. Whichever count is greater allows the tank to determine which way it has drifted and to correct its motion based on the difference between the two values.

If knocked off course, the tank will correct and return to its original direction while assisted driving is active.

PdbgiwILudo|Unassisted vs Assisted}} 8cnaFapi-4w|TInk Correcting Movement}}

Balancing[edit]

TInk has the ability to balance itself when it has been placed in a vertical position. Once data is collected from the SensorHub, it is placed in a queue. The data is then processed and used in a PID loop in order to know the tank's position. This data is then interpreted so that a reactionary signal can be sent to the motors. The motors are given the appropriate PWM commands in order to keep the tank balanced while in this vertical position.

The TInk Team[edit]

Bader Ali-Saleh Peter Samyn Evan Lew Sophie Russo
Bader tink.JPG

Image.jpeg
TInk.JPG

Sofie tink.JPG
E2e.jpg {{
  1. switchcategory:MultiCore=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article TInk here.

Keystone=
  • For technical support on MultiCore devices, please post your questions in the C6000 MultiCore Forum
  • For questions related to the BIOS MultiCore SDK (MCSDK), please use the BIOS Forum

Please post only comments related to the article TInk here.

C2000=For technical support on the C2000 please post your questions on The C2000 Forum. Please post only comments about the article TInk here. DaVinci=For technical support on DaVincoplease post your questions on The DaVinci Forum. Please post only comments about the article TInk here. MSP430=For technical support on MSP430 please post your questions on The MSP430 Forum. Please post only comments about the article TInk here. OMAP35x=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article TInk here. OMAPL1=For technical support on OMAP please post your questions on The OMAP Forum. Please post only comments about the article TInk here. MAVRK=For technical support on MAVRK please post your questions on The MAVRK Toolbox Forum. Please post only comments about the article TInk here. For technical support please post your questions at http://e2e.ti.com. Please post only comments about the article TInk here.

}}

Hyperlink blue.png Links

Amplifiers & Linear
Audio
Broadband RF/IF & Digital Radio
Clocks & Timers
Data Converters

DLP & MEMS
High-Reliability
Interface
Logic
Power Management

Processors

Switches & Multiplexers
Temperature Sensors & Control ICs
Wireless Connectivity