Wednesday, November 20, 2013

Homemade PPM Encoder

This project is a spin off from my PPM decoder project. The overall goal is to translate the individual PPM signals from an RC receiver (like THIS one) into usable data that can be sent via serial, I2C, or a simple analog pin. Breaking that down, we get three smaller goals. If you have no idea what I'm talking about, read up on the subject HERE.
1) Combine the different channels into one "PPM Stream"
2) Decode this stream using a microcontroller
3) Do something useful with this decoded information

This post will tackle the first issue. To decode the signals coming from the RC receiver we first want to combine all the different channels (e.g. aileron, rudder, elevator...) into one channel. We want to do this so that later we can decode all the channels with one hardware interrupt (a single pin). 

Before you begin, you should consider your different options
1) Buy a PPM encoder ($25) - This seems to be the most popular one. There are a few others floating around Ebay
2) Buy a receiver with a PPM Stream output - Various receivers have this functionality. There have also been reports of people using satellite receivers like THIS. I can neither confirm nor deny the feasibility of that.
3) Hack your existing receiver - Funny enough, your receiver probably has the signal in the form we want at one time or another. It then decodes it to separate out the channels for the different servos. If you can find the correct place to solder on a wire, you're in business. HERE is a great write up on this. I preferred a noninvasive approach.
4) Make your own external PPM Encoder- Read on!

Now, there are several ways you can make your PPM encoder. The most complicated way is described HERE. If you choose to go that route, I will forgive you. I have no doubt that it probably is more robust and "correct" than the way I am going. The schematic is included as well as the PCB gerber files, so if you have access to all the materials have at it.

The method I am using is pretty simple. Put a diode on each channel with a pull down resistor at the end. The schematic is below.



Note that the receiver is running at a 3.3V logic level. For some microcontrollers this is not a problem; the Arduino DUE operates at 3.3V logic. However, for a standard Arduino like the Uno or Mega2560 operating at 3.3V is flaky. While it may work, fluctuations could cause glitches. At any rate, I included a built in 3.3V to 5V logic level converter circuit.

The circuit consists of 4 resistors and 2 transistors. I based mine off of the circuit found HERE. It is worth noting that there are other ways to convert 3.3V logic to 5V. I am not qualified to explain all of them, but I can say that ready made solutions are available from many different vendors.

When you combine these two circuits, the following schematic emerges.


Running a quick LTSpice simulation on it yields the graph below. Note that blue is the output on the 5V side. Red is the input on one of the channels (in real life this will be digital, but I just did a voltage sweep from 0 -3.3). Green is the voltage at the 3.3V output. Note the slight voltage drop. While this is insignificant when using the logic level shifter, it is something to note if you are using a 3.3V microcontroller.


Now to assemble it.

Bill of Materials:

  • 1 - Protoboard
  • 9 - Male Headers 
  • 6 - 1N4148 Diodes
  • 2 - 2N3904 NPN Transistor
  • 3 - 1k Ohm Resistor
  • 1 - 10k Ohm Resistor
  • 1 - 1.5k Ohm Resistor

1N1418 Diode Array

Finished Product

Underneath Side

The keen eyed observer may spy that I substituted a 1k resistor for the 1.5k, and it works fine. I didn't have a 1.5k. You may also notice that it could be made a bit smaller with a little effort. That will be work for v2. 

On the finished product picture above, the six male headers are the six 3.3V inputs. The two male pins the the right are the 5V and GND connections. The single male header at  the bottom is the 5V encoded output. Below is a picture of it connected up to my Arduino Mega 2560 and 6 channel OrangeRx receiver.



Here are the results. The first picture is the signal when all the pins of the receiver are just straight wired together. The second picture is when the signals are run through my encoder without the logic level converter.The third is the full encoder output with the logic level converter. The main difference is the peak voltage. Without the encoder, each peak is about 500mV. With the encoder, each peak is about 4.9V. All three circuits are on channel 1 on the oscilloscope. See the scale in the bottom left of the oscilloscope screen.
Without Encoder
Encoder Without Logic Level Converter Circuit
Full PPM Encoder Output
As you can see, the encoder works perfectly. Each signal is distinguishable from every other signal and is large enough to be read by an Arduino. It is ready to be fed into one of the Arduino's hardware interrupts to be decoded. To decode the RC receiver signals go to my other post, Arduino PPM Decoder: Decoding an RC Receiver with an Arduino.

