Canada
Asked — Edited

2 Wheel Balancing Robot

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.


ARC Pro

Upgrade to ARC Pro

Stay at the forefront of robot programming innovation with ARC Pro, ensuring your robot is always equipped with the latest advancements.

PRO
Synthiam
#33  

Thanks! I really really enjoyed those videos!

#34  

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.

PRO
Synthiam
#35  

That will be neat to see an acrylic version of that bot! Looking forward to it

PRO
USA
#36  

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.

PRO
Synthiam
#37  

Yes and no.

If there are no encoders, the encoder pid is disabled.

#38  

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...

PRO
Synthiam
#39  

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:D

Heck, humans have made it pretty far balancing on two feet!

#40  

@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....