Wirelessly Controlled USB Missile Launcher on iRobot with Arduino (Files)

I. Introduction:

The purpose of the final project was to allow us to put the information we learned in class to practical use through a project. We decided to choose a project that would challenge our ability to solve problems and ultimately prove to ourselves that we actually did learn in EE360 this semester. We chose to attempt to gain remote control of an iRobot Create with a USB Missile launcher mounted on it. The project turned out to be quite a challenge but we conquered the problem in the end.

Download files: http://idzr.org/o9tn

II. Theory:

Design Process

We came up with several design ideas before we decided to create a movable robot that could shoot a missile and was radio controlled by the user. The project is named Air Defense Artillery (ADA) since our objective was to create a controlled missile defense system. We wanted to control the robot via hardware, not software, so we knew that we needed a joystick shield. The shield would have an analog joystick to move the robot with a button to fire the missile. We decided to create the wireless connection via radio frequency transmitters and receivers. We opted out of using the simpler XBee platform because in a real production cycle, the RF transmitter/receivers are cheaper and easier to replace. There is very little difference between the two methods.

We did not know what type of missile launcher we would be receiving. We thought it would either be a regular USB missile launcher or, if we were lucky, one that we could easily plug into pins. It was the former, so we had to research how to connect an Arduino to the missile launcher. We were initially assigned a USB-to-Serial converter but after research we found that this would not work as we needed a master USB port. The missile launcher came with an API which allows us to control the missile launcher with visual basic scripts. The API came in handy as we could write visual basic scripts onto the Arduino. When the fire button was pressed, the script would run ideally. For controlling the robot, we overrode the sensors on the robot and changed to the states from Lab 5 with the movements from our joystick. Since we were wireless, we were using our laptop to power the transmitting Arduino, and the iRobot to power the receiving Arduino. Figure 1 shows our block diagram.

 

Missile Control Unit

Arduino

RF Transmitter

RF Receiver

Joystick Shield

iRobot Create

Missile Launcher

Arduino

Control Unit

Radio Frequency Unit

Wireless Connection

Robot Control Unit

Laptop (Power Source)

iRobot (Power Source)

 

 

 

Figure 1: Block Diagram for ADA Robot

 

Procedures and Equipment:

Gaining remote control of the iRobot Create

Hardware

  • Arduino Duemilanove x 2
  • Joystick Shield
  • Protoboard x 2
  • 434 MHz RF Links

Getting Started

We decided that we would use the same inputs/outputs that we were introduced to during Lab 5: forward/turn, left/right, stop/go, speed msb, and speed lsb. This required us to determine which of the inputs we needed to use on the robot. This was made a lot simpler by the reference sheet we were given at the beginning of the project. The pin layout is described in Table 1:

Table 1: Robot Inputs

Port

Color

Hdr

 Pin

Label

5V

0V

Cargo Bay ePort

Black

JP2

Pin 1

STRAIGHT_TURN

straight

turn

Top Center ePort

White

JP2

Pin 2

TURN_DIRECTION

left

right

Top Right ePort

Gray

JP2

Pin 3

STOP_GO

stop

go

Top Left ePort

Violet

JP2

Pin 4

SPEED_LSB

1

0

Cargo Bay ePort

Blue

JP2

Pin 5

SPEED_MSB

1

0

Using these inputs we derived that we would need five output pins on the Arduino. But before we worried about how to connect everything up to the robot we had to figure out how to use the RF Links.

The most helpful tutorial we found was here: http://letsmakerobots.com/node/12336. This helped us to get the transmitter and receiver powered and operational. Figure 3 is an illustration of our control module.

Figure 2: Control Module