Let me know if this works for you! If you have problems, comment below and I will do my best to help you. 
Matthew

Arduino PPM Decoder: Decoding an RC Receiver with an Arduino

In this post I will detail how to decode the PPM signals from an RC receiver using an Arduino. Specifically, I will decode the signals from a 6 channel OrangeRx receiver using an Arduino Mega 2560 r3 and my custom PPM encoder board that I describe HERE.

As most interested people know, the only good way to do this is with interrupts. While pulseIn will work for a few channels, more than 2 or 3 will bog it down too much to do anything useful.

Step 1
Access PPM Stream. THIS site describes what I mean by that. In short, we want to combine the single signal from the six individual pins into six signals on an individual pin. This allows us to decode all 6 channels with one hardware interrupt. That's something any Arduino can handle.

Like I mentioned above, you will need my PPM Encoder to do that (there are other options that I discuss in that post as well). Luckily, it is fairly cheap and easy to make. You may ask, "Why can't I just wire all the pins together?" In short, it doesn't work. I tried. This is because when one pin is high, five are low. Again, more details are in my other post.

6 Channel PPM Stream

Step 2
Decode the PPM Stream. As you can see in the picture above, the PPM stream consists of six spikes that we need to decode. Now, there are many descriptions online about how to decode these signals using interrupts, but I wanted a hardware independent approach. I didn't want to have to worry about my timers not working when this code is running or anything like that. For that reason, I wrote some fairly simple code that runs right in the Arduino sketch (vs tucked away in a library). I just set a hardware interrupt that triggers from a rising signal and subtract the times between each. (Read more on interrupts HERE). This of course causes a problem for channel 6 which doesn't have a signal coming after it. For this reason we have to do a few other things when we get to channel six.

HERE is my code. Look at it for yourself. It reads the values from the RC receiver, scales them to 1-100 and then prints them to the Serial Monitor. I'm not entirely happy with the way that I handled channel 6 at this point, but it works fine. I initially tried getting its value inside Spike(), but the micros() function does weird things inside it. I may revisit my approach someday, but it works for now. Though I wouldn't put anything life threatening on channel 6 (or any of the channels for that matter..). Below is an example output.


There you have it. A simple Arduino PPM signal decoder. Now you can get inputs from virtually any RC receiver and use them in your projects, library free. Hopefully you found this useful. As always, if you have any problems comment below and I'll see if I can help. If you had success, great! I'd love to hear about that as well. If you like this post, check out some of my others by clicking on a label that interests you.

Best of luck,
Matthew

Saturday, November 16, 2013

iRobot Create - Arduino interface cable

This post details the construction of a custom Arduino interface shield and cable for the iRobot Create. See my tutorial series on the iRobot Create. This cable allows the user to easily and cleanly interface with the Create and communicate with it via the Arduino Mega2560's Serial1 port.

Parts List:

Assembly is fairly self explanatory when you see the pictures. Here are a few useful charts.

Arduino Mega PinCreate Cargo Bay Pin
TX1 (pin 18)RXD (pin 1)
RX1 (pin 19)TXD (pin 2)
GNDGND (pin 14)

The chart above shows the connections that must be made. Note that Serial0 on the Arduino cannot be used without additional external hardware.




Cargo Bay Pinout.JPGArduinoMega pinout.png
First things first, assemble the protoshield as per THESE instructions.

Next, solder the ribbon cable to the DB25 connector. I chose to do it in such a way that the pins would be mirrored on both end. Note the way the ribbon cable connectors work, every other wire is connected to the top row. Really, the only important thing is that you include pins 1, 2 and a ground. Crimp the ribbon cable connector on.

Now you need to solder on some male headers to the protoshield. This is where the ribbon cable will connect.

