Yes, it's another segway clone

Thread Starter

bug13

Joined Feb 13, 2012
2,002
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: https://app.box.com/s/mi61vwolslck2i5i5hqy

youtube demo:

PID without a PHD:
http://fabacademy.org/archives/2014/students/shooshtari.ali/week16/images/PID-Without-a-PhD.pdf

The best balance filter/complementary filter explained (IMO):
https://b94be14129454da9cf7f056f5f8.../host/0B0ZbiLZrqVa6Y2d3UjFVWDhNZms/filter.pdf

SG filter
http://en.wikipedia.org/wiki/Savitzky–Golay_filter

getting help with PD turning:
http://forum.allaboutcircuits.com/threads/pid-turning-help-balance-robot.91537/#post-667426

Find center of gravity (wrong approach):
http://forum.allaboutcircuits.com/threads/algorism-to-find-the-centre-of-gravity.69802/#post-484693

battery power motor and PID stuff:
http://forum.allaboutcircuits.com/threads/motor-driver-for-batteries-power-device.91659/#post-668197

deal with DC motor noise:
http://forum.allaboutcircuits.com/t...motor-to-arduino-mcu.90733/page-2#post-667031

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:

ibanez130

Joined Aug 30, 2015
1
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 ?

i see MOTOR L,MOTOR L1,MOTOR L2
MOTOR R,MOTOR R1,MOTOR R2
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.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
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 ?

i see MOTOR L,MOTOR L1,MOTOR L2
MOTOR R,MOTOR R1,MOTOR R2
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.
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:
Forward()
{
MOTOR_L1 = HIGH;
MOTOR_L2 = LOW;
}

So you can possible replace my function with a single line like this:
MOTOR_DIR_L = HIGH;

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.
 

atferrari

Joined Jan 6, 2004
4,766
Hola Zhuhua

Impressive!

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?

Interested.
 

Thread Starter

bug13

Joined Feb 13, 2012
2,002
Hola Zhuhua

Impressive!

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?

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

ian field

Joined Oct 27, 2012
6,536
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.
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.
 
Top