DSC_5539 (copy).JPG
This instructable shows how to build my ArduRoller balance bot. It balances quite well on the spot and responds to most knocks pretty quickly but sometimes giving it a more gentle push sends it gliding across the room at a constant speed. I'm still working on that.

There's a video of the bot in action at http://www.flickr.com/photos/fasaxc/5944650602/.
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

DSC_5539.JPG
DSC_5540.JPG
DSC_5547.JPG
DSC_5548.JPG
Here are the parts I used:

1 x Arduino Uno
1 x Sparkfun Ardumoto motor driver shield
1 x Sparkfun BlueSmirf Bluetooth modem
1 x 150 degree/s gyro
1 x 1.7g Accelerometer
2 x Arduino header kits
2 x screw terminals
2 x 24:1 gear motor
1 x set of 70mm wheels
2 x JST connectors
2 x LiPo batteries
1 x basic LiPo charger
3 x Multi-turn 10k potentiometers
1 x SPST switch (Radioshack)
1 x Laser-cut bamboo chassis via Ponoko  (link should allow you to make one from my shared design)
1 x LED
1 x Normally-open push switch
1 x packet of Sugru to make the bumber
Assorted M2-04 machine screws (6mm - 16mm) (found on Amazon)
M2-04 nuts to match machine screws above
Assorted straight and right-angle break-away headers
Assorted jumper wires
Solid core wire
Stranded core wire
Instamorph (aka Polymorph) low-melt-point thermoplastic

Notes:

Chassis: the motors didn't quite fit the mounts I made so I had to sand them down and rebuild them with instamorph.  I think the sensor bundle suffers from too much vibration, it might have been better to make it more solid rather than sticking out as it does.

Accelerometer: I originally tried building the bot with only an accelerometer for tilt sensing and no gyro.  It turns out that approach is a non-starter -- the accelerometer gets overwhelmed by the acceleration due to the motors so it can't be used to estimate tilt while the bot is accelerating.  OTOH, using only a gyro would make the bot susceptible to drift over time so you really need both.

Gyro: I used a 150 degree/s rate gyro.  From looking at the telemetry from my bot, I'm pretty sure it sometimes clip if you give the bot a knocks so if I was starting over I'd probably look for a 300 degree/s model.  

Wheels: the wheels are a little fragile, after a few knocks I noticed cracks around the axle so I strengthened them with instamorph.

Motors: I also tried sparkfun's 100:1 gear motors but they weren't fast enough.  The 24:1 versions have plenty of torque and speed.

Bluetooth: I use the bluetooth modem for telemetry right now but I'm also planning to use it for remote control from my Android phone.  If you omit it then the robot will still work but tuning it will be harder.

Pots: I added 3 10k multi-turn pots to the design to allow me to easily tweak internal values.  Using 3 might have been overkill since I tend to tweak only one thing at once.

Instamorph:  Amazing stuff.  It's a tough, white plastic (resembling solid nylon) at room temperature but if you heat it in boiling water it turns into a pliable goo that's really easy to work with your hands.  A heat gun is great for working with it too, allowing you to melt small areas. 
aizhan92 says: Apr 17, 2013. 2:52 AM
Ok. But what about d_tilt_pot? it is not used anywhere, why do we read its analog value? In the code there is the line: speed = 7 * sqrt(abs(speed)). Is 7 related somehow to the diameter of the wheel?
aizhan92 says: Apr 16, 2013. 3:02 AM
Thanks for your reply) Now I'm trying to understand the code, but some parts of the program are unclear. Why GYRO_OFFSET = 3.982, and X_OFFSET = 8 ? And why do we need potentıometers? Have you used complementary filter or other one? Thank you in advance:)
fasaxc (author) in reply to aizhan92Apr 16, 2013. 8:54 PM
The potentiometers allow adjustment of the PID controller without recompilation. I can adjust the code so that the potentiometers change any value that I'm interested in and then change the potentiometers gradually to experiment. It's much faster than recompiling the code every time.

