Asked
— Edited
I got a 4 - in - 1 sensor and have put together a 2 wheeled balancing robot. Now I need to figure out some coding. I have the Initialization script and it works good - getting lots of data. I'm not having any luck after that. Does anyone have some scripting they would be willing to share with me to help me get going? Here's what I've got so far.
ControlCommand("MPU9150", Init)
sleep(100)
:loop
#Added these because $AccelX and $AccelY were not recognized later in the script for some reason.
$XAccel = $AccelX
$YAccel = $AccelY
if ("x" =0)
print(1)
sleep(2000)
goto(loop)
endif
ControlCommand("MPU9150", RunOnce)
if($AccelX > 1000 and $AccelX < 1000)
servo(d4,108)
servo(d6,108)
endif
print("x: " + $XAccel)
print("y: " + $YAccel)
if($AccelX > 1000)
servo(d4,120)
servo(d6,61)
print(2)
elseif ($AccelX < 1000)
Servo(d4,61)
servo(D6,120)
print( 1)
endif
Sleep(100)
goto(loop)
I am working with a code that d. cochran posted awhile ago. It will change directions when it is tipped but will never stop. Also, after it has run for 30 seconds or so it will just keep running and the only way to stop the wheels is by disconnecting the power to the EZB.
Thanks! I really really enjoyed those videos!
I am going to be doing some acrylic laser cuts of the last one, if you interested in a set let me know and maybe we work out a deal.
That will be neat to see an acrylic version of that bot! Looking forward to it
cool!
The last one is very crafty (wood details).
@DJ, Does yours works without encoders ?
Most of them use encoders, i don't know if is a requirement to handle the balance or not.
Yes and no.
If there are no encoders, the encoder pid is disabled.
Just my opinion and I am sure a lot of effort has gone in to building and programming these (kudos), but after about 10 minutes the novelty for me is gone... I say save you battery and the need for extensive processing power and add a 3rd castor wheel.... KISS for reliability and efficiency. Practicality wise balancing bots are for show only...
They sure show well! Sure, practicality isn't the strong point of a balancing robot yet, but when we (ezrobot) gets a universal inverted pendulum module reliable... imagine the applications. We could slowly start getting increased reliability and stability out of balancing robots. Who knows, maybe one day they'll all balance on two wheels
Heck, humans have made it pretty far balancing on two feet!
@DJ.... Does the inverted pendulum off load some/all of the processing power in order to balance the bot? I am all for that if the ezb isn't bogged down just maintaining balance....