OpenTank

OpenTank

This is a project involving the DFRobotShop Rover and the eZ430-RF2500. The original idea was to make the rover or tank wireless using XBee protocol and Series 1 XBees however, it was simpler to use the eZ430s instead. This project is a collaborative effort between Chris Barta and Thomas Watteyne.

To control the rover, Copy and paste the code below into the Arduino software.

int E1 = 6; //M1 Speed Control
int E2 = 5; //M2 Speed Control
int M1 = 8; //M1 Direction Control
int M2 = 7; //M2 Direction Control
void setup(void)
{
  int i;
  for(i=5;i<=8;i++)
  pinMode(i, OUTPUT);
  Serial.begin(9600);
}
void loop(void)
{
  while (Serial.available() < 1) {} // Wait until a character is received
  char val = Serial.read();
  int leftspeed = 255;  //255 is maximum speed 
  int rightspeed = 255;
  switch(val) // Perform an action depending on the command
  {
  case 'w'://Move Forward
    forward (leftspeed,rightspeed);
    break;
  case 's'://Move Backwards
    reverse (leftspeed,rightspeed);
    break;
  case 'a'://Turn Left
    left (leftspeed,rightspeed);
    break;
  case 'd'://Turn Right
    right (leftspeed,rightspeed);
    break;
  default:
    stop();
    break;
  }  
}
void stop(void) //Stop
{
  digitalWrite(E1,LOW);
  digitalWrite(E2,LOW);
}
void forward(char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void reverse (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}
void left (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,HIGH);
  analogWrite (E2,b);
  digitalWrite(M2,LOW);
}
void right (char a,char b)
{
  analogWrite (E1,a);
  digitalWrite(M1,LOW);
  analogWrite (E2,b);
  digitalWrite(M2,HIGH);
}

With this code uploaded into the tank we can control movement of the tank using the keys wads.

The tank is built around the Arduino platform and includes the headers of a standard Arduino. The Manual comes with a code to control the tank connected directly to the computer via USB. Using PuTTY we can communicate to the tank to tell it to go forward, left, right, and reverse using the corresponding keys wads.

Having the tank connected directly to the computer limits the range the robot travels to the length of the cord. One could use XBees but we decided to use the eZ430 because it is easier to interface with the robot.

TODO: Embed video of EZ430 connected to tank and controlled wireless.

When I met with Thomas I brought some Arduino shields in case we wanted to tinker around a bit with the Arduino. We (Thomas) figured out a way to connect the eZ430 to a Joystick Shield from SparkFun. Using the analog data from the joystick, we coded the eZ430 to control the movement of the robot. If you move the joystick forward the tank would move forward too and vice versa.

TODO: Embed video of joystick moving tank.

...to be completed.