Connect the male header that corresponds to the ground to the ground pin on the Arduino. Use the colored wire to make a jumper that will go from the RXD and TXD pins to the Arduino TX1 and RX1 pins respectively (in the picture below, it is the black and white wire in the bottom center).

Note that Serial1(TX1/RX1) must be used on the Arduino Mega (the Uno will not work without external hardware). The serial port output TXD from the Roomba/Create is too weak to drive the RX serial port (Serial0) input of an Arduino properly. This is because of the USB-Serial converter on the Arduino: it also tries to drive the RX serial port input via a pullup resistor, but the Roomba does not have enough drive to pull the RX down below about 2.5 volts, which is insufficient to be reliably detected as a TTL serial input of 0. Furthermore, using Serial1 still allows for the use of the Arduino Serial Monitor for debugging purposes. Also note that Serial2 or Serial3 could be used if selected in software.

Test your board and see if it works!

I hope this post was somewhat useful. It isn't so much of a how to as it is a description of what I did. There are many ways to do it. Really, the only important thing is that you connect TXD to RX1, RXD to TX1, and GND to GND. When you do that, you'll be ready to head back to my tutorial series!

Matthew

iRobot Create: Arduino Control

Introduction

This is the fourth section of the iRobot Create tutorial. If you have not completed the first sections, I would recommend that you go back and do so by following the links below.

Sections

Reference Documents

These documents should be referenced for details on interfacing with the Create
  • iRobot Create Open Interface Manual (OIM)- This manual provides detailed information on the serial interface with the Create. It details the implementation of the opcode system used to control the various systems as well as the necessary measures that must be taken to receive sensor data from the Create. Information regarding sensor packet size, connector pinouts, and command details can be found here.
  • Roomba Class Reference Guide (CRG)- This document provides support for the Arduino "Roomba" library. Here details can be found regarding the functions included in that library.
  • iRobot Create User Manual - This manual provides an introduction to the basic functions of the Create and an overview of the basic onboard functionality

Necessary Hardware

Necessary Software


Arduino Control

Arduino control can be implemented using the Roomba library. This library handles all the background serial commands allowing the user to program the Create's functions using the Arduino IDE. If the Roomba library is not installed download it HERE. Unzip and install the library then restart the Arduino IDE (See How to Install a Library).

Arduino Basics

This tutorial assumes basic knowledge of the Arduino IDE. If instructions are unclear or problems arise concerning the Arduino system, refer to THIS page and my previous posts (the ones labeled Arduino).


Wiring

Connecting the Arduino Mega to the Create is simple. In general, connections should be made according to the chart below. See my post, iRobot Create - Arduino interface cable.
Note that Serial1(TX1/RX1) should be used on the Arduino Mega. The serial port output TXD from the Roomba/Create is too weak to drive the RX serial port (Serial0) input of an Arduino properly. This is because of the USB-Serial converter on the Arduino: it also tries to drive the RX serial port input via a pullup resistor, but the Roomba does not have enough drive to pull the RX down below about 2.5 volts, which is insufficient to be reliably detected as a TTL serial input of 0. Furthermore, using Serial1 still allows for the use of the Arduino Serial Monitor for debugging purposes. Also note that Serial2 or Serial3 could be used if selected in software.
Arduino Mega PinCreate Cargo Bay Pin
TX1 (pin 18)RXD (pin 1)
RX1 (pin 19)TXD (pin 2)
GNDGND (pin 14)
Cargo Bay Pinout.JPG
ArduinoMega pinout.png

In this tutorial, connections will be simplified using a custom interface shield and ribbon cable. Connect the Arduino as shown below. See THIS post for details on the custom interface shield and cable.
IRobot Create Arduino Wiring 1.jpgIRobot Create Arduino Wiring 2.JPG
Note:
  • The direction of the ribbon cable is important. It must be connected as shown.
  • The connection of the TX/RX cable is important. Connect it exactly as shown.
    • White: TX1 pin 18
    • Black: RX1 pin 19
  • When using the cargo bay connector, ensure that the mini-DIN connector (the one used with the Create serial cable) is unplugged.

