Robotics with the Boe-Bot
Genetix
Posts: 1,754
I am stuck on how to do Project 2 at the end of Chapter 4 where it asks to write a program to make the Boe-Bot navigate in a circle. I know I need to make the inner wheel turn faster than the outer wheel but I don't know by how much.
Comments
I explained a bit about programming a robot to perform a figure 8 in post #35 of my cheap bot thread. The instructions assume one is programming in Spin but the concepts should apply to any programming language.
I've found it's important for the voltage to the servos be regulated in order to have a robot move consistently. The drop in voltage as a battery pack discharges will cause the speed of the servos to change as the voltage changes. It was very frustrating trying to get a robot to perform a figure 8 with unregulated servo power.
Of course you can do the circle by trial and error, but consider doing one by working out the math of the whole thing. It's fun! Of course that's just me. But, once you work out the math you have a greater understanding of how the critter works.
Amanda
haha! i know the feeling Genetix, I have been working on my boebot for a good part of a week (roughly 12 hours in) - i am taking a class in college and one of our testing projects is to get it to move in basic directions first
and of course a figure 8 is in it. It has been the most challenging part yet - it does move in a "figure 8" but not perfect yet. I did get it to move in a circle first, but only in one direction *this was part of class project*, i didnt even stop to think about doing it the oppisite direction.
Like i said its gotta be tweaked just right, you have checked out Erco's challenge, and you prolly seen some code on page 4, this is a short-cut method, and to be honest it will not work like his did (servos, batteries, electronics in general, etc.) but you could use that as a template. I wouldnt suggest it cause you will eventually end up tweaking it to make it do what you want. I basically wrote for circle right and then circle left, getting it smoothed through transistion is kind of a challege, but not "brute-force" - use some troubleshooting methods, here some info that you might think will help it helped me a bit the first few hours of coding (btw i abosultely hate programming and math, but yet i can do it...sometimes gracefully haha. i am an electronics technology major at my JC here.)
(source : boebotteacher.com) - good read has helped me tons.
DirectionLeftRight
CW ( <750 )
Backward
Forward
Still ( =750 )
Still
Still
CCW ( >750 )
Forward
Backward
if you run
PULSOUT 13, 650
PULSOUT 12, 650
see what you get, work it from there - make one a little faster than the other. etc.
baby steps
i am not using the standard battery holder (4xAA) i am using 4/3 A 2100mAh @ 1.2v (6x) [ 1.2v * 6 = 7.2v ] roughly puts out 8.90v peaked - i run it to about 7.80v and there is a difference. try using a lipo pack as they will keep V up a little better then a good old NiMh/NiCad pack, lol or what we did in our lab, really really really long jumpers and a DC PSU @ 9.01v. dont do that tho, its overkill for this small bot and you will get tangled! should have taken pix.
Ronnie
Ronnie,
Welcome to the forum. Are you running the CR servos directly off the battery? If so, you my greatly reduce the life of the servos. Some servos can handle 7.2V but these high voltage servos are the exception. Most servos shouldn't be powered above 6V.
I thought I'd try giving an early attempt at a hexapod some extra power by running the servos off of a two cell LiPo. It was only a matter of seconds before I burned out one of the servos.
A figure 8 with CR servos is pretty much impossible without using a regulated voltage source. The distance the robot travels at various speed settings will change as the battery voltage changes. I have a link to some inexpensive switching regulator in the BOM section of my cheap bot thread.
This is the method I used to set the servo speeds.
It's in Spin but hopefully it will make sense to those familiar with PBASIC.
In the above equations, I'm setting the pulse of each servo (PORT for left and STARBOARD for right). I'll convert the pulse length to those used by the BS2. For a ccw turn, I'd set "localSpeed" to 50 and "turnAmount" to 12. For a cw turn, I'd use -12 for "turnAmount" and leave "localSpeed" at 50.
The turn amount ends up increasing the speed of one motor while slowing the other one down a bit. The constant "STOP" is the pulse length used to stop the servo (750 in the BS2's case).
One would want to add PULSOUT statements where the Spin code calls the "Refresh" method (a method in Spin is kind of line a subroutine in PBASIC). You'd also want to add a pause to the loop and a way of keeping track of how long you've been turning. I kept track of the time elsewhere in the program.
The code:
Will just turn the robot in place.
This:
Should give you a circle. (Assuming pin 13 is the left servo, switch the pulse amounts if the pins are switched.)
hey Duane, I am running some old CR servos pulled form an old project (i think the life is or has been reduced already, but they both run at about the same RPM when measure with a fixed voltage source)
Our parallax ones where bummed from factory (both didn't spin - yes after calibrations and before, they are just defective, no big deal - so i grabbed the ones i could find without spending any money hehe)
I didn't know about running so much Voltage to it could damage them, due to the fact that we use a 9v battery attached to the BOE-BOT. suppose when we get out parallax kit ones back, ill use a lipoly pack or l-ion pack, if i want to run a lipoly pack whats the safest 3.3? obviously there's a 7.4 or 11.1, too much and i do not have a voltage regulator attached (could though i think i have a 78xx chip around). ill have to read up on some packs that are ok with the boebot, prehaps ill just go grab some rechargable AA's. suggestions would be awesome hehe.
as for my code yes it spins in a circle i think CCW (i think..) anyways if you can make one slow than the other or faster than the other you can make it a circle, well thats how i went over it in my head, just seemed easier to understand this way.
Thanks for the info and help! ill be cranking on the code this weekend in my spare time hopefully get it working perfectly!! hehe.
Rondo, Parallax is very good at replacing defective products. I haven't yet had to replace anything but I have seen numerous people on the Forums have issues and Parallax sent the replacements. Give them a call about your CR servos and see what they say.
Brian
Brian yes they are I haven't had any problems contacting Parallax. I should be receiving some CR servos by Monday or Tuesday. I think I might just stop by on Tuesday. Yes at Parallax hehe im about 25 mins away.
You are so lucky Rondo to live so close to Parallax! It would take me most of the day to drive there from here in Orange County. Others on here live in other states and so are in other countries. Everytime I order something from Parallax it takes about a week to arrive. Hopefully you will be a frequent visitor and customer.
Brian
no kidding! Yep i feel as i will be pretty frequent, i have never done any type of robotics, mainly electronics (discrete parts etc...just from school and some own little projects like audio amps, capacitor banks for airsoft guns etc). I do like it a ton and its requiring me to do a little more research and "playing" than i thought, and it is fun seeing how your code can make something so little do something like figure 8s or even navigate a maze, follow cats, or even program a little turret with the ping sensor hehe.
w00t have a little time tomorrow to wrench on some code see if i can get a figure 8!! ...or perhaps baby steps, circle haha.
ill definitely post up my boe-bot when its all completed - main goal right now is to navigate a maze with some obstacles and obstructions, and..stealth objects... cant wait!!
the parallax boards and site is filled with a ton of information and resources! im sure if i run into a snag there a few members here that have alittle knowledge to throw my way if needed, but im pretty stubborn and ill end up trial and error technique to find out what does and doesnt work hehe.
Thanks!
-Ronnie
Brian
Thanks for the awesome words of support. Definitely in with doing my own work....like I said I hate coding but gotta learn it and its super easy im just being a baby about it hehe. You know at first coffee or beer isnt the greatest...then...haha not the same but im sure you get the pic. ..or better its like math. Gotta use it.
Ronnie
I don't know what your background is but learn to document your code. It makes it easier for yourself and others to understand when you look at it later.
Brian
I have some good practices with programming and have been looking at code for a good while, and we are working in teams, coding with more than one person gets a little crazy, keeping notes helps a ton.
Well i have gotten my boe-bot now to navigate with some whiskers, gotta modify the head/contact pins a little to get it the way i want, code is looking pretty good and it can navigate through our little maze (not all the way through, but enough - hasnt completed the maze yet, but still have to put a few more sensors on the kit.
-ronnie