The code found on the website did not work however. It was hard to determine whether the equipment was working without operational code so we searched for alternative code. What was we found was VirtualWire (http://www.open.com.au/mikem/arduino/VirtualWire.pdf). VirtualWire is an Arduino library specifically designed for use with wireless transceivers. Using the example code we were able to derive a working code for the transmitter and receiver. Once we confirmed that data was actually being transferred we began to mold the code into something we could use.

 Coding

Our control was implemented through an Arduino joystick shield connected to the transmitter. We first had to determine the pin layout of the joystick of the joystick to see where we should begin. We found this layout at the manufacturer’s site: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Dev/Arduino/Shields/Joystick_Shield-v14.pdf.

Once we knew the layout it was a matter of determining how to create cases. Essentially, the way a transceiver works is that the receiver acts based on the message it receives from the transmitter. In this case we used numbers. Using a series of if/then statements we created several “states” which corresponded to the actions on the controller. The code snippet below is an example of what we did:

We created a series of statements for every single function we wanted an assigned it a separate value. We then turned to the receiver code.

The receiver is actually the most important of the pair because the receiver actually executes the actions. Our receiver was pretty easy to code once we understood how they worked together. We declared five pins as each output to the robot and used the “digitalWrite” command to achieve the desired function for each value. The hardest part of the process was determining which number represented what action from the transmitter code. A snippet of our receiver code is below:

After troubleshooting the code we focused on actually attaching our equipment to the robot. This was relatively simple once we determined how the ribbon cable worked. We placed a protoboard containing an Arduino and the RF Receiver in the cargo bay of the iRobot Create. We then removed the DE2 board from the robot to give us space to work. Using the power supply from the DE2 board we were able to power our Arduino. We then connected the output pins on the Arduino to the corresponding pins on the ribbon cable. The setup is shown in Figure 2.

Figure 3: Connecting Our Equipment to the Robot

After a little troubleshooting we had successful control of the iRobot Create using the Joystick shield and RF Links. Next we turned to the launcher to figure out how to implement it into our design.

Establishing Communication with the USB Missile Launcher

Hardware

  • Arduino Duemilanove
  • USB Host Shield
  • Ninja Gizmos Striker II: USB Laser Guided Missile Launcher

Getting Started

The big challenge of the USB rocket launcher part of this project was actually communicating with the launcher via the Arduino. Ninja Gizmos has a C# API for the rocket launcher but we were unable to implement this on the Arduino since the Arduino does not communicate with the hardware using C# natively. Thankfully, we were able to use the Ninja Gizmos software to help us figure out the hardware specifications of the launcher. We knew that the computer was sending the launcher some sort of commands via USB.

busdog

“busdog is a filter driver for MS Windows (XP and above) to sniff USB traffic” (code.google.com/p/busdog). What busdog does is allow users to see the commands that the software Ninja Gizmos provides is sending to the USB rocket launcher. The commands are in Hex and are eight bytes of data. The commands are sent four times and with all commands beside FIRE, STOP is also sent four times. Below are the eight byte values for each command as seen in our Arduino code:

char FIRE[]  = { 0x0A, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char LEFT[]  = { 0x0C, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char RIGHT[]  = { 0x0D, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char UP[]  = { 0x0E, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char DOWN[]  = { 0x0F, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char STOP[]  = { 0x14, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

char LAZER[]  = { 0x0B, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };

Legacy USB Library

The Arduino software and compiler was updated to 1.0 fairly recently. This was unfortunate for us as most of the libraries were not updated. The USB library was updated but it lacked a key feature we needed for our design. We wanted to send multiple bytes of data at a time through the USB. In the legacy library, we could use the setReport(..) command. The updated USB library did not have this command and we were unable to find an alternative as most libraries do not have helpful and searchable documentation similar to javadocs. Luckily, we were able to use the legacy library and were able to get the code to compile by updating the library ourselves. We basically just removed all the code that the new Arduino 1.0 compiler was complaining about.

We borrowed code from an existing project for the Cheeky Mail Notifier (http://www.circuitsathome.com). This device receives USB commands and lights up according to the command. We modified the code to send the rocket launcher commands depending on the specific button presses on our controller. We also had to see which address our launcher was using. We found this information out using the tools included in the legacy USB library.

Synthesis

            Once we knew what the commands for the launcher were, it was a matter of determining how to implement them. We added the initialization information from the Mail Notifier code to our Receiver code as shown below:

This code worked to initialize the launcher and from there it was just a matter of adding the new commands to the existing state functions:

Once we had implemented the code we had a working project. Both the launcher and robot were now being controlled at the same time using the Arduino + Joystick Shield. Our entire completed code can be found in Appendix A.

Results and Discussion:

Though we were able to successfully complete our project we ran into several problems along the way. We overcame all with the exception of two.

Problems

1)      Issues connecting the receiver module to the iRobot Create.

We solved this problem by using the ribbon cable. We found that it was a lot simpler to use the ribbon cable to route our inputs and power the board than trying to connect directly to the serial ports.

2)      Compatibility issues with Arduino and USB Host Shield

The USB Host Shield we were given was not designed to work with the Arduino Duemilanove. We fixed this problem by writing the pins the USB needed to high. This allowed the USB to initialize despite the issue.

3)      Output pin conflict with USB Host Shield

When we initially implemented our code with both the launcher and the robot together we found that the launcher worked while the robot just jerked uncontrollably. We discovered that the pins we were trying to use at outputs to the robot were actually already in use by the USB Shield. We fixed this problem by assigning different output pins. However, we had to eliminate the speed lsb pin due to lack of space on the shield. So this problem was not completely resolved.

4)      The way we implemented sending commands is not the exact way the launcher was made to receive commands

As stated before, the rocket launcher receives four commands at a time, and then four stop commands (except for the fire command). With our current code, the rocket launcher repeatedly receives the commands until we “cancel” it. We worked around this problem by simply sending the opposite command to the launcher which served as a “stop” function.

5)      There were delays after sending commands to the launcher

We usually had to wait approximately five seconds until another command was recognized by the launcher. We have reason to believe this may be an Arduino problem and not a coding problem as other groups had similar experiences when using USB devices. Although, we think adding extra delay() statements in our code could help mitigate this issue and not overwhelm the Arduino.  Ultimately, we were not able to resolve this problem.

Conclusion:

Though there were bumps along the way, we ultimately solved our problem. We applied the skill we learned in EE360 throughout this semester and turned them into something tangible. We both learned from this experience that we are capable of solving complex problems given enough time. For both of us, this project served as a confidence booster and a great start to our respective academic pursuits.

 

 

 

 

 

 

 

 

 

Appendix A

Transmitter

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Notes

The links contained here are the ones not directly cited within the report:

http://code.google.com/p/busdog/

https://github.com/felis/USB_Host_Shield

Download files: http://idzr.org/o9tn

Video

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s