The recommended input voltage for an Arduino is 7-12V, center positive. Verify battery voltage before connecting. 


Checking Connections: TestSuite

This example is included in the Roomba library (see "Necessary Software"). It allows for a quick assessment of Arduino-Create communication.
1) Open TestSuite.pde - In the Arduino IDE: File > Examples > Roomba > TestSuite
2) Connect the USB cable to the Arduino. Install the driver if not already done (How to Install Arduino Drivers)
3) Upload Program
  • Tools > Board > Arduino Mega 2560
  • Tools > Serial Port > [COM port]
  • File > Upload 
4) Open Serial Monitor - Set baud to 9600
5) Restart Arduino Mega by pressing restart button

A message indicating 0 errors should be displayed in the Serial Monitor and the Create should play an audible melody. If errors are reported, check the items listed below. Proceeding to other examples will be futile until these errors are eliminated.
  • TX/RX cable: White -> pin 18 , Black -> pin 19
  • Orientation of ribbon cable
  • Serial monitor baud rate
  • Arduino Driver Installed
  • Correct COM port selected

Controlling Drive Output

This example shows the basics of controlling the Create's movements. There are 2 basic functions that can be used to control the Create's drive motors. The Roomba library provides support for both. Details regarding usage of the 2 functions can be found in the Roomba Class Reference Guide. Information on maximums, minimums, and special cases can be found in the Open Interface Manual. 
  • drive(int16_t velocity, int16_t radius) - Velocity is in mm/s. Radius is in mm. Special values can be found in the CRG.
  • driveDirect(int16_t leftVelocity, int16_t rightVelocity) - Velocity is in mm/s.

1) Turn Create to OFF.
2) Open Roomba_Drive_Test.ino - In the Arduino IDE: File > Examples > Roomba > TTU Examples > Roomba_Drive_Test.ino or copy sketch from link at the bottom of the section.
3) Upload it to the Arduino Mega.
WARNING: If the Create is on, the sketch will start as soon as the upload is complete. Before uploading, turn the Create off. It is important to note that the Create may be ON even if the power LED is off. The power LED turns off when the Create is put in safe or full mode as well. Cycling power until the power LED is lit and then goes off will ensure that the Create is truly OFF. Regardless, it is a good practice to ensure that adequate space is available in case of accidental movement.
4) Disconnect USB and connect Arduino external power.
5) Place Create on large, flat surface (ie. the floor)
6) Power up the Create.
7) Restart Arduino.
The Create should cycle through a series of movements using the two methods of control as defined below. 
  • driveDirect
    • Drive straight
    • Spin CounterClockwise
    • Spin Clockwise
    • Stop
  • drive
    • Turn Left
    • Turn Right
    • Drive Straight
    • Spin Clockwise
    • Spin CounterClockwise
    • Stop


Reading Sensor Data

Sensor data can be read in two different ways. While both methods are described in the OIM, this example will only cover the getSensors() approach. The Create automatically updates its sensor data every 15ms. The user can choose often to read the values of those readings. While calling getSensors more frequently will cause no harm, the values read in that period will be redundant.
To read a sensor, the following information is needed
  • Sensor packet ID - the number associated with the sensor value the user is trying to read. Packets 0-6 are associated with groups of sensor values. Packet 6 is associated with all sensor values available 
  • Size of sensor packet (in bytes) - the number of bytes returned when the user calls a sensor packet ID 
  • Variable type returned - the way the bytes received must be interpreted. 
Example 1: Packet 7 returns one byte. However, it must be interpreted as individual bits. A value of 3 means that bytes 0 and 1 are 1s and therefore the Left and Right Bumpers are triggered.
Example 2: Packet 28 returns 2 bytes. They must be interpreted as one unsigned integer value. As in the "Drive Forward 20cm" example, a value of 1 and 44 would mean that the Left Cliff Sensor is reading 300.
All of this information can be found in the Open Interface Manual beginning on pg. 17. 
Useful Arduino functions for interpreting sensor values
  • bitRead - Reads an individual bit in a byte
  • Bitshift - Shifts the bits in a variable in either direction. Useful for high_byte, low_byte composition
  • BitShiftCombine - Function included in the example (defined at the bottom). Uses Bitshift to combine to bytes into a 16 bit int. Note that the int may be signed or unsigned depending on the receiving variable type. 

