Yes, it's another segway clone

Discussion in 'The Projects Forum' started by bug13, Sep 1, 2014.

  1. bug13

    Thread Starter Well-Known Member

    Feb 13, 2012
    Yes, this is another segway clone. This project won't be a success without Andrew Rodger's help. (He helped me to do the platform and other mechanical stuff)

    I always want to build a Segway, early this year, I finally finished this project. It's not the greatest Segway clone, but it works.

    I thought I can share the code here, hoping it will be useful for someone who want to build his/her own.

    If you have any question, just ask.

    The brain is Arduion Uno, IMU is the low cost MPU6050.

    source code download link (too big to be upload to this site), IDE Visual Studio C++ and Visual Micro:
    code download:

    youtube demo:

    PID without a PHD:

    The best balance filter/complementary filter explained (IMO):

    SG filter–Golay_filter

    getting help with PD turning:

    Find center of gravity (wrong approach):

    battery power motor and PID stuff:

    deal with DC motor noise:

    some photos:
    IMG 2353
    by bug13 on All About Circuits

    IMG 2235
    by bug13 on All About Circuits

    IMG 2323
    by bug13 on All About Circuits

    IMG 2238
    by bug13 on All About Circuits

    IMG 2295
    by bug13 on All About Circuits
    Last edited: Sep 3, 2014
    RichardO, DerStrom8, nsaspook and 3 others like this.
  2. MrChips


    Oct 2, 2009
    Cool! Congratulations,well done!
    bug13 likes this.
  3. ibanez130

    New Member

    Aug 30, 2015
    hi, very nice looking your project. i made a diy segway and same motor driver but i want to use your code but there is no any schema about your project.can you share with me? i have some questions ?

    where is to connect??? there is 6 pins on motor driver (+5, PW1, DIR1, PW2,DIR2, DND)

    where is connect the mpu6050 pins?

    if you answer to me i will be happy.
  4. GopherT

    AAC Fanatic!

    Nov 23, 2012
    Be careful with those things or you will be infamous in hurry.

    Imagine if he ended his carrier instead of having him bounce back up?

    cmartinez and Sinus23 like this.
  5. nsaspook

    AAC Fanatic!

    Aug 27, 2009
    That's got to leave a mark. Ouch!
    GopherT likes this.
  6. bug13

    Thread Starter Well-Known Member

    Feb 13, 2012
    The driver I use can drive the different half of the h-bridge independently. From my code, you can see I have some function like these:
    MOTOR_L1 = HIGH;
    MOTOR_L2 = LOW;

    So you can possible replace my function with a single line like this:

    For mpu6050 connection, just google it, I think I just use an standard connection. Connect to I2C pins of the arduino.

    You may need to tune the pid settings to suit your project.

    And make sure there is no sharp conner at your Segway clone before you test your Segway clone, THIS IS VERY IMPORTANT for safety reason.

    PS: I think you need a 5v-3.3v logic level converter to connect your mpu5060 too.
  7. atferrari

    AAC Fanatic!

    Jan 6, 2004
    Hola Zhuhua


    My questions:

    Are you planing to post somewhere a detailed description?

    What center of gravity are you considering? The whole thing (mobile and driver)? If so, you calculate it on the fly once for each new driver or continuously?

    In the video, your mobile seems prone to move backwards? Desired or to be corrected?

    The mobile, how is it supposed to react if put upright and pushed forward with no driver on board?

  8. bug13

    Thread Starter Well-Known Member

    Feb 13, 2012
    I would have posted the detailed description if I have good documentation. This is sort of a fun project that design as I built, and I don't have much documentation expect a few photos. But you are free to ask any questions, I am happy to answer them. (I have asked questions on some of the key elements of this project in this forum too, links above).

    I don't really pay too much attention to the center of gravity of my clone, and you properly don't need to. The goal is to drive the motor (the wooden platform) to the direction that the segway falls. With the right power/torque, so the platform catch driver and the platform before it falls, and sort of push the driver and platform back a little too.

    Once is turned, it can work on different drivers. (different weight, tall etc..) I tested it with a few friends, some work better some work ok. I don't need to turn it for different users. But I think there is a limit somewhere, same as everything else in physic.

    Moving backward is part of my demo, I want to show it can move forward, backward. And it can stay still too, but I properly didn't make it obvious in the video.

    Because the center of gravity is at the front of the mobile, it will move forward by itself if no driver. And eventually the motor can't catch up with the fall, it will fall down. My codes will stop the power to the motor if it tiles more than 15 degree, or something like that.

    PS: I found one of my early prototype video.
    Last edited: Aug 31, 2015
  9. ian field

    Distinguished Member

    Oct 27, 2012
    Elektor magazine did a project to build one over several issues a few years back.

    AFAIK: a kit of parts was produced at the time.

    IIRC: the project was named: Elektor Wheelie.