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.Code:
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.
Asked
— Edited
Maybe a difference in the mobile web interface vs full interface. I was searching from my phone, and had no luck.
Interesting looking device now that I found it. A bit pricey for what it does, but this is not a cheap hobby....
Alan
@thetechguru - not a cheap hobby at all, but it was cheaper that my main hobby of drag racing Mustangs. There are a few pretty decent self balancing robots out there.
However, the challenge ez-robot is taking on isn't a simple balancing robot. EZ-Robot's inverted pendulum is taking the challenge to make anything inverted balancing. Meaning a selection of motors, wheel sizes, hbridges (for differing motor sizes), voltage, and robot sizes.
The reason that above video is working with the inverted pendulum prototype is that the pid and algorithm is tuned for the voltage, hbridge, motors, wheel size, and weight.
The idea of the inverted pendulum is to provide easy options to the user to very simply fine tune an inverted pendulum balancing robot that was built within the range of hardware specifications.
The reason i'm looking at other balancing robots is because everyone does the pid and other work within the main loop a little different - and i'd like to learn what others are doing to assist with our goal. Sadly, all of the open source code that i have seen is either very inefficient or only works due to pure fluke because sometimes the PID's don't even make sense. Those with professional knowledge of programming can view the code and see unused variable declarations, re-assigning variables with nullifying previous calculations, and a pile more.
But - that doesn't mean EZ-Robot giving up on the inverted pendulum
I think the balancing action is neat and ppl r curious about it... that's probably the only interesting part lol
For me it is because it looks cool, which improves the WAF (Wife Acceptance Factor). My wife has been much more supportive of my robot supplies purchases and the time I spend on them since I got a Six. Six is the most useless of my robots, but looks and moves the coolest, so she understands why I want to build them. If I could build a balance bot, it would amaze her, and I would have another year of high WAF.
Alan
@DJ, just don't tap it, push it. Are you using a cascading PDI?
Yours looks like it may be using SainSmart stuff? Could be wrong.
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.
If there are no encoders, the encoder pid is disabled.
Heck, humans have made it pretty far balancing on two feet!