Wednesday, December 7, 2011

Introduction: the fail-Way, a crappy balancing robot that almost works

"Last post: April 20 2011" This blog is neglected.

I figured I'd document this here, since I intend to actually continue improving on this for a while. Hopefully this won't fade away like my other projects (water rockets, R/C cars, custom laser tag...)

The origin of this project stems from 3 parts:

1) A 4WD robot I built 4 years ago for Science Olympiad
2) A Wii Motion Plus sensor I bought for a quad copter I never built (inspired by this Hackaday post)
3) Buying an Arduino for a Science Olympiad even this year

Having the ease of use of the Arduino combined with the multi-purpose robot was what got me started on the idea of using my WMP sensor and a Wii nunchuck for a balancing robot. Because it was so easy I managed to do it in three days.

I did a lot of research on getting the two sensors to work together, as well as getting useful, filtered data out of them. I'm using the code from that link to fetch the accelerometer and gyro data from the Wii sensors over I2C. It also used some complementary filter to parse the data.

I then used some code from Shane Colton's Segstick Instructable to figure out motor control.

Or at least, tried to. I had to do some clever working around stuff, and rather than convert units or change equations, I just stuck something together to try and make it work. In the end, I had this:

PDangle = rollCF;
PDrate = roll;
PDoutput += PDangle * KP + PDrate * KD;
m1pwr = map(PDoutput, -100, 100, 27, 163);

It sort of works. It's enough to make my robot react correctly, but it's still not enough for it to stay upright for very long. It could also be the fact that I'm using a nunchuck held on by rubber bands, but I think it's a software problem.

Sadly, I hooked some things up wrong, and I messed up my Arduino. It still runs the last program uploaded (the fail balance one) but I can't program it anymore. Oh well. I plan to a) get an ISP programmer, b) replace the FTDI chip, or c) get a new Ardunio.

I'm sure I'll update this more, but it's late and I'm tired of typing, so here it is.

No comments:

Post a Comment