The TriBot base includes wheel encoders that provide feedback about the actual wheel rotation to the TriBot main chip.
These 3 wheel encoders are connected to the TriBot board with 3 thin 3-wire cables. They take 12V as input and output 12V. This means that you should convert the output to 5v before connecting it to the Arduino, which is a hassle.
However, if you disconnect them from the tribot and power them in 5V, they will work fine and output a nice Arduino-friendly 5V.
So the connection of each wheel encoder to an Arduino is pretty straightforward: ground to ground, +5 to Arduino +5 output, and the wheel encoder output to any Arduino pin (preferably one of the interrupt enabled pins), configured as input.
I used my TriBot-based robot base to play with Android and Bluetooth. Goal: controlling the robot base with an Android phone.
The robot now look like that:
And the result, where you can see that the robot can actually turn and slide in all directions (left pad for sliding, right pad for turning):
How to connect Android to an Arduino?
I bought this very cheap serial/BlueTooth board (CSR Bluetooth chip/CSR BlueTooth chip) from Iteadstudio:
To connect the Android phone to the Arduino using this BlueTooth module, I used the Amarino library.
Setting up the BT module
The HC-06 BT Module is setup at 9600 bps by default. Amarino required it to run at 57200 Bps.
To change the serial connection rate, upload this code to your Arduino, disconnect it from your PC, connect the BlueTooth module to the serail port of your Arduino and restart it.
The code is strongly inspired by the MultiColorLamp example code.
The two interesting additional points are:
Each message is constituted with values (one for each motor, from -255 to 255). Using several values in a message is undocumented, but straightforward
I included a timer to stop motors after half a second without any incoming message. Usefull to prevent accidents when the Bluetooth get disconnected. Of course it implies that the Android application send messages constantly during to move the robot.
#include
MeetAndroid meetAndroid;
int MOTOR_ENABLE[] = {5,6,7};
int MOTOR_DIR[] = {4,3,2};
int STOP_DELAY=500;
unsigned long lastSignalTime;
int LED = 13;
void setup() {
Serial.begin(57600);
meetAndroid.registerFunction(setMotor, 'm');
for (int i=0;i<3;i++) {
pinMode(MOTOR_ENABLE[i], OUTPUT);
pinMode(MOTOR_DIR[i], OUTPUT);
}
pinMode(LED, OUTPUT);
}
void loop() {
if (millis()-lastSignalTime>STOP_DELAY)
stopMotor();
meetAndroid.receive();
}
void setMotor(byte flag, byte numOfValues)
{
lastSignalTime=millis();
digitalWrite(LED,HIGH);
int values[3];
meetAndroid.getIntValues(values);
for (int i=0;i<3;i++) {
int v=values[i];
if (v>0) {
digitalWrite(MOTOR_DIR[i],1);
analogWrite(MOTOR_ENABLE[i], v);
} else {
digitalWrite(MOTOR_DIR[i],0);
analogWrite(MOTOR_ENABLE[i], -v);
}
}
digitalWrite(LED,LOW);
}
void stopMotor() {
for (int i=0;i<3;i++)
analogWrite(MOTOR_ENABLE[i],0);
}
Using the Amarino Android Libary
I will not go into the details of the Android application, strongly inspired by MultiColorLamp as well. It displays a joypad, convert thumb positions into motor values (the tricky part), and send them to the Arduino by BlueTooth, using:
The Tribot is an autonomous robot from WowWee with a nice feature set, including omnidirectionnal wheels, voice synthesis and several sensors. It cost 65 euros, much less on the second hand market (I got mine for 30 euros)
Once I got fed up with its excessively talkative nature (which took less than ten minutes), I started thinking about hacking the beast.
The most interesting part of the robot is its lower part: 3 wheels + 3 reasonnably powerfull motors (with wheel encoders) + the main board (including motor drivers) + the 12V battery case. Building such omni-directionnal robot base with brand new components from a robot hobbyist shop would cost much more than the price of this robot.
What about controlling this robot base with an arduino?
The parts we are interested in in the main board are:
- The 3 H-Bridges
- The Wheel encoder output to get feedback from the wheel rotation
- The 12V output to power the arduino
The wheel encoder outputs are in 12V so they cannot be directly connected to the Arduino (this will be adressed in a future post).
The H-Bridges input for motor control can be directly connected to the arduino. To do that, I disconnected them from the main chip (using a Dremel on the chip pins) and soldered wires connected to the arduino instead.
Pinout is:
1: Motor 3 direction
2: Motor 2 direction
3: Motor 1 direction
4: Motor 1 enable
5: Motor 2 enable
6: Motor 3 enable
7-9: Wheel encoder feedback (not working properly, more info in a future post)
EDIT: It seems that the wheel encoder feedback does not work properly in this setup (it does not seem to be properly powered). Additional info in a future post.