getSensors(uint8_t packetID, uint8_t* destination, uint8_t length)
  • packetID - number of packet to read
  • destination - an array with at at least "length" entries. Note that arrays are 0-indexed. ie, the first value in an array of 52 entries is array[0]. The last entry is array[51].
  • length - number of bytes associated with packetID being used.

Process for running sketch:
1) Open Full_Sensor_Test.ino - In the Arduino IDE: File > Examples > Roomba > TTU Examples > Full_Sensor_Test
2) Upload sketch to Arduino Mega
3) Open Arduino Serial Monitor - Set baud to 57600
4) Power ON Create
5) Restart the Arduino
Data from sensor packet 6 (all sensor data) should be displayed in the Serial Monitor. For more information regarding the nature of the sensor data, see the Open Interface Manual.


Basic Object Avoidance

This example demonstrates the use of the Create's sensors to navigate around obstacles. When executed, the Create should drive forward. When it bumps into an object, it should back up and turn away from the object. Sensor data is read using getSensors and motor control is implemented using driveDirect.


1) Turn Create to OFF.
2) Open Basic_Object_Avoidance.ino - In the Arduino IDE: File > Examples > Roomba > TTU Examples > Basic_Object_Avoidance
3) Upload sketch to the Arduino Mega.
WARNING: If the Create is on, the sketch will start as soon as the upload is complete. Before uploading, turn the Create off. It is a good practice to ensure that adequate space is available in case of accidental movement.
4) Disconnect USB and connect Arduino external power.
5) Place Create on large, flat surface (ie. the floor).
6) Power up the Create.
7) Restart Arduino. 

iRobot Create: MATLAB Control

Introduction

This is the third section of the iRobot Create tutorial. If you have not completed the first and second sections, I would recommend that you go back and do so by following the links below. They provide more insight into how the toolbox actually works. This section covers control of the iRobot Create via MATLAB. If you do not have access to MATLAB, feel free to skip this section. While it may be possible to use GNU Octave (a free Matlab compatible software), I know very little about that(Update: See my post on Octave serial communication HERE. More details on an Octave package coming soon).

Sections

Reference Documents