The other values are the calibration values for my particular sensors. You'll need to work those out for your own sensors too or experiment until you find the right values.
WhiteTech says: Apr 15, 2013. 12:49 AM
Any fix on the constant speed across the room issue? I think that could be solved with a line that would slowly increase the amount of correct if the initial amount does work. SO instead at going across the room, it would increase until it had enough to right it self
fasaxc (author) in reply to WhiteTechApr 15, 2013. 7:43 AM
I already have an integral term in my controller but due to symmetry it doesn't work to prevent horizontal drift. Increasing it tend to make the bot oscillate back and forth but it still drifts across the floor as it does so. It's probably theoretically possible to derive the drift rate from the sensors but they're so noisy that it's very difficult. It'd be must easier to just add shaft encoders so that my bot can tell exactly how far it has travelled and how fast.
WhiteTech in reply to fasaxcApr 16, 2013. 12:18 AM
I apologize for my lack of knowledge on the subject. I've been just getting into controllers, and was looking into balance bots as a project. Been a bit tough, dropping out of calculous sure doesn't help matters, especially in terms of PID controllers....
WhiteTech in reply to fasaxcApr 16, 2013. 12:00 AM
Hmm, that is an unfortunate downside to reasonably priced electronic components. Shaft encoders might do it, but Im not sure how that would solve the oscillation due to sensor noise. Now that got me thinking. What about another line that would dictate how much power the integral line would be allowed to add to correct offset? So the closer the bot is to up right the lower the limit, and as the angle increases the higher the limit would be set if it was needed. Less chance of over correcting. But if it were too low you'd might get a slow side to side sway.
fasaxc (author) in reply to WhiteTechApr 16, 2013. 9:00 PM
Ah, but what if the bot is upright and moving, then the integral term would do nothing and we're back to square one! In short: control theory is hard and there are a lot of non-obvious consequences of any change. I've experimented quite a lot with all the PID parameters but without a rewrite I think the code is as good as it's going to get. (A rewrite would let me make the code more performant so it might shorten the control loop and result in better control.)

Using the shaft encoders would help oscillation because I could reduce the integral term and rely instead more on the shaft encoders. Unfortunately, amalgamating multiple inputs like that requires more complex control algorithms that I'm not familiar with.
aizhan92 says: Mar 10, 2013. 2:06 PM
Hi! I'm going to build this robot, and I have a question: can I use triple axis accelerometer instead of dual axis? or can I use evaluation board ADXL203EB? I could not find ADXL203CE breakout board.
fasaxc (author) in reply to aizhan92Mar 13, 2013. 3:41 PM
Using a 3-axis gyro would be fine but you'll need to have a good understanding of the design and the datasheet of the gyro you use in order to adapt the design. I don't want to put you off but this project is not an easy one for a beginner; you'll need a good understanding of the design and the theory behind the algorithms to get it to work. It's not just a matter of running my code, you'll need to calibrate it. Good luck!
adamlukegilbert says: Sep 4, 2012. 5:15 AM
Hey mate, i'm learning to play with the arduino hardware, and am going to attempt to remake your arduroller. Can I throw you questions everynow and then?
fasaxc (author) in reply to adamlukegilbertSep 4, 2012. 11:11 AM
Sure, but, unless you've got a good handle on the engineering already, I wouldn't try the Arduroller as a first project. It's tough to get right and some of the parts don't seem to exist any more so you'll have to be comfortable adjusting the schematics and code for a different gyro.
adamlukegilbert in reply to fasaxcSep 6, 2012. 2:32 AM
I'm building myself up. Arduroller won't be my first, but it's what I will be working towards. I was going to ask you how you used the JST connectors on the prototype section of the board to power the ardumoto?
fasaxc (author) in reply to adamlukegilbertSep 8, 2012. 5:38 PM
I wired them in series and then connected them to Vin so that it would power the Ardumoto and the Arduino via its 5v regulator.
Delpap says: May 3, 2012. 7:44 PM
I could not find ADXRS613 and ADXL203CE on Sparkfun, any replacement for that , may be I can purchase on eBay ? Thanks.
fasaxc (author) in reply to DelpapMay 3, 2012. 8:39 PM
I haven't found a good drop-in replacement I'm afraid. If you're building my bot, make sure you don't go below 150 deg/s. 200 deg/s or 300 deg/s might actually work better (sometimes the bot moves more quickly than 150deg/s, leading to clipping). Remember to check the voltage of the gyro you get matches the microcontroller you're using.
bpark1000 says: Feb 26, 2012. 5:21 PM
Ways to make your bot work better:

