SegWii
Hello I am Tijmen Verhulsdonck 17 years old and come form the netherlands. In the past six months I have been working on a self Balancing robot that you can control with a Wiiremote. I got the idea from Ara Kourchians he was thought of the idea to remote control a self balancing robot with a Wiimote. He never succeeded in connecting the wiimote to an Arduino and a Couple of other things.
Hey thats the great thing about open source someone else could pop up and finish your idea.
So I got the idea from Ara Kourchians and around the same time I found a youtube clip of someone controlling a servo with a Wiiremote connected to an arduino. So it was possible to connected and exchange data with a wiimote. On that point the theory said it was possible. Yes you can make a Self balancing robot with an Arduino and yes you can connected a Wiimote with an arduino.
As always it was a lot harder than assumed by me. I ran in to problems like unstable bluetooth code and had to use 2 arduino's instead of one. Because the code for connecting tot the wiimote was extremely sensitive that when you added to many lines of code it would drammaticly slow readings down and eventually become unusable. But arduino's aren't that expensive and with a sponsor backing me I decided to use 2 Arduino's. This solved the problem of the instable code and made programming the balancing part and all the other functions easier.
Okay back to the robot as I said it is self balancing, this was achieved using a IMU 5 DoF sensor from sparkfun coupled with 37D 1:29 pololu motors with encoders. The data from the IMU is filtered using a kalman filter to make a very nice smooth line. The encoders are tracked using interrupts and direct port manipulation. The connection with the wiimote was made using a Arduino clone with an atmega 328, a usb host shield form circuits@home and a csr2.3 bluetooth dongle from Sweex.
If you want more information about how a balancing bot works check out x-firm.com which has a great tutorial section for balancing robots. Oh yeah and it is a lot harder to build one than you would think (I found out the hard way).
You can find the code in the attached file and on the github link Below I will post my void loop code:
void loop() {
// ********************* Sensor aquisition & filtering *******************
LCD();
getMotion();
updateSensors();
ACC_angle = getAccAngle(); // in Quids
GYRO_rate = getGyroRate(); // in Quids/seconds
actAngle = kalmanCalculate(ACC_angle, GYRO_rate, lastLoopTime); // calculate Absolute Angle
// *********************** PID and motor drive *****************
drive = updatePid(setPoint, actAngle); // PID algorithm
if(abs(actAngle-setPoint) < 100) Drive_Motor(drive);
else Drive_Motor(0); // stop motors if situation is hopeless
//************************update Serial***********************
if (b == 1) {b = 0;}else {b = 1;}
digitalWrite(21, b);
// *********************** loop timing control **************************
lastLoopUsefulTime = millis()-loopStartTime;
if(lastLoopUsefulTime<STD_LOOP_TIME) delay(STD_LOOP_TIME-lastLoopUsefulTime);
lastLoopTime = millis() - loopStartTime;
loopStartTime = millis();
}
In the end I want to thank:
X-firm.com For the great tutorials on balancing bots.
Ara Kourchians For the idea
Circuits@home For the usb host shield
And my sponsors:
Tu Delft
Helenparkhurst almere
Self balancing robot remote controlled directly by a wiimote via bluetooth
- Actuators / output devices: 1:29 Pololu 37D metal gear motor with encoders
- Control method: Controlled via Bluetooth HID connection to Wiimote
- CPU: atmega328, Atmega2560
- Operating system: Arduino
- Power source: 5000mah 3s Li-Po Battery
- Programming language: Variant of C, arduino code
- Sensors / input devices: motor encoders, IMU 5 DOF, Wiiremote
- Target environment: indoor