These documents should be referenced for details on interfacing with the Create
  • MATLAB Toolbox Documentation - This document provides details on the various functions included in the MATLAB toolbox. More information can be found in comments in the functions themselves.
  • iRobot Create Open Interface Manual (OIM)- This manual provides detailed information on the serial interface with the Create. It details the implementation of the opcode system used to control the various systems as well as the necessary measures that must be taken to receive sensor data from the Create. Information regarding sensor packet size, connector pinouts, and command details can be found here.
  • iRobot Create User Manual - This manual provides an introduction to the basic functions of the Create and an overview of the basic onboard functionality

    Necessary Hardware

    Necessary Software


    MATLAB Control

    Another convenient way to control the Create is with a MATLAB toolbox. The MATLAB toolbox to be used in this lab (Developed by Joel Esposito at the US Naval Academy) allows the user to control the Create from any computer via a serial tether. This lab will explore the basic functions of this toolbox. See comments in the scripts for details on each function. For more information, see comments in the functions themselves or read the MTIC Documentation

    Before beginning, download the MATLAB toolbox HERE and unzip it into the folder in your MATLAB directory. In windows it will be "C:\Program Files\MATLAB." Next connect to the computer the Create using either the iRobot serial cable and a serial extension or a bluetooth serial link. Open the Device Manager and make note of the COM port associated with the Create. Open MATLAB and proceed.

    ExampleButtonBeep

    This example demonstrates the use of the Create's Advance and Play buttons. When in Full or Safe Mode, these buttons may be read as digital inputs. The function ButtonSensorRoomba returns 1 for a depressed button and 0 for a button that is not depressed.
    1) Open ExampleButtonBeep.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RoombaInit() to RoombaInit(8) 
    3) Click the green run icon in the center of the MATLAB toolbar.
    4) Press combinations of the Play and Advance buttons to hear different patterns of beeps

    ExampleDrive

    This example explores two of the ways the user can control the Create's wheels, SetFwdVelRadiusRoomba and SetDriveWheelsCreate. See comments in the scripts for details on each function. For more information, see comments in the functions themselves or read the MTIC Documentation.
    1) Open ExampleDrive.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RoombaInit() to RoombaInit(8) 
    3) Place Create on large, flat surface (e.g. the floor).
    4) If not already done, turn Create to ON.
    5) Click the green run icon in the center of the MATLAB toolbar. 

    Observe how each function moves the Create. Note the distance measurements displayed in the MATLAB Command Window. They are the distance readings from the Create's wheel encoders. Note that the distance is taken as the average of the two wheels, so if one wheel traveled 1m and the other wheel traveled -1m. The distance is still 0. 

    Explore how different inputs effect the Create's movements and the sensor readings.

    ExampleDrive2

    This example demonstrates two of the ways to control the Create's wheels using feedback from the Create's wheel encoders, travelDist and turnAngle.
    Note: travelDist and turnAngle use scripting from the Create Open Interface. This means that these functions are blocking. The Create waits and will not accept any new commands (e.g. requests for sensor data or commands to STOP!!) until it has traveled the desired distance. For this reason, use of these functions should be limited to small distances.

    1) Open ExampleDrive2.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RoombaInit() to RoombaInit(8) 
    3) Place Create on large, flat surface (e.g. the floor).
    4) If not already done, turn Create to ON.
    5) Click the green run icon in the center of the MATLAB toolbar. 
    Observe how each function moves the Create.
    Explore how different inputs effect the Create's movements.

    ExampleSensorRead

    This example demonstrates the various methods of reading the Create's sensors. For details on interpreting the sensor readings, see the Create Open Interface Manual. 
    Note that not all sensor read functions are included in this example. See the MTIC documentation for information on other individual sensor read functions. 
    1) Open ExampleSensorRead.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RoombaInit() to RoombaInit(8) 
    3) If not already done, turn Create to ON.
    4) Click the green run icon in the center of the MATLAB toolbar. 
    Observe the values printed to the MATLAB Command Window from the different functions. Note the format of each reading. Using the Create Open Interface Manual and the MTIC documentation, interpret each value displayed and consider how that value might be useful. For example:
    CliffRgt = 0. What does that mean?
    Wall = 1. What does that mean?
    pCharge = 66.4563. What does that mean? 

    ExampleBasicObjectAvoidance

    This example demonstrates the implementation of basic object avoidance using the Create's bump sensors. 
    The Create drives forward until it encounters an object and turns away from it. Pressing either button (Advance or Play) while the script is running stops the Create. 
    Note: Set Serial Port to port connected to Create
    Note: ctrl + c stops execution of MATLAB code 
    1) Open ExampleBasicObjectAvoidance.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RoombaInit() to RoombaInit(8) 
    3) Place Create on large, flat surface (e.g. the floor).
    4) If not already done, turn Create to ON.
    Note: To stop the Create's movements, press one of its buttons or simply lift one of its wheels off the ground. If the Create becomes disconnected from the computer, it will follow the last command it was given.
    5) Click the green run icon in the center of the MATLAB toolbar. 
    Observe the behavior of the Create. Make changes to the example sketch to improve its functionality. What do the limitations seem to be in the system?

    ExampleKeyboardControl

    This example demonstrates keyboard control of the iRobot Create. 
    Note: Exiting keyboard control by any method other than pressing 'q' (e.g. clicking the red x on the window) will likely crash MATLAB. 
    1) Open ExampleKeyboardControl.m
    2) Set serial port to COM port associated with Create. 
    Example: For a Create connected to COM 8. Change RobotHardKeyBoard() to RobotHardKeyBoard(8), and change RoombaInit() to RoombaInit(8) 
    3) Place Create on large, flat surface (e.g. the floor).
    4) If not already done, turn Create to ON.
    5) Click the green run icon in the center of the MATLAB toolbar.
    6) Use keyboard commands displayed on screen to control Create.
    7) Press 'q' to end keyboard control

    iRobot Create: Console App GUI Control

    Introduction

    This is the second section of the iRobot Create tutorial. If you have not completed the first section, I would recommend that you go back and do so by following the link below.

    Sections

    Reference Documents

    These documents should be referenced for details on interfacing with the Create
    • iRobot Create Open Interface Manual (OIM)- This manual provides detailed information on the serial interface with the Create. It details the implementation of the opcode system used to control the various systems as well as the necessary measures that must be taken to receive sensor data from the Create. Information regarding sensor packet size, connector pinouts, and command details can be found here.
    • iRobot Create User Manual - This manual provides an introduction to the basic functions of the Create and an overview of the basic onboard functionality

    Necessary Hardware

    Necessary Software


    GUI Control

    One convenient way to get started with controlling the iRobot Create is with a desktop application. One such application (Downloadable HERE) that has been developed provides a convenient GUI to mask the underlying serial commands. Follow the instructions below to get started.
    1) Connect the Create as described above. Use of a serial extension is recommended.
    2) Run Create.1.0.1.2.exe (close RealTerm if open)
    3) Power on Create
    4) Select "COM Open"
    Use the following settings
    • COM Port: Default
    • Baud: 57600
    • Data Bits: 8
    • Stop Bits: 1
    • Parity: None
    • Flow Control:
      • RTS: Disabled
      • DTR: Disabled
    Note that "COM PORT OPENED" should be displayed in the bottom left corner of the window. If the program fails to connect, check that RealTerm is closed and no other program is using the COM port. If problems persist, open the device manager and ensure that the Create is using COM 1.
    Create COMopen.jpg 

    5) Select "Safe Mode." The lights on the Create should go out and the picture of the Create should change to that shown below. Note that if any of the wheel drop sensor are triggered, the Create will go into Passive mode again. Also note that Full Mode should not be used as it disables safety critical sensor functions.
    Create GUIsafemode.jpg 

    6) Check "Automatic Refresh" next to Get Sensor Data. Try triggering the Create's sensors. The green icons should now turn red when the respective sensor is triggered.
    Create GUIautomaticupdate.jpg 

    7) Place the Create on a large flat, surface and explore the various methods of control described below. The user should note, in case of emergency picking up the Create will cease all output. If the Create becomes unplugged, it will continue to follow the last command it received. For this reason it is a good practice to have one team member "spot" the Create while the other controls it. A robot traveling at 400mm/s can be surprisingly difficult to catch. 
    1) Directional buttons- These buttons allow the user to control the Create at a safe speed merely by clicking on the appropriate button. Note that the Create will follow the last command received until a new one is given. That is, the Create will follow the last command given (such as drive forward) until the user inputs a new command (such as stop). 
    2) Manual speed input- This option allows the user to input the desired speed of the Create (mm/s) and select a direction. Again, the Create will follow the last command given until it receives a new one. 
    3) Graphical control- Note the graph to the right of the window. It depicts the iRobot Create with the red line pointing toward the front of the Create. Clicking on a point on the graph will cause the Create to navigate to that point using it's wheel encoder data. Ensure that sufficient cable length is available before sending any commands. Each grid mark is 10 inches. 

    8) View the Log- Selecting the "Log" tab at top of the window allows the user to view the serial commands sent to the Create. Compare the serial commands sent for driving forward to those used in the "Getting Started: Using OI Commands" section. Reference the Open Interface Manual for information on each of the commands.
    Create GUIlog.jpg



    Goto: Arduino Control

    iRobot Create: Getting Started

    Introduction

    This is the first section of a tutorial I wrote for use in classes here at Tennessee Tech. The purpose of the tutorial is to teach the users the basics of operating an iRobot Create. The Create is an affordable mobile robot platform that incorporates sensors, motor drivers, and other control systems. It is very well documented and has been used extensively by many people. 

    Sections


    Reference Documents

    These documents should be referenced for details on interfacing with the Create
    • iRobot Create Open Interface Manual (OIM)- This manual provides detailed information on the serial interface with the Create. It details the implementation of the opcode system used to control the various systems as well as the necessary measures that must be taken to receive sensor data from the Create. Information regarding sensor packet size, connector pinouts, and command details can be found here.
    • iRobot Create User Manual - This manual provides an introduction to the basic functions of the Create and an overview of the basic onboard functionality

    Necessary Hardware


    Necessary Software


    Getting Started: Using OI Commands

    OI commands are sent to the Create via a serial connection. For a first example, we will send the these commands from a PC using a terminal program called RealTerm. Basic information regarding this interface can be found on page 11 of the the Create User Manual.

    Connect Create

    The Create communicates via the computer's serial port. Connect the Create as shown below using the white serial tether. This tether handles the logic level shifts necessary for the Create to communicate with the computer safely and connects only to the mini-DIN connector on the side of the Create, above the charging port. Note that serial cable extensions may be used to increase the Create's tether length. It is also important to note that nothing should be connected to the Create's cargo bay port at this time. Connected electronics can interfere with serial communications on the other port.

    Configure RealTerm

    Open RealTerm. Configure the serial settings to 57600 baud, 8 data bits, 1 stop bit, and no flow control. Select the “Send” tab on RealTerm. 

    Control LEDs

    This string of commands will turn on the Create's Play LED
    128 131 139 2 0 0 [Send]
    • 128 - This is the first Opcode. It starts the OI. This command must always be entered before sending other commands or the Create will ignore them.
    • 131 - This Opcode puts the Create in "Safe" Mode. This enables the user to control the iRobot Create without removing safety critical sensor lockouts.
    • 139 - This Opcode controls the LEDs on the Create. When received, the Create listens for 3 data bytes
      • 2 - This byte tells the Create to light the Play LED. Details on OIM pg 9. In binary, 2 = 00000010 (Play LED), 8 = 00001000 (Advance LED), 10 = 0001010 (Both LEDs)
      • 0 - This sets the Power LED color (green)
      • 0 - This sets the Power LED intensity to 0 (off).

    As each string of commands is sent, the user should be able to observe a quick flash of the indicator LEDs on the Create serial cable.

    Drive Forward 20cm

    It is possible to input a string of commands that the Create will then execute concurrently. This next example does this. Note:Be sure you have adequate room for the Create to drive as well as sufficient cable length BEFORE executing this sketch.
    128 131 152 13 137 1 44 128 0 156 0 200 137 0 0 0 0 [Send]
    153 [Send]
    • 128 - Start OI
    • 131 - Safe Mode
    • 152 - Script. See OIM pg. 15 for details.
    • 13 - Number of bytes in script. This must always follow the script command
    • 137 - Drive Opcode. Create listens for 4 bytes (OIM pg. 9)
      • Velocity - Velocity data is a 16 bit signed integer value sent in 2 8 bit bytes. We will send the value 300 (mm/s) (0b = 00000001 00101100)
        • 1 - Velocity High byte. 1 0b = 00000001
        • 44 - Velocity Low byte. 44 0b = 00101100
      • Radius - Radius data is a 16 bit signed integer value sent in 2 8 bit bytes. Straight is a special case. For this we will enter 32768 (0b = 1000000000000000)
        • 128 - Radius High byte. 128 0b = 10000000
        • 0 - Radius Low byte. 0 0b = 00000000
    • 156 - Wait Distance (OIM pg. 16) This data comes from the onboard wheel encoders. Accepts a 16 bit signed integer sent in 2 8 bit bytes.
      • 0 - Distance High byte
      • 200 - Distance Low byte
    • 137 - Drive Opcode. Create listens for 4 bytes (OIM pg. 9)
      • 0 0 0 0 - Stop
    [Send] 
    • 153 - This opcode executes the script previously stored. Note that this command can be added to the end of the script to make the script repeat. In this case, adding this command to the script would make the Roomba drive forward indefinitely.

    Try other values for the distance. (binary/decimal/hexadecimal converter)
    • 400mm = 1 144
    • 500mm = ?
    • 1000mm = ?

    Goto: GUI Control