Trying to figure out the Segway...


Yesterday I went to my dad’s company picnic and got to play with a Segway. Ever since, I have been trying to figure out the algorithm behind it…hehe!

I think it’s a PID loop. As you lean, it adds the offset to a separate integral term that controls the speed. It seems simple, but for 5 grand, it seems that I’m missing something…or is it just overpriced?

What are your thoughts? I can’t get anyone around me to analyze how it works because they don’t care or know enough to figure it out.

Gosh that thing was fun…


I was exactly in your same mindset a couple years ago. So I tried to build one. After I was done, I would have gladly just paid 5 grand. If you try making one, you will quickly learn why it costs so much. It’s purpose may not be worth 5 grand but all the parts and development that’s in it certainly is.

I would imagine the speed limiting function further complicates the balancing algorithm.

When you’re approaching the maximum speed for the key you’re on, or when you’re otherwise approaching the maximum power the motors can put out (like when facing a strong headwind) the motors sort of put on a burst of acceleration to get the base of the Segway further forward in relation to the handlebars, so that if you wanted to accelerate any more you’d have to lean right over the handlebars (which would prompt a stick-shake warning).

So I’m going to leave speculation on how it works to people who are more qualified to answer.

Wow, I used to sound just like you. When I first started gliding I would think continuously how I was moving and how momentum was working amongst myself and the Seg. After almost two years, I tend to just hop on Slate, smile and glide. It leaves the mind for more joy and less thinking, that’s why I paid someone for the Seg instead of building it myself.

You may find the book Code Name Ginger very interesting, as it goes in-depth (without getting too technical) into the creation of the Segway, and many of the engineering and programming problems and issues that had to be solved to make Segways as safe and efficient as they are. I happened to come across it in a local bookstore a few years ago and I bought it on the spot without hesitation.

actually the balancing algorithm on a Segway is not much different that the cruise control on a car. Sensors detect the orientation of the platform and the rate at which it is starting to tip, and the motors respond to keep the Segway level

just like the cruise control on a car adjusts the throttle to hold the car at a constant speed - the Segway holds a constant level.

I dont have personal knowledge of the algorithm used, but you can make feedback systems tight or loose. If its tight it will quickly cancel out all error. On the Segway, that would mean as soon as you shifted your weight (lean forward) it would instantly compensate to stay level, moving very little.

I think the feedback on the Segway is selectively loose - when you lean forward it compensates to keep you from falling over, but not completely, so the platform ends up moving forward - sorta like its perpetually falling

It sounds like all of you have given up. Why would you do such a thing? :slight_smile:

I wonder if Dean Kamen knows how much this bugs other people? I imagine he would laugh if he knew how much this BUGS ME!!! :ahh:

Yes, I realize that there are many, many redundant systems in the Segway, but I still think it would be interesting to build my own. I’m definitely talking to the team about building one. What’s the worst that can happen…? :ahh:

You’ll be many hundreds if not thousands of dollars poorer with a pile of hardware that doesn’t do a darn thing. And you may have people injured requiring thousands of dollars in medical bills. You did say worst. :slight_smile:

Test it with monkeys. Works for the cosmetic industry, so why can’t it work for a robotics team? That would possibly solve the thousands of dollars in medical bills, they’ll turn into vet bills. Heh… funny me.

But yeah, building your own Segway could prove rather expensive and not worth it. That’s just my opinion though.

if you want to know how the segway works, get the patent and read it.

The patent must fully disclose the operation of the system, because that is what is being patented, not just what the system does, but how it does it.

For this reason it is necessary for the patent to fully explain how it works. Otherwise, whenever someone else came up with a similar idea, Segway could claim “thats how we do it, so we have a patent on that…”

your patent only covers your invention as you describe it. If someone else can come up with a different way to make a system that performs the same function, they are not violating your patent.

Good call, if I recall correctly from the book, that’s how Dean got the project to finally work. He had fallen in the shower and the idea hit him :ahh: of controlled falling.

It not just speed and direction, you’re forgetting balance. You’re not balancing the seg, it’s balancing you.

You’re also missing a lot of safety redundancy. There are (I think) eight gyros on board which are constantly polling and voting, similar to the way the systems work on the space shuttle where multiple redundant sensors provide data and then the results are voted on by the processors to weed out defective sensors or data.

And is it overpriced? I don’t think so. If gas gets a little more expensive, say $4/gal., I’ll be taking one to work, when I’m not mountain biking or roller-blading that is. :smiley:

Just need one more mile of trail and I can commute about 75% of the way on the Quinnipiac River Linear Trail, and I saw the survey party out last week working on final designs! :wink:

actually, i saw a guy (some professor at a college) on the internet who explained how he built his own. it came out to $300 (i think). I’ll try to find the link and post it in a bit.

these things don’t really need 8 gyros, except for redundancy and safety.

edit: i’m not sure it’s the same link, but here you go:

I agree, if you are building your own to learn about solid state gyros and PID loops, a single point system is fine

if you do this, make sure you wear a helmet when you ride it, and skateboard gloves so your hands dont hit the pavement when you fall.

When you fall! Single point system => single point failures => total loss of functionality!

the segway is designed to be foolproof, so that even the leaders of great nations can ride them with ease

your SeGwAy-X can be a little more… uhmmmm… interesting to ride, if you are not going to let your grandmother use it in the mall.

Off-topic, but how would one go about utlizing multiple gyros in a system? The obvious solution to me would be to average out the values (or, given enough data, something like figure skating with the highest and lowest values thrown out, THEN average), but IANAEE.

in redundant systems each gyro would be read and used as if it is the only gyro in the system. The signals from all gyros are compaired. If they dont agree, one of them is wrong

with a dual system you have no way of knowing which one is wrong, so you must shut the system down

with a triple or quad redundant system, the gyro that disagrees with the rest is flagged as defective, and taken off line. The system can keep functioning until you get down to two.

OK, I get it. That doesn’t keep me from trying it. I think I’m going to try it at a somewhat smaller scale. I will probably make a…box(?)…of some sort and play with that. I can probably get away with that. Just think if I used CIM motors on this thing and my code got away from me…rrrr…rrr…RRR…RRRRRRRRR BAM! :ahh:

And the best part is it would probably keep going. BAM BAM AAAAHHH! BAM

Yeah, you get my drift…

I am going to try something like this, and if I succeed, it is probably going to show up at every regional I go to, so beware!

The patent on the real thing is really interesting…well, sorta: