DIY Segway

embedded by Embedded Video

YouTube Direkt

embedded by Embedded Video

YouTube Direkt

Why build a DIY Segway?


at_skansen
The main reason that I wanted to build a DIY Segway was simply because I wanted to see if it was possible. I also liked the idea of building something that strongly interacts with humans. I will now describe how I built it.

 

 


Hardware

el-scooter_small.pngThe motors, wheels, chain, gears and batteries came from electric scooters like the one to the right. You need hardware from two since the electric scooters only have one motor and gear setup. The motors are some cheap china unbranded ones. They are rated as 300W 24Volt, 2750 rpm

 

The gearing is made in one step from the small gear on the motor to the bigger gear head on the wheel. The ratio is approx 6:1, a higher ratio would be preferred to get a better torque and a lower top speed. Now the motors have to work pretty hard and currents above 30A(in total from both motors) have been registered since the fuse burned.

img_3100_small.jpgThe fasting of the gear on the 12” wheel was based on a freewheel mechanism therefore I had to open up the freewheel and remove all the grease and then use epoxy to make it possible to drive it in both directions. In the picture below you can see the freewheel after it has been filled with epoxy as well as a tool made to be able to open it up.

There is one fixed axle on which both wheels rotate, this axle is attached with three aluminum blocks which fixates the axle with 5mm set screws.

img_3116_small.jpg img_3119_small.jpg img_3126_small.jpg

Steering, to be able to turn left and right by just tilting the handlebar a rigid joint was needed, the design was made in SolidWorks and then produced in a CNC mill. The transfer from the CAD drawing to the machine instructions (g-code) was made with CAMBAM. The same method was used to produce the box for the electronics and the assembly for the emergency brake.

joint_small.png infastning_styrstang2_small.jpg

The handlebar is a normal bicycle handlebar, the pipe on which it is connected is a 25mm hollow steel pipe. To keep the pipe centered and to give some force feedback two springs are attached with steel wires. On the handlebar there is also an emergency button which is connected to a standard car relay which directly cuts the power to the motors. Two 12V 12Ah lead batteries are used in series since the motors run at 24V


Electronics

segway-electronics_small.png

All PCBs are custom made, the main board (top left in image above) takes care of the computation, gathers data from sensor such as gyro(ADXRS614), accelerometer(ADXL203) and a trim potentiometer which is modified and positioned in the steering joint to detect in which direction you want to turn. The main processor is an AVR AtMega168. The communication to my laptop is made over Bluetooth using a RN-41 from Roving Networks (the same is used in Sparkfuns BlueSMiRF Gold).
The two H-bridges (right-hand side in the image) which convert the control signals from the main board to the power to the motors are designed by friend named Benjamin Vedder. Each H-bridge also have an AtMega168, the communication between the boards is done via UART, originally I2C was used but due to the high currents produced by the motors too much noise was generated and was influencing the I2C communication. All the electronics run on a separate battery (a LiPo 7.4v 900mAh).

electronic_box_small.png

To have easy access for charging the batteries, programming the main board and changing parameters to the control loop a small box with several connectors, a switch to turn on and off the power to the electronics and trim potentiometer is positioned on the top side.


Software

p1r-robotcontroller_small.jpgThe software in the microcontroller mainly consists of a filter for the gyro and accelerometer and a PD control loop. The idea from the beginning was to have the DIY Segway as a platform for testing different types of control methods. However since the power of the motors and the mass of the system was quite big it turned out that it is not such a great test platform (at least if you don’t like getting lots of bruises and destroying the interior of the place you are testing it at).

A better option would be to have a smaller balancing setup which fits on a table and with a mass of less than 1kg for this purpose.
Regarding the filtering of the gyro and accelerometer I tested both a Kalman filter and a Complemenatry filter. It turned out that the performance was very similar of the two filters but the Complementary filter required less computation and is therefore currently used.
On the computer I made an application written in Java where I can see all the sensor values and control signals, battery status etc. It’s a great way of debugging the system.


Cost

I didn’t keep a strict log over my purchases so this is mainly an estimate, however I have tried to overestimated all costs to not give a too optimistic result. The biggest cost was the motors wheels and batteries. I managed to reduce this cost pretty well by buying a second hand scooter which was malfunctioning due to an electrical error, the parts I scavenged from it makes up one setup of wheel motor and gears. Since I needed parts from two scooters I also bought a separate setup as spare parts so these were completely new. Regarding the electronics I bought several items via eBay which can give great prices.

Hardware (200€)
2 motors, 2 wheels and 2 lead batteries 150€
Steel pipe 5€
Aluminum blocks 10€
Aluminum base plate 10€
12mm Steel axle 5€
Handlebar 7€
Emergency brake 3€
2 Springs 8€
Electronics (100€)
3 x AtMega168
ADXRS614
ADXL203
8 Mosfets
Gate drivers
Capacitors & resistors
Double layer PCB
Voltage regulator
LED
LiPo battery
Total 300€

103 thoughts on “DIY Segway

  1. Hi Peter, sorry my english, I know that you against patent rights in violation if you sell a Segway, but as a kit where only the wheels must be mounted, it would be possible. If you sell it to me as a construction set, I would also be willing to pay significantly more.

    mfg

  2. Hello Peter.
    Great job! My name is Anatoliy and I from Ukraine. Can you share electronics and code? Without electronics and code, I can’t do my segway
    Please Share your Electronics and Code.
    toliy1@yandex.ru
    Thank you

  3. great job sir yours is best and simplest model i have seen on internet. I wanna try the same using hub motors 250 watt is this feasible for this application and do you think its a good idea.

  4. Hi Peter. I am also interrested to buy all the spares if possible and assembling the unit myself. I was scammed by a Chinese company HK-Products and lost over a $1000 also in effort to build a Segway. Thanks Peter.

  5. Hi

    If I want to get all the materials and control code from you, How much shall i pay for it?
    Can I assemble it myself? will you want to ship it to Taiwan?

  6. Hello Peter !
    I am also interested in building Segway , but I got some troubles with code. Is there any possibility to get a code from you ?
    I would be so grateful .
    Thanks ! Janko :) (jankokobal3@gmail.com)

  7. Hallo Petter,
    kann ich so ein Segway bei dir kaufen?
    Schön wäre es mit einem Sitz drauf, da ich eine Gehbehinderung habe (defektes Knie). Für Für zu Hause habe ich einen Apachen ( http://www.myfrankie.de/ ) und bin da top zufrieden mit. Für Flugreisen benötige ich allerdings noch ein leichteres Gerät, vor allem mit Bleigel Akkus, sonst gibt es Probleme mit dem Transport mit dem Flugzeug.
    Über eine Antwort von Dir würde ich mich sehr freuen.

  8. Suggestion!

    If you could integrate two pressure plates on or in the “floor” you could maybe us e theese to calculate the drivers weight distribution. En then use theese values to turn. Then you could maybe remove the steering bar altogehter. Just two wheels and a flatt surface to stand on, would look quite cool!

  9. hi peter,

    first congratulations for your work,

    I want know more about the gyroscope and tilt sensor function. Why you use this sensors. please explain me clearly.

    regard , Iman

  10. Hi Peter,
    your diy segway is SUPER, Im fond of Segway and planning to make a segway, can you help me by giving diagrams and codes you have, that would help me a lot,, thanks a lot man.
    best regards,
    Taras

  11. Hello Peter, can you share electronics and code?
    Without electronics and code, we can’t finish own scooter
    All the work without the electronic control it’s nothing
    Please Share your Electronics and Code
    rsmastech@gmail.com

  12. Hi Peter,
    A job well done! i like your simple and clean set-up, i hope you have a diagram for an easy and quick-to-follow wiring installation….. and the codes for arduino…
    Hope you make a single wheel too….. if you have a diagram set-up pls email me… vinnfernandez@yahoo.com… thanks!

  13. Hi Peter,
    your diy segway is SUPER, Im fond of Segway and planning to make a segway, can you help me by giving diagrams and codes you have, that would help me a lot,, thanks a lot man.
    best regards,
    Taras

  14. Hi, I love your seg way !
    I am not so able than you to built it… but I pro mess to my soon to have one.
    Is it possible to by one in kit?
    It will be too funny
    my mail : jjrobin@me.com
    tell want price for a kit

    regards

    jean jacques

  15. Hi.

    I came Form germany and i am trying to rebuild your human transporter …. I habe bought an arduino Bord the gyros and accel.. But i am not gold at programming … Is it possible that you send me your code so that i can look at it while i Programm it ??? That would be very nice if you could send it.

    Thanks and happy building :-)

  16. hai bro,
    i am a 2 year mechanical engineering student from india i am really amazed on seeing ur project i wish i could try ur project…can u pls guide me in doing it.? can u pls send me circuit diagram and details of the circuit board.. ? my mail id is chrislin94@gmail.com…. waiting for ur response
    thank you
    christy

  17. Hey datz an awesome creation . . i m planning to make a segway as my final yr mechanical engineering project since it involves all aspects mechanics , electronics and coding . . can u please helpme with the components and the coding language . . it wud of gr8 help . .

  18. its a awesome project!!!
    thanks for all information u posted about your segway…
    i’m gonna to make it one….:D

  19. GOOD JOB Peter,, your diy segway is really amazing,, Im an Electronics Engineering looking for my final year thesis.. I’m planning to make a segway,, can you help me by giving diagrams and codes you have,, that would help me a lot,, thanks a lot man.. ur amazing,,
    best regards,,

  20. Hi Petter,
    you have done a great job man,i m from kuwait, i like it very much. that makes me to start to make one too. but i have got no any idea how to find the balancing device ( H-bridges) mother board and soft wear, could you please guide me how to get them?

    best regards
    Salem

  21. Hi Petter,
    you have done a great job man, i like it very much. that makes me to start to make one too. but i have got no any idea how to find the balancing device ( H-bridges) mother board and soft wear, could you please guide me how to get them? or are you able to supply them to me? if you can supply, could you please tell me the cost.

    best regards
    salem

  22. Hi Peter I plan on building my own segway for my senior year college physics project. I know you wrote the application in java but what were the robotics programed in? I’m thinking C++ would be best and would like to know if that’s what you used? I’m currently planning on teaching myself C++ for this project. If you did program in Java or C could you please send my a sample of your code? I figure the programming and debugging will be the hardest part of the project. Thank you for your time and great work on the segway!

  23. Hej Petter!

    Jag är en kille på 12 år som är mycket intresserad av teknik, speciellt robotar och datorer, men även lite programmering.
    Jag såg din coola video på Segwayen du har byggt och blev jätte imponerad.
    Jag skulle gärna själv vilja bygga en Segway och har sparat ihop pengar till det,
    men är lite osäker på vilka delar jag ska använda.
    Så det hade varit jätte vänligt ifall du skulle vilja hjälpa mig med alla detaljer tex maila en lista över alla artikelnamn till delarna som du använde till din Segway, till min mail: jacoblundell@hotmail.se .
    Det hade också varit jätte bra ifall du kunde maila programmeringskoden till Segwayen, för jag är mest insatt i programmering i HTML och CSS.

    Med vänliga hälsningar
    Blivande ingenjören Jacob :)

  24. Hi Peter, really good work!

    I’m about to start to build a similar project. I just wonder if motor power is enough: which speed do you reach? And is it enough to climb slopes (for example 10°? 20°?)

    thanks a lot.

    Garo

  25. hi peter

    i am a masters student and even i am working on diy segway….the mechanical designing is done. And i have already designed the motor drivers too. Right now i am working on the balancing part.

    i am using atmega32 microcontroller. I wont be using gyro and accelerometer , but i will be using some other tilt sensors to control the speed as well as providing balance to the bike. Do you think its a good idea?? And can you plz send me some logic or atleast dummy codes for the processing of the inputs from these sensors.

    thanks and
    regards

  26. I would to build one. Petter could you send me an electronic project circuit diagrams and firmware? the new address THX Robbi

  27. Hello,

    excellent work, I’m impressed.

    Is it possible to get some more detailed information about the electronics?

    Thank you

    Mitja B.

  28. Nice Vehicle but this whole Page is of no use for others who does’nt have enough knowlege to build this on their own since you are not willing to give details. On the other hand those with enough knowlege how to build it can do this on their own, but those don’t need this page also.
    So its of no use for nobody except for your self-praise which makes People getting mad at you.

    • come on, don’t complain simply because it didn’t help you, I only have basic knowledge and this page is awesome. It helped a lot.

  29. Hi Petter, i was wondering if you could send me the code for your Segway. I was also wondering if you could be so kind to enlighten me on what kind of potentiometer you are using to determine right or left when turning? Much appreciated.

  30. Jag är en UK ex-pat, pensionerad mekanisk ingenjör – jag arbete som volontär och guide att Aeroseum; http://www.aeroseum.se. Anläggning är 22 000 m2 stort och många av oss är äldre. Din DIY Segway kunde spara mycket gångtid och trötta ben! Har du lust att hälsa på en tisdag 07oo-21oo (volontär kväll från 18oo) eller fredag 07oo-1500? Fråga efter Martin i entré kiosk, jag kommer hämta dig för en rundvandring. F.d. Chalmarister med elektronik som bakgrund samt pensionerad kretskort designer finns – mekanik ta jag och en annan kollega hand om… Mvh, Martin Bronsdon mob. 0706-788425 hem 031-198889 (Svangatan 9D, 416 69 Gbg)

    • Hej Martin, det låter jätte häftigt, dessvärre så har jag flyttat och bor numer i Sthlm. Men om jag är i Göteborg nån gång så ska jag förska titta förbit. Mvh

  31. Peter
    I have just discovered your self-made Segway Mobile Scooter. I am not only impressed, but very jealous. While my capabilities are not up to the ingenuity you possess, I am of the mindset ‘why cannot I do the very same thing’? In truth I cannot, however I do admire your skil.
    I am disabled and have limited mobility and have long asked why I am not able to use a device such as you have designed. To be able to use this in a home setting is my thought here, as opposed to a Rollater. A ‘rolling walker’.The traditional large scale marketed Segway has been shown to be first of all priced above what the average low income individual can reasonably afford, and second is not, what I have seen as easily manuevable as your prototype. My thought here is – your device is perfect for the mobility limited individual like myself. I do believe you have a definite market. I know I would love to be able to secure (purchase) one. Possible? I definately would love to be able to use a device such as your magnificent ‘Segway’…
    Than you for listening…
    Sincerely
    David Norris
    Sacramento, California
    norris299@sbcglobal.net

    • Hello David.
      Thank you for your kind words. Regarding your idea,
      it is very interesting but there are some disadvantages that you need to consider for example when not moving around the Segway is still using power just to balance itself. Therefore it is not very energy efficient compared to a three or four wheeled alternative. Another thing to consider is thresholds and similar obstacles, the Segway is not so good at climbing thresholds. You kind of need to gain some speed to “bump” over it which might be a bit hazardous in indoor environments.
      Best Regards

  32. Nice job I think your segway is perfect for my friend that is handycaped and I am going to try and make one that the handle bars will be replaced with a bluetooth head gear he can only use his body from the neck up
    Do you think the head gear would work like the handelbars do
    would love to here your thoughts on the modifications thanks for your time and giving me the idea for my friend and maybe the Disabled
    Kevin

  33. bro its a awesome works. i would like 2 applied bt it seems the electronic circuit is new for me id u explaining more about the the electronic part of this segwat

  34. Hi Petter,
    Wondering if you would be willing to supply your code as a reference for others? I have a completed segway running on an Arduino using the kalman filter, though it’s not perfect. Thinking of switching over to a less complicated complementary filter. Which do you use?
    Your DIY segway is the best I’ve seen by far.

    Thank you,
    Shane

  35. Hello Peter! Your ballancibg sckoter is great. I would like to make a segway to my grandson. Can you please be so kind and disclosure the schematics and software of motor control? Thanks

  36. Hello, If one day you decide to produce it at a good price, I could be interested in dealing it in France. Then, do not hesitate to contacted me.

    Oliver 00 33 (0)7 60 74 90 90

  37. Hej Petter! Jag heter Benjamin Dzebo och jag går tredje året på fordons programmet och jag skulle vilja att du emailar mig på Benjamin_dzebo@hotmail.com med kontakt information då jag är sugen på att göra detta som projekt arbete:) Tack så mycket i förväg, mvh Benjamin.

  38. Здравствуй Петтер!
    А кто разрабатывал данную схему?
    интересно посмотреть её!

  39. Hi Petter,

    Good job. I am interested to built one segway. Can I get from you the eletricronic scheme and also the software from ATMega168 ?

    Thanks! Costel

  40. Hello Peter !
    I am also interested in building Segway , but I got some troubles with electronics . Is there any possibility to get a electronic PDF projector from you ?
    I would be so grateful .
    Thanks ! Kate :) ( kejt3@buziaczek.pl)

  41. Hello, Petter. Your email is XXX, doesn’t it? I would like to discuss desingning of your segway. This is a very very interestingly!

  42. Petter, i want to ask you about your project.
    I’m very interest with your DIY segway.
    And now I want to make DIY segway.
    I want to ask about the gyro and accelero. Should we use gyro and accelero ?Or we can use one( accelero or gyro) ?
    And how to program the accelero or gyro so that the DIY segway can control the velocity of the motor ?
    Thank you Petter.. :)

  43. found your website searching the web. I bought two electric scooter from an estate sale–neither worked for lack of parts or missing stuff. I tried to build a working scooter using the two but gave up when I fried the controller board.

    I can work with metals, some electronics but not programming. Us types who lack programming skills or PCboard building really need a source for completed boards or a good kit. and of course the program. are you or anyone else working to provide such?

    thanks again, great article; Gene

  44. Hi Petter,

    Just wondering if you would be so kind as to post your code for us unworthy mortals:)
    I have tried the code that is supplied further up in the comments pages but it does not debug. I think it was done with an earlier version of the Arduino code.
    You have gone to so much trouble to make a beautiful machine and website, all that is missing is unfortunately YOUR code.
    Thanks very much.
    Mart

    • I’m working on it, my plan is to produce new code that runs on Arduino hardware. I will make it available on Github. But still a few months before I can post it, have to many other projects consuming my time. Regards

  45. Hej,

    Jag går nu sista året på gymnasiet och är verkligen intreserad av ditt projekt.
    Funderar själv på att bygga en segway (fast med ett hjul). Är detta möjligt tror du?
    Hur långt tid kommer det ta och vad tror du kostnaderna för ett sådant projektarbete skulle kosta?

    Tack på förhand
    Mvh Marcus

    • Det är möjligt men det är svårare än med två hjul. Om du själv tänker sitta på den så får du själv ta hand om balansen i sidled medan motorn tar hand om balansen i frambak led. Om du ej sitter på den måste du låta ett svänghjul ta hand balansen i sidled.

  46. Hello. Good project. I also Would like to collect on the Atmega, a stepper motor as the driving force. It will be a miniature model. Can you lay out chip cards. And a program for Atmega. I would really be grateful. Yet in Russia to not sell such devices.

  47. Hi.is it possible for you to send me the h-bridge circuit.I´m bildding a custom made segway but i´m having problems with mosfet driving circuit.The motor that i have are 24v 250w from electric scooter like yours.I´ve also tried diferent PWM .What the frequency that you have used.

  48. Hi Petter,
    you have done a great job man, i like it very much. that makes me to start to make one too. but i have got no any idea how to find the balancing device ( H-bridges) mother board and soft wear, could you please guide me how to get them? or are you able to supply them to me? if you can supply, could you please tell me the cost.

    best regards
    Ray

  49. Hi all! I´ve also started building one. Regarding motors and stuff: I bought mine at http://www.sunds-sportartikel.de/ Cheaper than the swedish firms I´ve found, and very good delivery (20 euro regardless of weight, I bought batteries as well, and about 4 days).

    My problem now is the H-bridges, does anyone have an idea of instructions for building these? I will use an Arduino Mega card and 36V/500W/18A motors.

  50. Hello Peter,

    I want olso make a segway, but I don’t no where I can find the motors.
    Can you sent me the page of china where you buy this.

    thnks

    • I bought the motors and wheels from a Swedish online shop selling scooters like the one I mention in the beginning of this article. Ebay is a good place to find cheap electric motors. This type of motor can be found in different electric vehicles.

  51. Petter,
    Excellent work! Very good information on the design also.
    I am planning to make one just to try. Do you think I can use Arduino UNO or Arduino MEGA as controller instead of creating board with AtMega168?
    I am not good Hardware or software engineer, just trying it out as hobby.
    Thanks for sharing.
    -N

      • Hi Petter,
        Congratulation for the great work! Really amazing.
        I’m tryng to do similar project using Arduino and relevant motor shield.
        I did the 80% of the job, now I’m fighting with the tuning of parameters and I’m going crazy.
        If you want I could share with you the arduino code.
        Regards,
        Manuel

Leave a Reply

Your email address will not be published. Required fields are marked *

*


1 + = four

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>