Low pass filter the accelerometer with a very low corner (comparable to the drift time of the gyro). Add that into your angle calculation, rather than directly adding it in. I don't think you need a Kalman filter. That is for noisy signals. (Yes the accelerometer is "noisy", but not in the band of interest). Put optical encoders on the motors and feed this into the loop. This will stop "running across the room". (The reason Segway doesn't need this is the rider controls this).

Put weight up as high as you can get on the bot. That will increase the stability.
fasaxc (author) says: Sep 17, 2011. 11:23 AM
Looks like someone else has built a bot based on my chassis design: http://blog.makezine.com/archive/2011/09/pierce-nichols-at-the-ohs.html
H4T says: Aug 23, 2011. 6:35 PM
Wow, that is a good lookin' bot ;) The laser cut wood really makes it look super professional! I know this kind of thing is aimed towards beginners and people who want to build prototypes quickly, but I still had to chuckle at an alternate title for this Instructable: "How to make the most expensive desktop Arduino balancer!" :P I would build one of these in a heartbeat, but I am really curious about the total cost of this bot! Like I said though, this would be an extremely satisfying project for a beginner, so I'm not trying to play down the badassery of this little guy!
fasaxc (author) in reply to H4TAug 23, 2011. 7:35 PM
Thanks. That seems like a pretty apt description ;-)

It's definitely not a cheap bot if you go with all the parts I used. I'd guess that I spent about $300 on it plus I had to buy tools. There are some parts that aren't necessary (like the $50 Bluetooth modem) and there are certainly cheaper motors and batteries available (you could probably save $50 there). I didn't work too hard to reduce the cost because I was building it gradually over a couple of months and I've found in the past that it's too easy to spend 5 hours searching only to save $5.

I'd say it's a medium-difficulty project. The physical build isn't that hard (although cramming everything on the protoboard is a bit fiddly) but tuning it to stand up correctly took me a long time with a lot of trial-and-error.
fasaxc (author) says: Aug 22, 2011. 6:17 PM
Thanks for the suggestions propellerheadgeek. I'm always looking for new places to find parts.

Do you do custom laser cutting? What're your shipping times/rates to California like?
propellerheadgeek in reply to fasaxcAug 22, 2011. 7:26 PM
I produce kits, but yes, I custom laser cut as well - check out my instructables if you get a chance. Priority flat rate small box to California is $5 - the other sizes aren't bad either. 2-3 day shipping, guaranteed by the USPS.
propellerheadgeek says: Aug 22, 2011. 1:37 PM
Very nice balancing bot! I really like the overall design. I'm a laser cutter - let me know if I can help develop the chassis a bit further. Also, instead of the sparkfun motors, may I suggest using http://www.solarbotics.com/products/gm2/

They are modifiable from 224:1 to 14:1 by removing a gear and are far more robust, plus... they mount ROCK SOLID with through hole mounting and the wheels that they use are nylon, inexpensive, and unbreakable.

Again, very nice bot!
fasaxc (author) says: Aug 22, 2011. 8:38 AM
Can't seem to get the video to embed but there's one on flickr: http://www.flickr.com/photos/fasaxc/5944650602/in/set-72157627058612467
Kiteman says: Aug 22, 2011. 1:10 AM
Any chance of a video of the 'bot in action?
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!