Hi everyone,
Ive been lurking for a while but this is my first post.
Ive built myself a nice balancing robot which almost works...
The problem I am having is with the fricking DC motors. I can't seem to get fine grain control over them.
The goal:
I want to use DC motors to control my balancing robot, and allow it to be pushed and still balance itself.
The details:
I am using an arduino uno
I am using an arduino motor shield to power them
I wrote the code from scratch, and the balancing part, and PID are working at acceptable levels.
I have a whole box full of different DC motors, speed controllers, servos, continuous rotation servos, etc. and have tested all of them.
Continuous rotation servos work fine, but the robot will not be able to be pushed and remain balanced (pushing could be done if you pushed hard enough but thats bad for servo gears)
The best luck I have had with DC motors is geared 6.2:1 ratio 5v (2A max) motors, but its not good enough, I cant get the motors to take movement commands quick enough, or even get consistant distances when I pulse the same voltage to them multiple times
void drive()
{
// If the PID returns negative move backwards, if the PID is positive move forwards
digitalWrite(dir_a, pidVal < 0 ? LOW : HIGH);
digitalWrite(dir_b, pidVal < 0 ? LOW : HIGH);
// If the PID returns anything between positive or negative 300 the robot is for the most part in perfect balancing state
if (pidVal > 300 || pidVal < -300) {
/**
* 255 is full speed
* 40-42 is the minimum speed I can get the motors to start from 0 speed
* 28 is the minimum it will slow down to even if it starts at high speeds and then lowers
*/
analogWrite(pwm_a, 200); //After I can get the motors to be controlled more precisely the PID will specify the delay (or so the theory goes)
analogWrite(pwm_b, 200);
delay(14);
analogWrite(pwm_a, 0);
analogWrite(pwm_b, 0);
}
}
I have been playing with different pwm voltages, as well as delays but I am really unhappy with the results. The motors movements are so jerky that they cause it to fall out of balance.
If I cannot precisely control how far the wheels spin when a pulse is applied (or at the very least prevent the motors from jerking so much), I do not see how I am going to get this bot to balance.
I am also worried that if I get a higher gear ratio that I wont be able to achieve the "pushing the robot" affect.
I know there are some robotics experts on here who know how to precisely control a balancing bot/segway bot.
It doesnt seem like segways/other balancing bots use stepper motors (and I would prefer not to, as again I am afraid of not being able to push it)
Update: I took an indepth look at the arduRoller
http://www.flickr.com/photos/fasaxc/5944650602/#secretb52128ea53 and it seems to be using a 24:1 gear ratio.
I am going try putting some mondo wheels (currently I have 2" wheels so the theory goes if I up them to 8" wheels I should have the equivilent of a 24:1 ratio pushing 2" wheels) (any thoughts on this tactic?
It also looks like the gear box I have could be easily altered to support 12:1 ratio (plus 4" wheels).
Do any experts know if this will work, and if so will I completely loose the ability to push the robot or will it be easier? I could also find out that this will draw more than 2A which will max out the arduino motor shield (although with a balancer robot, its just balancing, not ever moving at full speeds)