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

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

#25  

@proteusy - on YouTube search for husarion robot . You should find a few videos on their stuff.

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

PRO
Synthiam
#26  

There are a number of awesome self balancing robots out there - and they're pretty neat to see. Balancing robots are quite simple and that's not an issue with EZ-Robot's inverted pendulum, as you can see from this inverted pendulum test from last year...

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:D We've been interviewing some math professionals to grow/fix/enhance the algorithm i've been working on.

#27  

Thanks for the update DJ, the robot in your video is what I was wanting to create, but as I've said before, I had not idea of the complexity of it. Good luck with your Inverted Pendulum.

#28  

I don't get the appeal of two wheeled robots and having to use all this self balancing effort to make them work. It's a neat technical challenge, but of what practical use is it? It must be a power hog, what with having to make constant corrections to maintain balance. Just add one or two wheels or casters and away you go. It could still have the same turn radius and all. I saw the Segway as the same sort of thing. More of a gimmick than a practical solution to anything. So, what exactly is the advantage of a two wheeled self balancing robot?

PRO
Synthiam
#29  

Ezeobots interest in any robot technology is to provide a platform for learning. What you do with it is your own reasons:)

I think the balancing action is neat and ppl r curious about it... that's probably the only interesting part lol

#30  

Quote:

So, what exactly is the advantage of a two wheeled self balancing robot?

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

#31  

For me, it's like a good challenge and the kids are interested in it also. I have some friends at CMU (PA) and I had the chance to pick their brains. R. Hollis and G. Kantor (and some others) are very talented and they put me to shame.

@DJ, just don't tap it, push it. Are you using a cascading PDI?

#32  

@DJ here some of my samples, please let me know once you view them. All three use different software and hardware. I have one of Ralph also, but ran out of time.

Yours looks like it may be using SainSmart stuff? Could be wrong.