Easy build self balancing electric skateboard

 by XenonJohn
Featured
Econoseg2.jpg

What is it?
Twin wheeled skateboard that works like a Segway.  Electric skateboards exist already - motors on rear wheels. The plan here was to build something like a Segway but in the form of a skateboard. It knows which way is "up" via a combination of gyroscope and an accelerometer sensors, using a complementary (not complimentary) filter which reads and combines data from both 100 times per second. Steering by a simple rocker switch in hand controller (or a rewired Wii-Nunchuck as in photo if you are more ambitious).

What's new on this Instructable?
- Working on code to use the new Sparkfun 6dof DIGITAL IMU. FIRST VERSION ATTACHED 8th March 2012 TO PAGE 53. Only tested as sensor/arduino but prints out believable angles etc, have posted it for those who want to experiment with it.

VERY IMPORTANT NEWS 27/4/13:
Thomas Feminella has almost managed to get a Unicycle working with Sparkfun DIGITAL 6DOF IMU, Arduino and SyRen motor controller. YouTube vid here: 
http://www.youtube.com/watch?v=mEee1iI6emE&sns=em
Examples of his code are here on an Arduino forum: http://arduino.cc/forum/index.php?topic=153496.0

NOTE: Since this instructable was made, analog IMU's which just output a voltage from each accelerometer and gyro axis have stopped being made as hobby boards by Sparkfun. This is a pity as all you had to do was read the voltages on the analog input pins of your arduino.

IMPORTANT NOTE May 15th 2013: You CAN, AGAIN, buy an analog IMU here on ebay: 
http://www.ebay.com/itm/181004141876?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649

Polulu also still sell accelerometers and gyros with analog outputs. They may work if set to their most sensitive ranges if anyone wants to try them:
http://www.pololu.com/catalog/product/1252
http://www.pololu.com/catalog/product/1270

May 2013: I am building a new skateboard. Photos here:
https://sites.google.com/site/onewheeledselfbalancing/Home/18-2013superskate

How does it stay level?
It controls the wheel motors so the wheels always stay under your centre of balance, like balancing a broomstick on your fingertip. This in engineering terms is called a "PID" control system and is used for all sorts of things. For example think of the 300+ feet high Apollo rockets used in the moon landings..........
Q: How come they didn't just fall over when they took off? They took off incredibly slowly for the first few seconds, tailfins would have no effect, far slower than Shuttle launches.                Watch this video
It takes a full 10 seconds just to get to 100m and clear the launch tower:
http://www.youtube.com/watch?v=_PEGi3k6yNQ
A: They had engines mounted on gimbals (swivelling joints) hydraulically controlled by a PID control system (lots of analog electronics I think involved too). 

Background:
In 2008 I saw a YouTube video by Ben Smithers of his one-wheeled self balancing skateboard whizzing around a car park in Norwich UK. http://www.robosys.co.uk/       Video: http://www.youtube.com/watch?v=HGbbag9dklU
It turns out he was a Lotus cars controls system engineer - which makes sense.
Also see Trevor Blackwell's site: http://www.tlb.org/eunicycle.html
Meanwhile I wanted to teach myself microcontroller programming and, totally underestimating the task, thought this would be a great fun way to do this. I built several machines some with one wheel and some with two. Advantage of two wheelers is that they turn more easily and can turn and balance even when stationary - which is fun.

Why an Instructable?
Having learned lessons the hard way I thought it would be worth redesigning the project around an Arduino microcontroller, then seeing how low-cost and easy-build I could possibly make it. Clearly something like this is not for the complete Arduino beginner, nor is it that "easy" however this is about as easy as a self-balancing machine is realistically ever going to get.

Skills:
Projects like this lend themselves to being built as a team. Some examples below were built as college projects. There are
i) some electronics (not making circuit boards, just wiring and soldering) to master,
ii) some mechanical fabrication; this version is designed to require no welding, just nuts bolts and some woodwork. Wheel/sprockets/axles/bearings come as a unit (electric scooter rear wheel assemblies).
iii) some programming; the programs (Arduino sketches) you need, including those to help debugging, are attached (P43 - 47).
There are; IMU tester, motor tester, balances-nothing-else, rocker switch steered and potentiometer steered code examples.

How much does it cost?
I realised when costing them up that the cost of a self balancing robot would only be a little lower than that of a ride on machine, therefore I went for a ride-on machine! Robot motor/gearbox combinations are pretty expensive.
For me the cost was about $300 equivalent PLUS whatever batteries you choose to use. I recommend starting with lead-acid batteries then make improvements later once you have a working machine. Lithium batteries etc are expensive!

Why do it?
i) For the challenge of doing something original. Most things have been invented, indeed self-balancing machines have been invented. Segway skateboards have been invented in principle BUT there is huge room for improvement.
ii) Making something that is practical and intuitive to ride is quite a challenge in terms of both electronics/software and fabrication/packaging. Cannot all be done on a computer. Eventually you have to actually build something then incrementally improve it. Despite the myth of "Eureka" moments, the truth is that this is how most innovations come about, by slow incremental development and hard work. Edison did not invent the lightbulb. He developed the first practical lightbulb.
iii) To educate yourself. You will learn a huge amount.
iv) These things are really good fun to ride! I have taken this to 2 UK Maker Faires now and both times people are wanting to have a go. Last time the BBC cameramen who also had an exhibit politely waited until the end of show, then they too asked to try it out.

This instructable:
There are a large number of pages in this. This is deliberate, if you are serious about building one then you need every single step documented with no gaps.

Additional information:
I have documented all my machines both good and bad on another website here:
http://sites.google.com/site/onewheeledselfbalancing/
I have a page of links to dozens of other self-balancing projects from around the world here:
http://sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects

Can I do this as a beginnner?
The fabrication has been deliberately kept really simple.
The soldering between sensors and arduino board needs to be good quality!
If you are new to Arduino I would recommend buying an Arduino starter kit. These come with some ancillary sensors etc and a set of about 12 tutorials. Work through them all (about 2 days work) and read a beginners book to Arduino. You will then be ready.

Can I build a SegwayTM clone?
Yes. Australian SciTech group have built a very low cost machine using a version of the Arduino code from this Instructable:
http://www.instructables.com/id/Self-Balancing-Scooter-Ver-20/
Here also is the Thatch No-Way Segway using my code almost unaltered: http://www.youtube.com/watch?v=R4ax3N0UW38

Has anyone else built one of these?
Ages currently range from 12yrs to 81yrs.
This Instructable is over a year old now, so yes indeed, people have. Here are a few I know of:
1)   Skateboard:    http://www.youtube.com/watch?v=kSW7YXLCjqk
2)   Skateboard:    http://www.youtube.com/watch?v=u-uUidBZEnM
3)   The Velociryder:  http://www.youtube.com/watch?v=xvfUIxusPZw&feature=player_embedded
4)   Great board video - Buffalo State College senior project: http://www.youtube.com/watch?v=FEaTxahyQxc
5)   Another board based on this Instructable:  http://www.youtube.com/watch?v=vhbH_AmIKZA&feature=related
6)   A board based on old FIRST robotics parts + code from this instructable (FIRST robotics was started by Dean Kamen who also invented the Segway, to encourage youth to get interested in engineering):   http://www.youtube.com/watch?v=Vh9LpNQ_S0k&feature=related
7)   Carbon fiber racing car seat with 2 - the SciChair: http://www.youtube.com/watch?feature=player_embedded&v=HtivH7INpZ4
8)   Carey's self-balancing platform, good video:   http://www.youtube.com/watch?v=ngMJcxeB7og
9) Really cool video (on clifftop path by the sea): Skate auto-balancé http://www.youtube.com/watch?
10) The KSLURP board from Malaysia: http://www.youtube.com/watch?v=x3O2NkjJOlg
11) The MIT Seboard, video clip: http://www.youtube.com/watch?v=zZQb-w_wyhM
12) The SITWAY sit-on machine by the 81year old gentleman above, with video: http://www.instructables.com/id/SITWAY/
13) This one has nothing to do with me but is such a really cool inspirational project I include it here, the TILTER skateboard, with hub motors and a suspension system: http://www.youtube.com/watch?v=WsYukdSO64A&feature=player_embedded
14) New one wheeler from team cosmos with some technical information and video here: http://teamcosmos.com/skateone/index.shtml


NOTE:
You build these at your own risk. If tilted they WILL accelerate to correct the tilt. If you are not on the board, this means it can fly across a room or into your head. This is why you have to have an emergency hand switch that cuts the power if you let go of it. If it develops a fault it does not have multiple redundant systems like a real segway, most likely you will fall off! The code is not guaranteed against any bugs. If you don't believe me here is a video of Clint Rutkas developing a similar machine, also featuring some holes it punched in the walls of his apartment!    http://vimeo.com/2013773

Have fun. Treat it as an adventure. Once you get it to balance there are many ways to improve it.

John



 

 
Remove these adsRemove these ads by Signing Up

Step 1: Parts

Partsonfloor.jpg
Here are the parts laid out on floor
kennyng says: Apr 23, 2013. 12:20 AM
Hi XenonJohn and friends,

I am amazed by the self-balancing skateboard and had tried to make it myself. The instruction is very clear and I really learn a lot from the thread.

I am in the stage of using “ Just Balances Codes “ and got stuck. The skateboard that I built doesn’t not response fast to the angle tilted. When I tilted the skateboard from side to side, I can see from the serial window that values under Motor1percent and Motor2percent change from + to – and – to +. But once it hit -100 or 100, it will stay at this value for a pretty long time even I had tilted the skateboard to the other direction.

Can anyone help me on this problem. Really wanted to have it working. Thank you so much in advance.

Kenny
XenonJohn (author) in reply to kennyngMay 15, 2013. 3:32 PM
If you hold it tilted one way, there is a value (the cur-Speed) term that increases according to how LONG (in time) it has been tilted that way, the I in PID. This accumulates until it eventually is sending 100% power to motors to try to make it go the other way and become level again.
If testing machine off the ground, i.e. with wheels in the air, you then tilt it other way and it takes a moment or two for this accumulator to decrease and then go the other way. If you rock it back and forth past the centre balanced point (as in real self-balancing) this term never really accumulates to a significant value.
This feature is used to go up slopes, you hold board slightly tilted (but still balancing) and the power slowly increases until it starts to go up the slope.

You can set the cur-speed term to zero in the code as it will still balance OK on level ground just using the P and D parts of "PID"

Alternative is to just try the machine with wheels on the ground and stand well to one side.

Does anyone fancy setting up a self-balancing segway/skateboard Arduino forum? There are so many Q and A's here now, and quite a few working boards out there too, we should all really just be helping each other out.with problems as a community of builders because the collective knowledge is out there now. I have no idea how you set up a forum.

John
XenonJohn (author) in reply to kennyngMay 15, 2013. 2:59 PM
It has no concept of position, only whether it is level or not. All it does is try to stay level by applying power in one direction or the other. Note, it does not apply a set speed, merely applies power which is not quite the same thing. Therefore it has no concept of speed either, only how much power is being applied as a percentage between 0 and 100% in either direction.
You can alter the balance point so it almost stays in one place, but it will never do so perfectly.
To give it "knowledge" of position, you would fit wheel speed encoders which tell arduino how fast wheels are rotating, then modify code so it stays balanced but also keeps the average wheel speed over time at or close to zero. This would make it more or less stay in one place.
If you are riding it you essentially do this manually by leaning a bit one way then the other.
If wheel encoders failed with you on it, - dirt on the optical encoder for example, there would be unpredictable behaviour as computer would then follow the "rubbish in, rubbish out" maxim and who knows what it would try to do.

John
zaki4484 says: Mar 26, 2013. 2:02 AM
hi,
I'm just wondering, is it possible if we don't use hand controller?
I mean like, we only need to use body motion to move the skateboard.
Thanks!
XenonJohn (author) in reply to zaki4484May 15, 2013. 3:19 PM
If you just have one wide wheel, then you can ride it like snowboard and turn by tyre deformation.

With 2 wheels fixed on the same axle with just one motor, if you have pneumatic tyres AND wheels fairly close together AND tyres medium-soft, then by leaning you will compress the inner tyre and so start to turn. Soft tyres mean more power required to run the machine however.

Finally, as in my "pneu-skate" you could fit pressure sensitive resistors on the deck and use your heel versus toe foot pressure to steer the machine (2 motors one for each wheel). This takes some experimentation to get right but did work. Hint: Put rubber pads over the resistor pads.

Very finally, look at the "Velocyrider" project where the foot platform for the trailing foot could actually be tilted by moving the foot. This was attached to a steering potentiometer which steered the machine.

So the answer is yes it can be done, but you need to be prepared to experiment a little. Nothing wrong with that. As Einstein said, "If we knew all the answers it would not be called research would it?"

John
sgovaerts says: Apr 11, 2013. 11:29 AM
Hey John

First of all: thank you for this amazing tutorial! :)
I was just wondering if you have to use the sabertooth. Can you also use a dual-channel motor drive module like this one, in combination with 2 300W motors?

http://www.benl.ebay.be/itm/High-Power-50A-Dual-Channel-motor-drive-module-Arduino-Compatible-and-library-/130717806584?pt=LH_DefaultDomain_0&hash=item1e6f636ff8

These are its specs:
Peak current (Load): 50A
Recommend max working current(Load): 20A
Power VCC (Load): 0V~30V
Recommend power vcc(load) : 12V ~ 26V
Control VCC: 4V~12V
Control TTL Voltage; 2.5V ~ 12V

Thanks in advance!
Stijn
XenonJohn (author) in reply to sgovaertsMay 15, 2013. 3:12 PM
It is peak 50A on ONE channel. This suggests it is peak 25A if using both channels. Nominal is 20A (it does not say per channel so nominal may be 10A per channel if both channels used separately).
Also no heat sink, you have to add your own.
No safety cut out if it overheats, it just melts essentially.

So, it is cheap so it may be worth taking a chance with it. Do not cry if it burns out however! It would probably be OK for a machine running gently on flat level ground. I have seen a small mini-Segway type machine run with a 2 x 10 Amp Sabertooth power controller but that was running slowly on a very smooth floor.

You get what you pay for with motor power controllers. The sabertooth and other similar robot controllers are expensive but they also have shut down circuits that help protect them if they get too hot. This means in the long term they may end up cheaper.

I have blown up several low cost controllers over the years and now realise that a good quality one will actually cost you less money over the long term.

Hope this helps.

John
him2anshu says: May 12, 2013. 3:04 AM
Can you please add the 6DOF digital code again please, its been removed again, or mail me at hemu.rockz@gmail.com
XenonJohn (author) in reply to him2anshuMay 15, 2013. 2:53 PM
See the note I have added to the title page. I would if I were you modify the code of Thomas Feminella as he has a unicycle self balancing using a digital IMU. Therefore he is the most advanced person so far as regards getting anything capable of carrying a human to self balance using a digital IMU and Arduino.

I am making a new compact board with an old analog IMU, pneumatic tyres and decent battery pack, but when it is built, I will then start investigating a digital IMU seriously to see if I can get it to work, based very much on his code.

John
eyhseow says: May 9, 2013. 1:51 AM
Hi All

My self-balancing likes to move left and right and doesn’t stay still in one position. Anywhere in the code where I can change to make it stay still?
Please help. Thanks.
eyhseow says: Mar 15, 2013. 1:41 AM
Dear Xenon John

Any update on on the SIXDOF digital unfinished code?

Thanks.

Regards
William Seow
XenonJohn (author) says: Mar 2, 2013. 9:15 AM
HI everyone,

Been away from this for a while. Still working on balancing machines though.
The specimen, UNFINISHED and UNTESTED attempt at reading a digital IMU (using Arduino V22 by the way) on step 53 has just been put back. For some reason it keeps disappearing, it is not because I remove it deliberately or anything.
Needs someone with proper training as programmer to write some software not just to read a digital hobby IMU, for which examples do exist, but then also run self balancing code without disrupting the reading of the digital IMU......which I have not been able to do yet. Whenever I add in the self balancing code, my data stream from the IMU locks up now and then.
For now all my projects are using analog IMU's from earlier projects.

All the best,

John
Pizzapie500 says: Sep 5, 2012. 8:22 AM
Hey, I got to the Just Balances point, but mine isn't balancing. I did the accsum thing, however it continues to violently waver up and down. Also it drifts a little bit forward. Any ideas?
Tim003 in reply to Pizzapie500Sep 9, 2012. 2:52 PM
Hello Pizzapie500,

Does your Just Balance act like this http://www.youtube.com/watch?v=MJLbAxnqPfE (video) ?

Also, my deadman switch is acting weirdly. When pressing the deadman switch, the wheels start spinning but as soon as I release the deadman switch, the wheels keep spinning instead of stopping. Does anyone have any idea on what the problem is?

Thanks,
Tim003
Pizzapie500 in reply to Tim003Sep 9, 2012. 6:01 PM
Yep. That's the exact problem, except I don't have to tilt it that far to engage tilt start. Did you figure out a solution? Your deadman switch is probably short circuiting. I had the same problem with my wii nunchuck.
Tim003 in reply to Pizzapie500Sep 9, 2012. 6:18 PM
Hi.

Well, that was a one time problem. Normally I just tilt it until it is horizontal and the TILT START engages.

I did not figure out a solution as of yet. I am still working on it but it seems that I am not using a resistor for the deadman switch, which might be the problem... Is that what you are referring to when saying " Your deadman switch is probably short circuiting. I had the same problem with my wii nunchuck. ".

If so, I will only be able to try with a resistor tomorrow since I currently do not have a 1500Ohm resistor.

Thanks,
Tim003
Tim003 in reply to Tim003Sep 10, 2012. 3:31 PM
Hi again,

My deadman switch is now working correctly. But the Just Balance code still does not work (by that, I mean that the robot doesn't self-balance at all).

Pizzapie500 in reply to Tim003Sep 10, 2012. 4:29 PM
Hey, so I guess now we're at the same standpoint now. We both are stuck at the Just Balance :( I'm going to try changing the values in the code, and I'll tell you if it works.
Tim003 in reply to Pizzapie500Sep 10, 2012. 5:24 PM
Thanks! I will also do my part by trying to change some things in the code.
Pizzapie500 in reply to Tim003Sep 11, 2012. 5:31 PM
Cool! I seem to have a problem with the deadman switch again. What did you do to fix it? Also XenonJohn commented this, "increase derivative gain constant (0.5 at present) so that when you tilt it one way it rapidly corrects in a damped sort of way, i.e as it get back closer to balance point the force of the correction drops off so it rapidly corrects without overshooting or oscillating". I haven't tried it yet, but it might help.
Tim003 in reply to Pizzapie500Sep 11, 2012. 6:15 PM
I'll try to do that tomorrow morning.

Here is a picture of what I did.

https://www.dropbox.com/s/z3m8vkhdwi3pvmc/IMG_20120910_160508.jpg

I got a 10K resistor, "tied" it to pin 9 wire and plugged the other side of the resistor to GND (ground). If you can't seem to understand what I did, I can take a few more pictures.

Thanks,
Tim
Pizzapie500 in reply to Tim003Sep 12, 2012. 5:13 PM
Oh, so that's what i did wrong! I only used a 2.2k resistor... Will try that in like 30 minutes. Good luck with the script! I have a lot of homework to do, so I can't play with the values tonight.
Tim003 in reply to Pizzapie500Sep 14, 2012. 12:54 PM
I tried to change the value but it did not change anything. I am not sure what value John is talking about. There are two 0.5 values. Do you have an idea?
Pizzapie500 in reply to Tim003Sep 14, 2012. 3:55 PM
I think he's talking about the overallgain target because it's under "setup variables". It turns out that it wasn't the resistor to ground that I needed, it was that the Nunchuck pressure sensor I had was broken. Now i'm just using a momentary switch as the dead man. Going to try the values tonight and the weekend.
Tim003 in reply to Pizzapie500Sep 16, 2012. 12:59 PM
I'll try that tonight.

Did you try changing the values already?
Pizzapie500 in reply to Tim003Sep 16, 2012. 5:25 PM
Tried switching my accsum to 344 and changing the derivative gain to .7. Unfortunately, it's acting like a bucking horse.
Tim003 in reply to Pizzapie500Sep 16, 2012. 6:34 PM
Can you do something for me (and everyone else on this website). Could you copy and paste your serial data on here? I will put mine on her tomorrow. We should compare our data.
Pizzapie500 in reply to Tim003Sep 17, 2012. 4:44 AM
Some data of a bucking horse:

balancegyroDegrees:-5.30 X-accdeg:1.48 overallAngleofTilt:0.816,9\n
balancegyroDegrees:-32.82 X-accdeg:-7.80 overallAngleofTilt:1.306,9\n
balancegyroDegrees:51.03 X-accdeg:4.02 overallAngleofTilt:5.676,9\n
balancegyroDegrees:56.18 X-accdeg:13.83 overallAngleofTilt:-0.726,9\n
balancegyroDegrees:33.36 X-accdeg:37.07 overallAngleofTilt:0.806,9\n
balancegyroDegrees:-2.00 X-accdeg:22.00 overallAngleofTilt:0.195,10\n
balancegyroDegrees:-4.23 X-accdeg:-2.18 overallAngleofTilt:5.676,8\n
balancegyroDegrees:-12.07 X-accdeg:3.98 overallAngleofTilt:5.266,9\n
balancegyroDegrees:81.01 X-accdeg:-18.59 overallAngleofTilt:16.106,9\n
balancegyroDegrees:-15.99 X-accdeg:-22.78 overallAngleofTilt:14.156,9\n
balancegyroDegrees:-60.26 X-accdeg:1.15 overallAngleofTilt:6.765,9\n
balancegyroDegrees:11.07 X-accdeg:20.36 overallAngleofTilt:7.285,9\n
balancegyroDegrees:0.46 X-accdeg:16.95 overallAngleofTilt:6.696,8\n
balancegyroDegrees:-5.61 X-accdeg:11.45 overallAngleofTilt:5.996,9\n
balancegyroDegrees:2.77 X-accdeg:17.20 overallAngleofTilt:5.536,9\n
balancegyroDegrees:-1.00 X-accdeg:9.65 overallAngleofTilt:4.977,9\n
balancegyroDegrees:8.68 X-accdeg:1.77 overallAngleofTilt:5.325,9\n
balancegyroDegrees:3.92 X-accdeg:16.83 overallAngleofTilt:5.575,9\n
balancegyroDegrees:0.69 X-accdeg:-1.89 overallAngleofTilt:5.776,9\n
Tim003 in reply to Pizzapie500Sep 17, 2012. 8:58 AM
Ok. I can't really verify anything right now (I m in class) but it seems that everything is working fine for you. Here is why:

"However when you tilt the board so accel values go +ve, the gyro values should TRANSIENTLY go more +ve also.

They will go transiently -ve as accel angle goes -ve when you are tilting it the other way.

If this happens then you have your accel and gyro mounted correctly!"

From my past paste of the data (http://pastebin.com/LpUd3PFp) it seems that my IMU is having trouble getting it's values right. I'll find out more about it as soon as I am back.
Pizzapie500 in reply to Tim003Sep 17, 2012. 1:05 PM
I think that we're doing different codes. I was using the Just Balances code. This is my IMU tester code data:

3,9
\n
balancegyroDegrees:7.07 accelDegrees:-1.11 overallAngleofTilt:1.90 accsum: 345.29
3,9
\n
balancegyroDegrees:5.23 accelDegrees:0.49 overallAngleofTilt:2.92 accsum: 343.43
3,9
\n
balancegyroDegrees:6.53 accelDegrees:2.26 overallAngleofTilt:4.35 accsum: 341.38
3,9
\n
balancegyroDegrees:6.76 accelDegrees:3.61 overallAngleofTilt:5.84 accsum: 339.81
4,9
\n
balancegyroDegrees:5.00 accelDegrees:6.57 overallAngleofTilt:7.06 accsum: 336.38
3,9
\n
balancegyroDegrees:0.46 accelDegrees:7.92 overallAngleofTilt:7.73 accsum: 334.81
3,10
\n
balancegyroDegrees:-4.61 accelDegrees:6.90 overallAngleofTilt:6.93 accsum: 336.00
3,9
\n
balancegyroDegrees:-6.76 accelDegrees:5.71 overallAngleofTilt:5.48 accsum: 337.38
3,9
\n
balancegyroDegrees:-2.38 accelDegrees:3.82 overallAngleofTilt:4.58 accsum: 339.57
3,9
\n
balancegyroDegrees:-4.92 accelDegrees:3.49 overallAngleofTilt:3.65 accsum: 339.95
3,9
\n
balancegyroDegrees:-6.69 accelDegrees:2.26 overallAngleofTilt:2.18 accsum: 341.38
3,9
\n
balancegyroDegrees:-9.15 accelDegrees:0.00 overallAngleofTilt:0.12 accsum: 344.00
4,8
\n
balancegyroDegrees:-6.99 accelDegrees:-2.83 overallAngleofTilt:-1.81 accsum: 347.29
4,9
\n
balancegyroDegrees:-9.45 accelDegrees:-4.27 overallAngleofTilt:-4.10 accsum: 348.95
4,8
\n
balancegyroDegrees:-6.92 accelDegrees:-6.44 overallAngleofTilt:-5.95 accsum: 351.48
3,10
\n
balancegyroDegrees:-9.61 accelDegrees:-8.99 overallAngleofTilt:-8.32 accsum: 354.43
3,9
\n
balancegyroDegrees:-2.92 accelDegrees:-10.59 overallAngleofTilt:-9.39 accsum: 356.29
3,10
\n
balancegyroDegrees:-4.07 accelDegrees:-11.45 overallAngleofTilt:-10.43 accsum: 357.29
3,9
\n
balancegyroDegrees:2.38 accelDegrees:-11.70 overallAngleofTilt:-10.15 accsum: 357.57
3,10
\n
balancegyroDegrees:6.07 accelDegrees:-10.67 overallAngleofTilt:-8.86 accsum: 356.38
3,9
\n
balancegyroDegrees:8.22 accelDegrees:-7.88 overallAngleofTilt:-6.95 accsum: 353.14
3,10
\n
balancegyroDegrees:9.30 accelDegrees:-6.53 overallAngleofTilt:-4.70 accsum: 351.57
3,9
\n
balancegyroDegrees:8.53 accelDegrees:-3.74 overallAngleofTilt:-2.60 accsum: 348.33
3,10
\n
balancegyroDegrees:9.38 accelDegrees:-1.11 overallAngleofTilt:-0.46 accsum: 345.29
3,9
\n
balancegyroDegrees:5.61 accelDegrees:3.16 overallAngleofTilt:1.42 accsum: 340.33
Tim003 in reply to Pizzapie500Jan 31, 2013. 7:48 AM
Did you get the segway working in the end?
Pizzapie500 in reply to Tim003Jan 31, 2013. 12:10 PM
I haven't got the time with school and everything. Did you?
Tim003 in reply to Pizzapie500Sep 17, 2012. 3:05 PM
We are actually using the same one. I am using the Just Balance code. I just decided to show ACCSUM in the serial data so that I know it is correct and nothing is messed up.
And yes, my ACCSUM is about 290 when horizontal. I don't really know why, but it doesn't seem to matter.

Pizzapie500 in reply to Tim003Sep 17, 2012. 4:12 PM
I see. Well, to get the correct gyro reading, I just soldered exactly the same way he did, and I mounted it using removable blue tac. Now I just have to figure out why my skateboard is over compensating and bucking.
XenonJohn (author) in reply to Pizzapie500Sep 23, 2012. 12:35 PM
Hi,

Send me a working email via the messages section and upload a video clip to youtube showing me what your machine does and let me have the link.

When we are in email contact, send me your sketch as you are using it and I will make some suggestions for you.

Best wishes

John

Pizzapie500 in reply to XenonJohnSep 30, 2012. 5:49 PM
I couldn't find your email address. Mine is pizza_pie900@yahoo.com (don't laugh, I made it in 1st grade). Anyhow, here's a video link to it. I forgot to copy the serial data, but I put it to the right of the video. http://www.youtube.com/watch?v=ScdXiRfAGVw&feature=youtu.be
XenonJohn (author) in reply to Pizzapie500Oct 21, 2012. 3:38 PM
Hi
I am sending you an email with suggestions.

Your machine is working but it looks a lot lighter in weight than mine so it does the right thing when it tips, but then overcompensates. Its like having your stereo amplifier working OK but then you turn the volume up to 11 !

Have emailed you some new code to try. It has a lower overallgain setting you can play with.

Also, I would not use rapid serial.Print values to the screen just maybe every 2 sec while balancing as it upsets the loop timing slightly. OK for testing your IMU but otherwise no.

Try out the new "Just balances nothing else" code I email you and let me know what happens. Have just sent it to someone else to try too but seems to be OK.

John

Pizzapie500 in reply to Pizzapie500Oct 1, 2012. 6:42 PM
Sorry for the double post, but you can see the serial data in full screen 1080 HD
Tim003 in reply to Pizzapie500Sep 17, 2012. 5:14 PM
The problem must be in the code somewhere. I hope John will read the comments and help us. I have no idea what to do right now.
peraz91 says: Sep 27, 2012. 5:07 AM
hello, I'm trying to build a balance!
I made the circuit today with all the parts but I have found serious problems:
1) The motor 1 rotates very slowly and does not respond all'IMU.
2) The motor 2 is stopped forever!
3) During the compilation of the Arduino sketch tells me that the word "BYTE" I have to replace with "Serial.write ()".
4) None of the switches affect the rotation of the motor 1.
If you can help me do me happy :)
Tim003 in reply to peraz91Oct 1, 2012. 2:34 PM
Here is how you fix #3:

SaberSerial.print(byte(0));

My best guess for problem #1,2 is that you misconnected a wire somewhere. Everything should be working fine with XenonJohn's code.

For problem #4, do you have a continuous switch or a momentary switch? You must have a momentary switch. Otherwise it won't work (I tried). Also, this is a good way to complete the switch circuit: https://www.dropbox.com/s/z3m8vkhdwi3pvmc/IMG_20120910_160508.jpg
WARNING: it does take a lot of battery. There might be another way of doing it, but I do not have too much time to deal with that problem right now.
peraz91 in reply to Tim003Oct 23, 2012. 4:06 AM
is amazing but to be functioning my IMU must be placed approximately at an angle of 45 degrees. I do not understand the reason for this behavior.
Tim003 in reply to peraz91Jan 29, 2013. 8:12 AM
Did you get it to work?
peraz91 in reply to Tim003Jan 30, 2013. 1:25 AM
Yes
Tim003 in reply to peraz91Jan 30, 2013. 1:26 PM
Would it be possible for you to send me your code? (tgirgin (at) wisc . edu) I've been stuck on this project for a while. The board just does not want to self-balance. It freaks out as soon as it is set.

And what was the deal with the IMU?

I really hope you can help me.

Thank you!
natsud1 says: Jan 16, 2013. 7:25 PM
Hello i am also looking for the digital version code that is supposed to be attached to step 53. I dont think it got attached, can you please repost it? I have tried to implement a digital version to your code with no success I am using a generic MPU6050 IMU and i just can figure out what the problem is hopefully I will have better luck with your code. and Thanks a million for your hard work.
XenonJohn (author) in reply to natsud1Jan 23, 2013. 5:01 AM
Instructables seem to have removed it along with the title photo which disappears for no obvious reason every month or two.
Must have uploaded it over 20 times since this I first put this up.

natsud1 in reply to XenonJohnJan 23, 2013. 7:18 AM
Thats odd, must be frustrating I bet its a pretty popular request. Would you be willing to send it to my email? natsud1@yahoo.com or maybe post it on github? i would really appreciate it
davidwjib says: Jan 15, 2013. 1:42 PM
Could you re-post your code that works with the digital 6DOF IMU please?
eyhseow says: Jan 15, 2013. 12:40 AM
Dear Sir
Do you have any spare anlalog IMU-5DOF or 6DOF that I can purchase from you? Please advise.
eyhseow says: Jan 15, 2013. 12:32 AM
Dear Sir
Do you have the software code for the whole project using the digital 6DOF, and the full schematics diagram for the whole project. If not the connections between the digital 6 DOF and the Arduino. I will greatly appreciate for your help.
eyhseow says: Jan 13, 2013. 11:22 PM
Dear Sir,

Do you have spare 5 dof analog accelometer (sparkfun part number: 11072) that I can purchase from? Can I use Sparkfun 6dof DIGITAL IMU for self balancing scooter project and also the code for self balancing scooter? Please advise. Thanks.
Blkant says: Jan 7, 2013. 3:16 AM
Seems I've arrived on the scene a bit too late... Not only is the 5DoF IMU gone again but the 6DoF IMU is gone as well. There is only a 9DoF IMU "Razor" now. Not sure where to even begin to attempt this one now. I fear this might be hopeless now without knowing all the ins and outs of the IMUs. Does anyone have ideas on how to approach this with the currently available hardware?
atanguay says: Jan 3, 2013. 8:59 PM
Any suggestions as to the exact IMU to get from Sprakfun as of jan 2013? I need some things from them and would like to include one that would work for this project.

https://www.sparkfun.com/pages/accel_gyro_guide

Seems like these things are getting killed as fast as they're coming out.

Really really cool stuff. I definitely want to build some kind of self balancer over the winter for the spring. Thanks for any ideas, and thanks for sharing!
el_walto says: Dec 8, 2012. 4:13 PM
So, i finally figured out that both raw AND vref have to be connected to 3.3v. I only had raw connected before and could not get imu test code to work. Hope this helps someone.
meirmark says: Nov 13, 2012. 12:08 PM
Hi.
Very nice work.
I like to use your desigen to build a segway with 16" weels.
what changes do I need to make to the software ?
el_walto in reply to meirmarkDec 8, 2012. 4:12 PM
I don't think you need to make any changes to the software
peraz91 says: Oct 26, 2012. 4:16 AM
the test of the IMU and the rest of it works, but the engines tend to shake and it becomes impossible to use.
Nthatchable says: Oct 21, 2012. 5:28 PM
A while ago I built a "Segway" style machine based on this instructable, using a Sabertooth and it works perfectly, I'm now attempting to make a one wheeled device using the Syren 25. When I power the system up the Syren goes full steam ahead for about 5-10 seconds before being stopped by the code, Im wondering if anybody else has had experience with this?
XenonJohn (author) in reply to NthatchableOct 22, 2012. 6:05 AM
Yeah, me!

Have tried same thing. Syren does not seem to behave just like a one channel version of the Sabertooth, even though it is supposed to. Still playing around with it.

My original heavyweight one wheeler used an OSMC and a different microcontroller with faster pwm output on it.

John
Nthatchable in reply to XenonJohnOct 22, 2012. 7:20 AM
Thanks, at least it's not just me, I've found I can lift the wheel off the floor whilst the arduino boots up, and then it behaves itself, but I'm thinking of shoving a Sabertooth in and just using one of the channels, plus it may be useful to have a spare channel for future Additions.
el_walto says: Sep 24, 2012. 2:47 PM
This is a really nice tutorial. I just finished building my side by side platform using 500Watt motors and 12.5" wheels. I hope to finish with all of the electronics\programming soon.

I have the 60amp sabertooth, so might end up using 8S LiPo after I'm done testing with 24V SLA.
grunff says: May 23, 2012. 9:32 AM
Hi XenonJohn,

I built a robot using this setup a while back, but never managed to get it to work satisfactorily. I've now picked the project back up to see if I can get it working.

The problem I'm having is caused by the Level drifting very quickly, so the board never finds its level. It tries to level, but by the time it gets there, the Level variable is way off horizontal, so it can't balance.

Any idea what can cause this drift? It happens over a few seconds, and within 30 seconds or so instead of being 0 deg it's 400 deg.
XenonJohn (author) in reply to grunffMay 25, 2012. 7:45 AM
Hi,
This is a classic issue. The gyro is doing the short term balancing but it drifts so after 30 sec or so it still balances but at an odd angle. The accel is supposed to gradually correct this. What you describe is the accel acting against the gyro rather than with it (i.e. back to front).

Solutions, turn IMU over (current upper side downwards) or alter code:

Take this line:
x_accdeg = (float)((accsum - (338 + balancetrim))* (-0.862));

Change the sign before the 0.862. If +ve now change it to a minus sign or vice versa.

Alternative is to take this line in code:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);

and again, change the sign so now reads opposite of what it was before:
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);

It makes the accel interact with the gyro readings in opposite way to whatever it is doing currently.

Hope this helps

John
grunff in reply to XenonJohnMay 25, 2012. 8:33 AM
Thanks for your help John, I appreciate it.

I'd actually got past this point, but I'm still having trouble getting it to balance. It starts off well, then oscillates wildly out of control. I suspect the values in your sketch are not working well on this small frame (~500g).

I'm experimenting with overallgain, and also with the scaling variables in the balance_torque calculation (4.5 and 0.5), but I still haven't managed to make it balance.

Any further insights would be much appreciated.
XenonJohn (author) in reply to grunffMay 26, 2012. 11:50 AM
Here is one way of many to do pid tuning I have found on the web:
Set all constants to zero
1) increase prportional gain constant (currently 4.5) until it more or less balances but starts to oscillate wildly. Then set the value to about 1/2 to 2/3 this value.

2) Increase derivative gain constant (0.5 at present) so that when you tilt it one way it rapidly corrects in a damped sort of way, i.e as it get back closer to balance point the force of the correction drops off so it rapidly corrects without overshooting or oscillating.

3) The I gain is more what tends to keep it in one place. Keep increasing it until you get oscillation then back off a bit. If too high and you push it off balance machine will roll along, regain balance, then roll back the other way as the I gain was too high. I gain in this sketch is actually the cur-speed multiplier value So that is the line of code you need to play with.

I am not an expert, whole theses are written on this, but this is one relatively simple explanation i found on the web.

John
grunff in reply to XenonJohnMay 27, 2012. 2:00 PM
Thanks very much for that John. I will spend this evening trying to tune it :-)
Pizzapie500 in reply to grunffSep 16, 2012. 5:59 PM
Did you ever figure out the solution? Please tell!
Pizzapie500 says: Sep 5, 2012. 5:58 AM
My +5V and Gnd short out doing this. Any ideas? I think it might be that I connected both +5V together since there's only one +5V pin.
Pizzapie500 in reply to Pizzapie500Sep 5, 2012. 7:14 AM
Solved it. I soldered a 1.8k resistor to the +5V, and it doesn't short out anymore.
grunff says: Apr 22, 2011. 1:14 PM
Hi John,

I hooked up my Arduino to my Sabertooth for the first time today, and ran the motor test. The output from the Arduino looks good. The deadman switch is on, and it is stepping through the motor outputs as it should. The DIP switches on the Sabertooth are set correctly, and the batteries and motors are all in place. But the Sabertooth doesn't power the motors - nothing at all!

I tested the Sabertooth in analogue mode just to check that it's good, and that side of it is fine. I stripped down the test code to just power the motors at 100%, and still nothing.

Did you have any problems getting the Arduino to talk to the Sabertooth? Any tips?
XenonJohn (author) in reply to grunffApr 23, 2011. 3:15 PM
Don't have any easy suggestions to be honest.

Only time my saber has refused to work was when I charged batteries so much they were producing around 37V. Saber decided this was too high so refused to work until I hed left it turned on for a while to drain the batteries a little.

I do know someone who had a faulty sabertooth which worked but highly erratically. He mailed me his Arduino/IMU and it worked fine on my sabertooth so he sent his back and had it replaced.


You could rewrite the code so it works using the analog inputs of the sabertooth.
If you look at the Instructable by Shane Colton that shows how to make a segway with drill motors, he has a sketch that resets the arduino pulse width modulation from the standard 500Hz (too slow) to a much faster rate.

If you smooth the pulses with an R/C filter so it JUST smooths out the pulses to a stable voltage (so retain the "instant" response time), then it could work.

One of my early boards used a non-arduino microcontroller, a PWM output of about 20,000Hz, with the ripples just smooothed with an R/C filter, feeding into the analog inputs of the sabertooth and it did work OK.

I used the serial link communication method in the instructable to deliberately avoid all this hassle!

John
grunff in reply to XenonJohnApr 24, 2011. 1:42 AM
Thanks for your help John. After spending much of yesterday playing with it, trying everything I could think of (including packetised serial), I am now 99% confident that my Sabertooth doesn't talk serial.

Rather than using the Sabertooth in Analog mode, I'm having a go at using it in RC mode. This is where it pretends to be a servo. I've used Arduinos to control small RC ESC like this. It does work fine, but I am concerned it wont be fast enough for self balancing.

There's an Arduino Servo library which does all the work for you, you just give each motor an input between 0 (full reverse) and 180 (full forward).

Will post an update on how this goes - I'm not convinced the response will be fast enough though.
grunff in reply to grunffApr 24, 2011. 3:59 AM
Ok, here's the update. I've used the Sabertooth's RC mode, and modified John's self balancing code to talk to the Sabertooth as a servo. While the communication does work, the board will not balance. It tries to, but overshoots, and ends up oscillating back and forth.

Do you think the speed of the communication is the issue, or could solething else be causing the overshoot?
grunff in reply to grunffApr 24, 2011. 5:42 AM
Another update :-) Got it to balance by cutting the servo output down to 50% (so instead of 180-90-0 it's 135-90-45.

Balances fine, but has a tendency to wander around the garden slowly on its own.
Tim003 in reply to grunffSep 1, 2012. 1:13 AM
Hi,

I hope you will receive this comment. Could you give out more information on what the problem was? I'm getting the same trouble as you did - system seems to react to late, therefore it does not balance correctly. Could you please share more about your solution? Thanks.

~Tim
grunff in reply to Tim003Sep 3, 2012. 2:42 AM
Hi Tim,

I'm not sure you have the same problem, in my case it was reacting too much, overshooting. I fixed this by reducing the motor speed range (I was using the servo lib, because my sabertooth refused to work in serial).

I got the board to balance in the end. I then went on to build a smaller robot, which I never succeeded in getting to balance satisfactorily. It would balance for a while, but eventually would oscillate itself into the ground.

Good luck!
Tim003 in reply to grunffSep 3, 2012. 9:18 AM
Hi grunff,

Sadly, I have never worked with a servo. It would be difficult for me to learn how to use one correctly I guess. I made a video though, http://www.youtube.com/watch?v=MJLbAxnqPfE

This is not the problem you get? I have to hold my board so that it somewhat "balances"..

Thanks!
grunff in reply to Tim003Sep 3, 2012. 11:14 AM
Hi Tim,

I think you definitely have a different problem to the one I had, looks like your motors are not responding fast enough.

Have you tweaked overallgain? Try increasing this from the current value, and note how this affects the behaviour.
XenonJohn (author) in reply to grunffMay 21, 2011. 8:30 AM
More on this:

Someone else has recently contacted me as he cannot get the sabertooth to respond to serial commands either.
I just wonder if some sabertooths have a fault with this as others do seem to get it to work OK.

Re: wandering around the garden: If you use a PID loop the "I" should stop it wandering too far.
As I am using something more like a "PD" loop in the code, it is only the rider who stops it rolling off in one direction by leaning back a bit when necessary.

Simplest explanation of all this I have seen is the SegWii project video and pdf tutorials:
www.segwii.com

John
XenonJohn (author) in reply to grunffMay 7, 2011. 5:05 AM
The second gyro is used to RESIST sudden turns when board moving along and no steering inputs being given by the rider.
This stops
a) Machine spinning you off if one wheel hits small obstruction.
b) Machine spinning you off as you come to a standstill after a run as one motor stops before the other one as they often have slightly different amounts of internal friction.

I learned all this by falling off!

Now, gyros drift with time, they are not the same as an electronic compass when used like this.
So, if you don't put in any steering inputs for a while, the "resist sudden unexpected changes is course" gyro will drift a bit and the board will start to meander around your garden as you say!

John
Tim003 says: Aug 29, 2012. 2:30 PM
Hello John,

Could you please tell me if my IMU has a problem or my Arduino?

When the "robot" is leveled (TILT-START is already engaged) and you suddenly tilt the robot to the right or left, the overallAngleOfTilt is responding fast (takes less than 2 seconds to get a "stable value") but when you go from tilted to level the overallAngleOfTilt is very slow (takes time) to come back to its leveled AngleOfTilt (at least 30 seconds).

Tim003 in reply to Tim003Aug 29, 2012. 3:22 PM
Here is a copy of my serial monitor. Could you please take a look?

http://pastebin.com/LpUd3PFp

I did test if everything was positioned correctly with the help of STEP 42. Everything is fine. The board just doesn't want to balance... it is way too slow to respond and get leveled again.

Is something wrong somewhere?
Tim003 says: Aug 20, 2012. 1:18 PM
Hello John,

Thank you for this awesome project. I would like to know if you have anything to say on how to connect the sabertooth to the arduino? I can't seem to find anything written on this page nor on your website. Can you give me (and the rest of the community) some tips on what pins to use on the Arduino and where to place them on the sabertooth.

Thank you!

Tim
Tim003 in reply to Tim003Aug 29, 2012. 2:15 PM
Never mind this, I found the solution. It's on the schematic with the Arduino.
nimith says: Jun 28, 2012. 1:16 PM
Hi John,

Sorry to Bother you again,

I am new for the Gyro and ACC concept.

I got the 5 DOF( SEN-11072) from Sparkfun that have reg for3.0 v on board,

Connected as your schematic to analog port of Arduino,

Motor Test anticlockwise -- OK !!

Uploaded IMU_test_code and installed IMU board point the 2 hole downward to the floor and component side face to the back

Till to engaged and then test to tilt anticlockwise ACCEL Should go V+

like this :-

balance-GyroDegrees:-32.74 AccelDegrees:-9.48 overall Angle of Tilt:-52.60 accsum: 303.00

Tilted Clockwise :-

balance-GyroDegrees:-32.89 AccelDegrees:12.93 overall Angle of Tilt:-58.44 accsum: 277.00

and hold still to Level:-

balance-GyroDegrees:56.87 AccelDegrees:-0.70 overall Angle of Tilt:116.39 accsum: 292.81

so i will use 292 for the accsum then recompiled

But I think something wrong with Gyro sometime value stay at 0 or 450 and not statble like ACC number, is that Gyro already failed ?

I cannot get it balance Motor spin like crazy.

I think GYRO board already failed.

Thank you,

NM






Tim003 in reply to nimithAug 24, 2012. 2:37 PM
I'm actually having the same problem as you do. Did you find the solution to get the motor spinning at its max RPM?

Thanks,
Tim
nimith in reply to Tim003Aug 24, 2012. 10:14 PM
No, I still do not figured that out.

Hard to deal with yet, I might need to try to see why later .

NM
Tim003 in reply to nimithAug 25, 2012. 1:16 PM
I actually found a solution so that the wheels do not go faster then a certain percentage of RPM. Go to your code and search for motorpercent (sorry, the name might be different, I do not have the code in front of me) and change the value to whatever percentage you want your wheels to turn (max).

I m still trying to figure out why it won't balance itself though.
Pizzapie500 says: Aug 8, 2012. 5:41 PM
I know you put codes for controlling the overall gain, but which wires/pins do you connect the potentiometer to? My 10k potentiometer has 6 tabs on it (it's this one http://www.taydaelectronics.com/10k-ohm-logarithmic-dual-taper-potentiometer.html), will it work? Thanks
XenonJohn (author) in reply to Pizzapie500Aug 9, 2012. 11:34 AM
Need to go back through the Q and A here as nearly every question you could think of has been answered.

The latest attached codes have the overallgain coded in at the top. You do not need a potentiometer at all.

I would start with the simplest version that is steered by push switches, then get more advanced later once you have it balancing.

The IMU: I soldered ribbon cable to every hole, although at the arduino end of the ribbon cable, I only used some of them, i.e. the ones I needed.

I did this as the IMU was buried in centre of one of my boards and hard to get to. Seemed good idea at the time to solder a wire to every hole and just tidy away the ends of the ones I did not need in the end at the arduino end of things.

I have just bought a Replicator from Makerbot so would be cool to see if could print bracket that could suppport my weight.

Remember chain needs to be JUST slightly loose but not so loose it slops around else you will get juddering when trying to balance in one place. Wheel axle mounting points should not be flexible!

Best wishes

John
Pizzapie500 says: Aug 8, 2012. 4:35 PM
To help anyone looking for the screwdriver to disassemble the nunchuck, it's called a "Triwing Screwdriver". It looks like a regular phillips screwdriver, except it only has three points, sort of like a peace sign. The Triwing is only a dollar and free shipping on ebay.
Pizzapie500 says: Aug 7, 2012. 7:24 PM
Hi! I'm new to electronics and stuff, so this may be an "easy to figure out" question. Anyhow, how come in the picture, the gyro has nine wires coming out of it, but in the arduino connection diagram, the gyro is only connected to six ports? Is it connected to something else than the arduino?
Pizzapie500 says: Aug 6, 2012. 6:51 PM
Hey! I created a axle wheel mount just for this! http://www.thingiverse.com/thing:28090

I'm currently building this, but I didn't want to go through the hassle of working with the metal angle brackets, so I created a 3d file that can be printed out and used as a wheel mount. Specifically, it's measured for E100 Scooter Wheels, but you can change it however you like. I haven't tested/printed this yet, as my 3d printer kit just arrived, but is missing some parts. I will update when I do this (probably in a month or so).
Pizzapie500 in reply to Pizzapie500Aug 6, 2012. 6:56 PM
Sorry for the double post, but here's an image of it and some specs: The entire thing is 3/8" thick. I think this should be adequate if made out of ABS or other strong plastics. As I said, I didn't test this. If anyone tries it, please let me know! If it isn't strong enough, just take out the triangular hole in the middle of the side of the mount.
Wheel Mount.jpg
kevinsundar says: Jul 3, 2012. 8:53 PM
Hi John,
I really want to be able to ride on somewhat rough surfaces and go over small bumps like cracks in a sidewalk.

Could you recommend any small pneumatic wheels that would work with your instructions that could mount under the skateboard but not raise the board too high?

I am concerned that it will be to hard to balance otherwise.

Thank you.
XenonJohn (author) in reply to kevinsundarJul 11, 2012. 6:17 AM
Yes, the rear wheels from the razor e300 scooter have pneumatic tyres. They seem to come with 2 sizes of chain sprocket fitted, ideally you want the bigger sprocket for slower speed but more torque.

I have modded my board to take these now so I know they work OK.

they come with drum brake system fitted so you have to remove all this and I also shortened the axles with hacksaw and welded a nut onto the cut end.



mbril says: Jul 5, 2012. 1:47 PM
Do I need this and if so do you know where i can get it from?
mjg2381 says: Jun 30, 2012. 8:52 AM
Hi,

I have (2 )100W 24V motors from the E100 scooter, will these work instead of the 250W motors you used?
XenonJohn (author) in reply to mjg2381Jul 3, 2012. 2:39 PM
The first segway type machine by the sci-tech group in australia used 100watt motors from rear of scooters. They have a couple of instructables. So, answer is yes, at least on level ground.
mjg2381 says: Jun 30, 2012. 9:07 PM
If I wanted to make this a segway platform do I need to make any changes to the code? I would think there would be some changes in regards to the IMU since its position would be different.
durakes says: Oct 29, 2011. 11:01 AM
I have been playing around with your instructions, great job! I got to the point of testing the motors but when I load the motor testing code into the Arduino IDE I get a landry list of Java errors. Not being a programmer I seen to be dead in the water

Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at processing.app.Sketch.setCurrentCode(Sketch.java:1106)
at processing.app.Sketch.load(Sketch.java:218)
at processing.app.Sketch.(Sketch.java:140)...

Any Advice? Thanks
kevinsundar in reply to durakesJun 29, 2012. 10:00 PM
This is a somewhat old comment but it might help someone.

There is a forum here where a similar problem is discussed. The error that is being discussed starts with the same 4 lines. I am by no means an expert at Java but this may help someone:

http://arduino.cc/forum/index.php?action=printpage;topic=74944.0
kevinsundar says: Jun 24, 2012. 8:55 PM
Hello,
I am pricing my materials and was wondering what gauge wire do you recommend for connecting the batteries to the Sabertooth?

Thanks
XenonJohn (author) in reply to kevinsundarJun 27, 2012. 1:30 PM
At least as thick as wires on your motors, ideally thicker since you have 2 motors. Also make sure your main power switch is good quality.

I often use a double pole switch but wire up both sides in parallel to maximise the current carrying capacity.

John
kevinsundar in reply to XenonJohnJun 27, 2012. 7:59 PM
(removed by author or community request)
nimith says: Jun 21, 2012. 9:55 AM
Hi John,

Sorry to bother you for some question-

1, I did finished the board and 5 DOF and it seems work on the IMU test enter my new level Accsum as you recommend and IMU engaged

2. Moter test worked perfect with Dead Man swith when released then stop

3. Just Balance nothing happen?

I do not know what is wrong, any help please?

Thank you for helping

Nimith
XenonJohn (author) in reply to nimithJun 27, 2012. 1:38 PM
Note that I uploaded new version of the justbalance code quite recently.

In previous version the serial display was commented out. In this one it works and there are a few other things added that help with debugging.

John
nimith says: Jun 14, 2012. 10:22 AM
Hi John,

I just purchased the New replacement of IMU -5DOF from SparkFun and this one already have building Reg for 3v . Can I use the same code that you have ?

I believed the same of your configuration.

Thank
XenonJohn (author) in reply to nimithJun 21, 2012. 8:42 AM
I think it has its own built in voltage regulator.

I would check the data sheet but presumably you can run it from the arduino 5v line without blowing it up.

Check the datasheet first as the old one would definitely not work any more if you connected it to 5v supply. It would blow the gyro leaving you just with accel values!

John
nimith in reply to XenonJohnJun 21, 2012. 10:00 AM
I believed it said on the Sparkfun website

http://www.sparkfun.com/products/11072

Features:

Full Scale Gyro Range: 500°/s
Full Accelerometer Range: +/-3g
On-Board Voltage Regulation
Input Voltage: 3-16V
Analog Output
Breadboard Friendly


But I already connect with 5V from Arduino and got the Acc.

Nimth
cjustini says: Jun 16, 2012. 5:15 AM
Hi John,

I am going through the code slowly building up to the whole thing. One thing I am not quite sure how you got: why to you add up 7 readings for the gyros? Is this some sort of average, like the Savitsky Golay filter for the accelerometers?

Thanks!
XenonJohn (author) in reply to cjustiniJun 16, 2012. 3:42 PM
Came to 7 by trial and error. Actually if you take mean of more than this it has increasingly smaller benefit. I just take 7 readings very fast almost at the same moment.

Sav Golay filter was nicked (borrowed) from a self balancing "TOBB" robot built by a proper engineer (TOBB stood for Totally Overengineered Balancing Bot). Very interesting filter as does not cause the "delay" effect that a rolling mean filter would cause. Lets more of signal through, with no time lag, and removes more of the noise. Worth reading about online. Even used in software to predict behaviour of stocks and shares for similar reasons.
Accel signal is v noisy so I was looking at ways to filter noise out. We use gyro for short term corrections and accel for long term correction of gyro drift.


Note,
New version of "just balances only" code uploaded tonight.

John
cjustini in reply to XenonJohnJun 16, 2012. 8:45 PM
Thanks John, its very clear. I have managed to get an angle calculation using the gyro and accel combined, same method you suggest. However, I do not understand why we need a gyroscalingfactor, when in theory we are using the right units to get the angle... do you understand why this is necessary? Mine is closer to 3.0 rather than your 2.2.
XenonJohn (author) in reply to cjustiniJun 21, 2012. 8:39 AM
No idea either

If you hold machine level, then tilt it to say 10 degrees, the gyro rates of tilting added very rapidly together will give you a new tilt angle of about 10 degrees.

If you then hold it still at 10 degrees tilt, the accel will,fine tune the tilt angle.

So, if you tilt it fast to 10 degrees and it reads say 5 degrees, then slowly settles to a reading on serial display of 10 degrees, your gyro is underreading the rate of tilt and then the accel gently fine tunes it.

This is what was happening so I ended up with a gyroscaling factor. It only seems to be an issue with the 5 dof analog IMU. I have a newer analog 6 dof one and it does not do this, the scaling facor is set to 1 with that IMU.

I know Sparkfun have replaced the old 5 dof IMU with a new version due to filtering issues so maybe this is what they meant.

John
dreniles18 says: Jun 17, 2012. 6:23 PM
Hey john i got my "Segway" to balance on Friday [i got my steering to work perfectly so no need and fixing that]................ and i have been playing with it ever since but i still have some question.
1. i got it to balance but when i step on it and lean forward a little it goes but if i go any father i will fall off same for when i reverse.
..............( all weekend i have been tweaking mostly every value AND still didn't fix what i wanted to fix)


but if you cloud help me out on this i really would appreciate it

thank you

http://www.youtube.com/watch?v=ZnN9b7lUnyY&feature=youtu.be

http://www.youtube.com/watch?v=ontfrH56gxM&feature=youtu.be
pumo says: Jun 9, 2012. 6:53 AM
what does soldering bodges mean?
I did manage to build my segwayclone and now just doing testing with wheels off ground, but very strange is going on, motors drives full power from beginning, turning IMU wont do any slow down...
wondering, did I broke somehow my IMU
aniles jr says: May 28, 2012. 1:05 PM
i almost done i have everything together i did the imu test and the motor test and everything worked fine. but i tried to put the JUST BALANCE code on it and i followed the directions and wired everything up right but when i bring it to balance point and nothing happened i tried to open up the serial moniter and it is blank..............can you please help me my project is due on 5/31/12 thank you for all the help.
XenonJohn (author) in reply to aniles jrMay 29, 2012. 4:58 AM
send me a message with a working email in it and I will send you variations of the code to see where the problem is.

John
XenonJohn (author) in reply to aniles jrMay 29, 2012. 4:56 AM
er, you mean as in 3 days from now?

John
tranct says: May 18, 2012. 5:45 AM
Hi John,
I am a beginner. As I see on Ebay lots of Sabertooth >But they are not the same with yours -
Please, could you show me where to buy this one
Many thanks
TRANCT
XenonJohn (author) in reply to tranctMay 20, 2012. 12:27 PM
I googled "sabertooth 2 x 25 buy" and here are a few webstores it came up with:

http://www.robotshop.com/dimension-engineering-sabertooth-2x25-6.html

http://www.solarbotics.com/product/50120/

http://www.lynxmotion.com/p-623-sabertooth-2x25-regenerative-dual-channel-motor-controller.aspx

http://robotbits.co.uk/motor-drivers/sabertooth-2x-25amp-motor-driver/prod_62.html

John
tranct in reply to XenonJohnMay 23, 2012. 3:18 AM
Where can I find a complete list of all objets to buy ?
Thanks
TRANCT
XenonJohn (author) in reply to tranctMay 25, 2012. 7:49 AM
I didn't actually do one, naughty me.

Do it in stages.

Get mechanicals right: wooden board, brackets, motors, chains, Razor wheel sets.

Then start on electronics:
IMU
Arduino
Battery to power Arduino initially
Switches/buttons

Also need sabertooth motor controller and 2 x 12V batteries.

I would not try this as complete beginner. I would make some Arduino projects first so you are fairly familiar with how it all works.

tranct in reply to XenonJohnMay 23, 2012. 3:11 AM
Merci John
aniles jr says: May 4, 2012. 9:28 PM
In this code dose it have to highest the motors can go is 50%?


dreniles

thank you
XenonJohn (author) in reply to aniles jrMay 11, 2012. 2:14 PM
The code can be altered so the motor speed is limited to 50 percent. Buzzer can be added to give warning when power reaches any value you want to set.

I have done all these things with my own projects. However, purpose of this instructable was to keep thiings fairly simple, more complexity means more things to go wrong.

You have to get it balancing first, then you add in clever features afterwards.

John
aniles jr in reply to XenonJohnMay 12, 2012. 4:11 AM
thank you how long do you thing it will take me to get it to balence
XenonJohn (author) in reply to aniles jrMay 16, 2012. 4:25 PM
Took me 3 sleepless months first time around. I have saved you so much hassle.
If you follow instructable sometimes people get the IMU back to front and things like that. Should be pretty quick so long as no faulty components or dry solder joints, misaligned drive chains and so on.

The IMU tester and motor tester software examples are there to help spot some of these basic problems before you get to the first self-balance test.
aniles jr in reply to XenonJohnMay 17, 2012. 1:16 AM
i appercatie all your help john i cant thank you enough i did the motor test and the IMU test and it worked perfect. but when i let go of the kill bottom it stops hard when it post to go to the next % this is how it went 10.00 20.00 30.00 40.00 50.00 40.00( let go of the kill switch) and then finish with the 40.00 then is stops hard when you let go of the kill switch is it post to stop keep balancing?




Thank you very much
XenonJohn (author) in reply to aniles jrMay 5, 2012. 6:25 AM
In the motor tester sketch motor power goes up to 50% in 10% steps, it seemed safer that way.

In main code for balancing machine, it can go up to 100%.

aniles jr in reply to XenonJohnMay 8, 2012. 3:28 PM
For the main code can i limit it to 50%. and when im useing the POT to steer do i turn the POT to the middle and then turn left to right?
aniles jr in reply to aniles jrMay 10, 2012. 12:09 AM
and how do i wire the pot's
aniles jr says: May 10, 2012. 12:16 AM
two questions how do i wire the POT for steering and i want to limt my motors to go 50% is there a way i could put a buzzer for when it gose above 50%?

thank you
XenonJohn (author) in reply to aniles jrMay 11, 2012. 2:11 PM
Pot has 3 connections. Suggest using 10k Ohm pots. Connect 5V pin to one of the side connections, GND pin to the connector on the other side.

As you move the pot the middle connection is connected to the wiper of the pot that moves over the carbon track inside it. This middle connection is connected to the analog input pin of the arduino for that pot.

When knob is in centre position, 2.5V will be read at the analog input pin, i.e. a
value of about 512 on the scale of 0 - 1023. If you do not know what this means buy a starter book of Arduino projects as they all describe how to control a motor or brightness of an LED using a potentiomer.

John
aniles jr in reply to XenonJohnMay 12, 2012. 4:15 AM
thank you
pumo says: May 4, 2012. 4:47 PM
with motor testing did I something wrong?
without pressing deadmanswitch motors turns byself..
it logs level 10 without turning motors.
and when pressing button then motors wont even turn.
I did add 12k pulldown resistor also

ou are NOT Pressing Dead Man Button so all power has been cut
level 0.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
level 20.00
level 30.00
You are NOT Pressing Dead Man Button so all power has been cut
level 40.00
You are NOT Pressing Dead Man Button so all power has been cut
level 50.00
level 40.00
You are NOT Pressing Dead Man Button so all power has been cut
level 30.00
You are NOT Pressing Dead Man Button so all power has been cut
level 20.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
level 0.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
pumo in reply to pumoMay 4, 2012. 6:49 PM
I got wrong schematic (from Self Balancing Scooter Ver 2.0)
I did change for your connection deadman switch to pin 9 and thru 1,8kohm resistor to +5V now it works, kindof..
it spins motors by own and stops after all levels but if I push button down it runs thru all levels once from 0...50...0
not sure should it be like this, but I think it works :)
XenonJohn (author) in reply to pumoMay 5, 2012. 6:23 AM
Motor tester should go to 10% power, then 20% then 30% then 40% then 50% then 40% then 30% then 20% then 10% then round the sequence again.

Make sure wheels are going in same direction, if not one of your motor wires are back to front.
John
XenonJohn (author) in reply to pumoMay 4, 2012. 11:09 AM
Send me a private message with a working email address and we can correspond on this until problem fixed.

John
cjustini says: May 1, 2012. 12:40 PM
John,

First, thanks for contributing such a great project and providing so much help. Everything is pretty clear, i am buying parts and will get started in the next few weeks with my kids. My only doubt is around the batteries. You suggest somewhere using other than Lead-acid. I don't mind spending a little more if I can get better weight:power ratio, for example. Where can I learn about battery types, chargers, optimum charger procedures etc.?

Thanks, will send you pictures once done, and hope to "grow" with many ideas from this design.

Best.
XenonJohn (author) in reply to cjustiniMay 3, 2012. 10:59 AM
I used lithium iron phosphate battery 24V from an electric bike shop on ebay.
Lots of batty summaries and discussions on electric bike forums. Some ebike shop websites have battery discussions.

I would not waste 200 - 300 dollars on a battery like this though until you have your machine balancing on a couple of much cheaper lead acids.

I have also used 2 x 12v nickel metal hydride packs designed for large radio controlled racing cars in the past as well. These are not so far behind lithium these days but cheaper and the chargers are cheaper. Have to make sure they can give thie peak current your motors require.

Lots of online stores for RC car parts and battery packs to choose from. Also combat robot sites have battery packs in all shapes and sizes.

Hope this helps
John
Delpap says: May 3, 2012. 4:20 AM
Could you send the code please, my email address is: d.prajitno@gmail.com
Thanks
XenonJohn (author) in reply to DelpapMay 3, 2012. 10:54 AM
Code is attached in several versions to last few pages of this instructable
Jon
aniles jr says: Apr 29, 2012. 8:54 AM
i know this seems like a dum question but if i put two arduino boreds toghter would it go fast like will it give faster resuslts.


thank you
XenonJohn (author) in reply to aniles jrApr 30, 2012. 3:09 PM
One goes plenty fast enough

If you want one to run the self balancing and for example one to read a wii nunchuck you can do that. To begin with though you just want it to balance, add all the clever controls later in the V2 rebuild.
ld'sa says: Apr 22, 2012. 7:54 PM
Hi Xenon,

i am working on a self balancing bot
even i checked out this website

but i need help with the variables to take in order for my code to perform calculations
because it is a digital IMU (6dof) i am facing a lot of problems as i am a beginner. If you could help me out i am will to share my details with you so other guys can also use it for their projects

thanks
XenonJohn (author) in reply to ld'saApr 24, 2012. 12:40 PM
As beginner i would strongly suggest using analog IMU.
It looks as if sparkfun have released a new updated version of the 5dof one I originally used.
Would be worth getting one of those. There is also a clone on ebay of the original one still available, see some of discussions below for links.
Best wishes

John
ld'sa in reply to XenonJohnApr 25, 2012. 4:44 AM
I have only a week left to submit my project and also i am from India so it would not be possible to order another one from sparkfun.
If you could please provide me your assistance.
Thank You.
XenonJohn (author) in reply to ld'saApr 25, 2012. 3:04 PM
On page 53 I have put a code example as a starting point for the 6dof digital IMU. Totally untested.
However unless you are pretty good at programming, i.e. not a beginner, I cannot see how you would be able to work on this and get all the bugs out of the code within 1 week. Sorry but true.

I am happy to help people and have done several times, but I do have a day job so it is just whenever I have some free time. If it is a college project with a deadline, contact me well before the deadline!

Best wishes
John
ld'sa in reply to XenonJohnApr 26, 2012. 7:14 AM
yes i tried getting the code from page 53 but i couldn't get a link to download. could you help me on that?

And my project guide is helping us out so he would be able to fix the bugs as he has used IMU for some sort of robotic arms...
XenonJohn (author) in reply to ld'saApr 26, 2012. 1:13 PM
Hi,
Example (unfinished) of code to read the 6dof DIGITAL imu seemed to have disappeared from my instructable. I have just put it back as an attachment to Page 53.

Hope this helps. If your supervisor gets it to work please do let me see the improved code as others would benefit from it.

Best wishes

John
ld'sa in reply to XenonJohnApr 26, 2012. 7:21 PM
have one more doubt..

in your motor calculations the tilt angles and gyro rates passed are in degrees and degrees/sec respectively? or are they the raw values?
XenonJohn (author) in reply to ld'saApr 27, 2012. 11:05 AM
I get raw databthen convert to degrees for accelerometer values and degrees per second for gyros. Commented saying where I do this.

later on in the examples (not the only part finished 6dof digital example) I then convert to smaller values to get the scaling correct for the motor driver part of the software.
If it seems odd it is because the code has evolved by trial and error.

All the examples need a complete rewrite but on the other hand they do work as they are, which is always useful!

Best wishes
John
ld'sa in reply to XenonJohnApr 26, 2012. 7:06 PM
i will surely give you the resources to my project if it works even 50%

thank you
ld'sa in reply to ld'saApr 26, 2012. 7:09 PM
in a comment i seen you have mentioned to use a 2.2K resistor what is the reason for it?
i have used varesano's code for testing my IMU and they worked just fine without the resistors...


one more question..
does ur code have the kalman filter?
XenonJohn (author) in reply to ld'saApr 27, 2012. 11:10 AM
Some people ay if you are using I2C communication between an external device and Arduino you need two resistors, especially if the cable between device and arduino is long.
I did this with a WiiNunchuck for example and it did not work without the reistors. If yours works without then fine, go for it.

The Modified Varaneso software in my 6dof digital example on page 53 is I think a kalman filter.

All my working examples using the analog IMUs are complementary filters. I have rewritten one of these with a kalman filter and the machine balances worse than wheni I used the complementary filter so I have not posted it!

XenonJohn (author) in reply to XenonJohnApr 27, 2012. 11:20 AM
Sorry ignore last comment.
I used varaneso software to get me the angles, then i display them on serial view window and that is it. Have not added all the self balancing part yet from my previous code versions.
Angles are zero whe balanced, then go negative or positive depending on direction of tilt fro level position. Same for gyro except now they are in degrees per second.
ld'sa in reply to XenonJohnApr 28, 2012. 5:12 AM
ok so i pass those angles and gyro values into the old code and hope that it works?
yes i also went thru the schematics and they have included on board resistor...
but thanks for the info...

it will stay in my head
XenonJohn (author) in reply to ld'saApr 28, 2012. 12:57 PM
In theory yes!

You will not need the gyro scaling factor in old code, just remove it or set it to 1

Best of luck

aniles jr says: Apr 21, 2012. 4:59 PM
Were should i place my gyro im almost done :D
XenonJohn (author) in reply to aniles jrApr 24, 2012. 12:38 PM
In theory gyro should be in centre but in reality it does not matt that much. See the segway builds on instructables by the scitech group in Australia
aniles jr in reply to aniles jrApr 21, 2012. 5:07 PM
2012-04-20 08.50.05.jpg
aronzitti says: Apr 15, 2012. 2:02 PM
Hi,
for set the accsum variable
i have insert in the foot of Setup() subrutine:
Serial.print("Setup:");
delay(3000); //3 sec delay
digitalWrite(beepPin, HIGH); delay(100); digitalWrite(beepPin, LOW);
for (int i=0; i < 50; i++){
fSetup += analogRead(accelPin); //read the accelerometer pin (0-1023)
delay(1);
}
fSetup /=50;
Serial.println(fSetup);
Serial.print("Start");
----end-----
XenonJohn (author) in reply to aronzittiApr 20, 2012. 12:43 AM
That does make more sense. I am working on a new project where I have added a $2 piezo buzzer. If you have a buzzer it is also very good to make the time delay between each beep proportional to (i.e. a multiple of) the measured tilt angle, in the tipstart routine. This means as you first bring it level after turning machine on, the beeps become faster and faster so you know exactly when the tiltstart is about to go active (continuous tone).
pumo says: Apr 13, 2012. 11:53 AM
I dont understand, is there something wrong with my connections or what.
(I have this ebay clone board)
when starting serial monitor there isnt any accsum number, or any even readings nearby 338

TILT-START ENGAGED
3,9\n
balancegyroDegrees:-6.84 accelDegrees:7.88 overallAngleofTilt:-1.263,10\n
balancegyroDegrees:-8.92 accelDegrees:5.17 overallAngleofTilt:-3.173,10\n
balancegyroDegrees:-58.72 accelDegrees:13.55 overallAngleofTilt:-14.824,9\n
balancegyroDegrees:-9.22 accelDegrees:12.48 overallAngleofTilt:-15.913,9\n
balancegyroDegrees:-9.38 accelDegrees:12.07 overallAngleofTilt:-16.614,9\n

pumo in reply to pumoApr 13, 2012. 12:12 PM
and upside down two holes nearest to ground readings are
TILT-START ENGAGED
3,9\n
balancegyroDegrees:-5.53 accelDegrees:-2.42 overallAngleofTilt:4.173,8\n
balancegyroDegrees:5.46 accelDegrees:-3.45 overallAngleofTilt:2.433,9\n
balancegyroDegrees:3.69 accelDegrees:-7.02 overallAngleofTilt:2.123,9\n
balancegyroDegrees:12.53 accelDegrees:-1.72 overallAngleofTilt:1.163,9\n
balancegyroDegrees:22.67 accelDegrees:0.82 overallAngleofTilt:2.714,8\n
XenonJohn (author) in reply to pumoApr 14, 2012. 3:36 PM
These look OK.

I have uploaded slightly tweaked version of the IMU tester. It will now show accsum in serial view window (it was commented out).

Best wishes
John
XenonJohn (author) says: Apr 14, 2012. 3:17 PM
Good news.
Sparkfun have released an updated version of their 5dof analog output IMU.

IMU Analog Combo Board - 5 Degrees of Freedom IDG500/ADXL335

Part number SEN-11072
So, everything is OK again.

John
pumo says: Apr 11, 2012. 12:52 PM
I got today ebay 5dof, I try to find time tomorrow night so I'll post here did it work with imu test.
one question do I need anymore those pulldown resistors to digital input?

there have been replacement for 5dof from sparkfun :http://www.sparkfun.com/products/11072
XenonJohn (author) in reply to pumoApr 13, 2012. 6:49 AM
If you alter code slightly you do not need the pulldowns.

Essentially you set the internal pullup so it is HIGH and pulled up to 5V.
The pushbuttons then connect the digital pin to ground(GND) i.e. pushing button pulls the pin down to 0V.

Best wishes
John
pumo in reply to XenonJohnApr 13, 2012. 11:31 AM
thanks I try (I am newbie with arduino) :)
just tested IMU tester code with ebay clone 5dof works!
E1024d says: Apr 8, 2012. 6:34 PM
I saw every programs star with #include
but I didn't find "SoftwareSerial.h".
where can I find it.And If I should put it in sketch libery or somewhere else?
Thanks
XenonJohn (author) in reply to E1024dApr 9, 2012. 2:34 PM
Hi,

When you download the Arduino programming environment, softwareserial is a library that should come with it, built in.
It is a bit of code that allows you to send serial commands using any of the digital pins on the arduino.
It is standard with all versions of Arduino beyond V6 so should not cause you any problem.

More:
http://arduino.cc/hu/Tutorial/SoftwareSerial

Best wishes
John
aniles jr says: Mar 28, 2012. 8:04 PM
can i use The E150 motor that seems to use 10 Amps. http://ampflow.com/ampflow_motors.htm with this motor controller http://www.dimensionengineering.com/Sabertooth2x60.htm and two 35ah batterys please HELP ME
XenonJohn (author) in reply to aniles jrMar 30, 2012. 7:04 AM
Hi,

I have been answering your numerous questions now for over a year.
The answer to this particular combination you have given me is yes, probably will be OK.
The Ah of your batteries reflects how long it will run for. You also need to know what maximum current is that it can deliver in a short burst. If you have 2 motors drawing 10 Amps then battery has to be able to provide 20 Amps at least for a short while such as when going up a hill.
Motor controller has to also cope with 2 x 10 Amps if using two 10 Amp motors.

Therefore, with two 10Amp motors, you would only need a 2 x 25Amp Sabertooth for example.

You have to match all 3 components to each other and make sure motor controller has some spare current handling capacity to reduce risk of meltdown under high loads (remember if you hold your 10Amp motor stalled, it will draw way more than 10 Amps).

Time to have a go and build something. Go for it.
aniles jr in reply to XenonJohnApr 1, 2012. 12:10 PM
thanks but would it be better if i got the 2x25 amp sabertooth because im just sarced that my motors will burn out (can you just help me out on this one because this poject needs to be done before 5/30/12) SORRY FOR THE BOTHER
XenonJohn (author) in reply to aniles jrApr 2, 2012. 2:44 PM
Watts = Amps x Volts
If your motors are 10 Amp at 24V then they are about 240 Watts each.

A 2 x 25Amp Sabertooth would be fine.

Motors will not burn out. If you put 24V across them and they are 10 Amp 24V motors, then they will draw around 10 Amps. The Sabertooth does not try to "force" 25 Amps into each motor. The motors draw the current they require from the battery, the Sabertooth regulates that so that they do not just run flat out all the time. The thing that might burn out is usually the motor controller if the motors are held stalled - when they will then draw much more than 10 Amps.
However the Sabertooth has protection circuits that will shut it down if too much current draw through it.

If your motors are 10 Amp then you could even use the smaller Sabertooth.
aniles jr in reply to XenonJohnApr 3, 2012. 5:13 PM
i cant thank you enough

But i decided to keep the 2x60 and im going to get a bigger motor that peaks at 2.3 horse power and the amps are 28 and its rpm at 24 volts is 6900 the only thing i need to find out is what tooth sprocket do i need to attach to the wheel the diamter of my wheel is 14 in. So can you work with me to find that out

Thank You
XenonJohn (author) in reply to aniles jrApr 4, 2012. 1:59 PM
You need low speed high torque, not high top speed, at least initially when developing and learning.

Use a big sprocket on your wheel say at least 6 times as many teeth as on your motor sprocket, or maybe even more. My original monowheel board had a sprocket on the wheel that was almost the same diameter as wheel/tyre itself, only slightly smaller.

Best wishes

John
XenonJohn (author) says: Apr 3, 2012. 2:50 PM
Clone of Sparkfun 5dof IMU found on ebay:

GOOD NEWS EVERYONE
This clone IMU on eBay looks exactly like the SparkFun 5dof analog output IMU that they have now discontinued. Price is good too.

http://www.ebay.com/itm/190478609162?ssPageName=STRK:null:IT&_trksid=p3984.m1542.l2649


This may help a few people.

John
pumo says: Mar 29, 2012. 10:56 PM
Does this code work with old IMU also ?
and is there link for right 6dof IMU, I found one but its also retired.
or should this work http://www.ebay.com/itm/190478609162?ssPageName=STRK:null:IT&_trksid=p3984.m1542.l2649?
XenonJohn (author) in reply to pumoMar 30, 2012. 6:59 AM
Code is written for the old 5 DOF IMU with analog outputs but nobody can find one for sale any more.

This is why I attached a version of the code for a 6DOF "Razor" analog IMU which is being discontinued but some stores still have a few in stock (be prepared to buy from anywhere in the world).

I am currently working on code for the 6DOF DIGITAL IMU from sparkfun as soon this will be the only one you can buy.

Best wishes

John
pumo in reply to XenonJohnMar 30, 2012. 7:55 AM
Thanks for your help and info, I did order that 5dof version from ebay if it wont work I just have to find 6dof analog.
Or if no luck with that I just wait your 6dof digital version code...


br
Pumo
BuildWiz says: Mar 25, 2012. 9:33 AM
Hi! I was just wondering if it was possible to use two motor controllers for this? and if so how would you connect them? I was looking at this one: http://www.robotshop.com/dimension-engineering-syren20-4.html.

Thank you,
Nick
XenonJohn (author) in reply to BuildWizMar 26, 2012. 11:14 AM
You can definitely use one syren so can probably use two.

Would have to set up another pair of pins as serialports for the second syren as I currently have for the saberserial.

Would then send all motor1 output to syrenserial1 and all motor2 output to syrenserial2

Dont really have time to write it and debug for you but that would be the general idea.

Best wishes

John
Nikotine says: Mar 19, 2012. 1:37 PM
Hi! Amazing build log!
I found a website where you can buy Razor parts (razorama.com). They sell three kind of rear wheel assemblies, for different versions of scooters. Does it matter which one to get? Will the teeth on the sprocket match the one on the motors you find on ebay?
XenonJohn (author) in reply to NikotineMar 19, 2012. 4:37 PM
The chain driven E100 scooter rear wheel (solid tyre as in this instructable) and the E300 rear wheel (small pneumatic tyre as in example shown near end of this instructable) both use the same chain type.

The Chinese electric motors sold as "scooter motors" have sprocket on them which fits this chain.

So, not sure what the 3rd type of wheel is but certainly for 2 of them the chain is the same type.
Nikotine in reply to XenonJohnMar 20, 2012. 3:13 AM
Hi XenonJohn, thanks for the quick reply!
Well, there's three types, depending on the version E100 you have.
See this page: http://www.razorama.com/e1scpa.html
The page doesn't say what the actual differences are between versions... Only that you should pick the right version or it won't fit, so there must be differences...

Perhaps I will buy bigger wheels like these: http://www.razorama.com/e300rearwheel.html
For doing a bit Segway off-roading :-)
skynard says: Mar 1, 2012. 12:43 AM
Hi XenonJohn!

Would the razor e100 chain driven wheel fit onto a Razor E300 MOTOR ST09 (24v 280 W) instead? Does the sprocket size fit towards each other ?

link for the motor http://www.ebay.com/itm/360430118675?item=360430118675&viewitem=&sspagename=ADME:L:OC:MY:1123&vxp=mtr

Thank you.


sincerely,
han
XenonJohn (author) in reply to skynardMar 19, 2012. 4:38 PM
Yes I think chain is the same type.
schabanow says: Feb 21, 2012. 3:48 AM
> Gyro is L3G4200D, Accel is LIS331DL from ST.
Both are of 3-axis and I2C.

XenonJohn wrote> I can search the web, find some code examples and supply a draft (untested) version of my code so one of you guys with the new 6DOF digital imu can test it out.
Yes! Would you please to do it for us as well? Let's come together - hardware enthusiasm and software experience! ))

Alex.
XenonJohn (author) in reply to schabanowMar 8, 2012. 3:16 PM
Hi Alex

If you want to have a go with the 6dof DIGITAL Imu from Sparkfun, then here is some code.

Only tested as a sensor / arduino combo so far but all the values it gives look about right so is a reasobale chance it will self-balance.
I have built it into my existing code for the rocker switch/button controlled self-balancer.

Attached to page 53 of my Instructable.above.
http://www.instructables.com/id/edit/?instructableId=E3C1NR6G6MPQ5EM#instructableId=E3C1NR6G6MPQ5EM,stepId=SZGO7T3GZKE1JXL

John
schabanow in reply to XenonJohnMar 9, 2012. 3:02 AM
> Attached to page 53 of my Instructable.above.

Hi John! Thanks for the link, I've posted it at our forum; hope it will turn to be appreciable one.

Alex.
ps: It's a pity but I have no news on sbj from our community yet.
XenonJohn (author) in reply to schabanowFeb 22, 2012. 4:06 PM
I have just obtained a Sparkfun 6dof Razor analog IMU board. It works fine but scaling constants have to be altered a little.
This is only a stopgap as although many places still have it in stock, it is also being discontinued.

To get an arduino to read data from the Sparkfun 6dof DIGITAL IMU, this website is the place to start and they have sample code:

http://www.varesano.net/blog/fabio/my-first-6-dof-imu-sensors-fusion-implementation-adxl345-itg3200-arduino-and-processing?page=2

If somebody who really understands I2C communication can write a well commented sketch that gets the arduino to read the accel angles in degrees and gyro rates of angular rotation in degrees per second from this IMU, it would very helpful to everyone else as all the IMUs now slowly seem to be going digital.

Anyone out there want to have a go? I for one would appreciate it.

John
free2flyus in reply to XenonJohnMar 4, 2012. 3:27 PM
hello john, where did you get the 6dof razor analog imu? can you send me the store name... thanks...
XenonJohn (author) in reply to free2flyusMar 5, 2012. 3:41 PM
You could try these, they are UK stores:

http://www.hobbytronics.co.uk/6dof-imu

http://www.skpang.co.uk/catalog/imu-6dof-razor-ultrathin-imu-p-594.html

This shop may still have some 5dof analog sensors left by the look of things:
http://www.active-robots.com/shop-by-brand/sparkfun-electronics/sensors/imu-sensors

John
free2flyus in reply to XenonJohnMar 9, 2012. 9:17 AM
thanks john... got one from skpang.co.uk
schabanow in reply to XenonJohnFeb 24, 2012. 5:00 AM
Unfortunately I'm not a programmer. But I'll ask my guys - maybe one of them will find some spare time to help us. What kind of sketch do we want to see? Exact one for your model, or principal well commented frame code for all I2C-compliants?
XenonJohn (author) in reply to schabanowFeb 24, 2012. 10:34 AM
Hi, if you can do this it would be great for all self-balancer builders and worth putting on one of the Aduino forums as well.

We do not need all the data from all 3 accels and all 3 gyros to self-balance, but if writing a general purpose sketch you might as well read all of them.

Basically you would want 3 variables x_acc, y_acc, z_acc which vary according to the output from each accelerometer.
Currently with analog output IMU's you get
i) a low voltage output when each individual accelerometer is held upwards relative to (downward) force of gravity,
ii) a high value when held downwards relative to force of gravity, i.e turned 180 degrees from the previous position and then
iii) a mid-value when held horizontal
These are on the scale 0 - 1023 at present as we use the analog inputs on the Arduino to read the voltage from each axis of the IMU.

We then have 3 more variables: x_gyro, y_gyro and z_gyro.
These give an output proportional to the angular rate of turning in the plane of each gyro.
When stationary the gyro ouputs a middle value. When rotating clockwise it increases and when actively rotating counterclockwise it decreases by an amount proportional to the angular rate of turning, eg degrees per second. The ideal units here would be degrees per second, -ve values being counterclockwise rotation, zero being no rotation and +ve values being clockwise rotation.

To be honest though so long as the arduino can read the data, these scaling issues can be sorted out later if necessary.

It would be nice to have one for all I2C compliants but for now the 6dof Sparkfun one seems to be the lowest priced one that people will use for next year or two.

If you need more dof than 3 accels and 3 gyros, then you are entering DIY drone territory not just self-balancing!

All hobby IMU's will be digital soon so this is worth doing for the whole Arduino community. Hope you can manage it.

All the best
John
schabanow in reply to XenonJohnFeb 24, 2012. 12:09 PM
I see. I'll try to do sth.
XenonJohn (author) in reply to schabanowMar 8, 2012. 3:17 PM
Example code (not fully tested) for 6dof DIGITAL Sparkfun Imu attached to page 53 of my Instructable.

John
schabanow in reply to schabanowFeb 24, 2012. 11:39 PM
Here some Arduino--I2C' videolessons for the meantime - I'm sure you can find these without Russian audio: http://www.youtube.com/watch?v=RcAg9XpgALI
schabanow says: Feb 21, 2012. 3:26 AM
Hi XenonJohn!

We're at the very beginning of our long way to balance )) with our DIY IMU-shield for Arduino Uno platform. Some pictures are below.

Gyro is L3G4200D, Accel is LIS331DL from ST. Few days ago we already get raw data from both of them and last week we're just almost in heaven. )) Yes it is, but yesterday I came to conclusion we have to go further. Some googling - and I'm here!

1. What can we do now in order to build our table-top little balancer (not skate-like)?
2. Does your code work properly in conditions when Z (vertical) acceleration work? In other words - will your skate keep its balance been put on the plain and smooth but VERTICALLY MOVABLE surface?

Sincerely,
Alex and Alex.
accel_x_vs_y_rotation.png1.jpg2.jpg3.jpgaccel_3_axis.png
XenonJohn (author) in reply to schabanowFeb 22, 2012. 3:56 PM
I may be wrong here but as I see it:
Gyro responds to angular rate of rotation and is vibration insensitive so that should still work fine.
Accel will alter its readout while flat surface on which machine rests is actually moving upwards or downwards, but not when it has finished moving up or down.

Input from accel is used to correct gyro drift over time so if small movements of the table top occur that do not last very long, then it will probably waver but tolerate it. If tabletop up/down movements are regular then they may well cancel out allowing accel to do its job. If they are random - not sure what would happen.

The answer is that short term balancing mainly taken care of by the gyro so small pertubations may be tolerated.

Q: Why is your surface moving up and down anyway?
schabanow in reply to XenonJohnFeb 24, 2012. 2:28 AM
Q: Why is your surface moving up and down anyway?
We gonna make a model of A-4 rocket with gimballed motor. Extremely slow and due to this - REALISTIC vertical lift-off during approx. 10 sec up to the height about 20 .. 30 meters. And then rescue with a parachute.
XenonJohn (author) in reply to schabanowFeb 24, 2012. 10:52 AM
Cool - as in the A4 rocket otherwise more well known as the V2?

http://www.youtube.com/watch?v=iCEEukiUTsA

Of course some men in grey suits might turn up and persuade you not to.

I can think of some politically incorrect names for your Arduino shield.

Another application would be to control inherently unstable model RC aircraft such as an exact copy Wright Flyer.

I think it would be OK but will chat with a friend who knows all the maths around attitude measurement.
John
schabanow in reply to XenonJohnFeb 24, 2012. 12:05 PM
A4 becomes V2 afterwards. A4 - rocket of human genius, V2 - its dark side, slaughter, nazi, and so on... Human history is full of paradoxes.

As for "grey suits" - we live here just in wonderland where you can found yourself in cell for million causes, so A4' model doesnt gain or diminish anything to your karma. Relax. ))

No "another application". A4 only. My dream. ))
XenonJohn (author) in reply to schabanowFeb 25, 2012. 9:44 AM
Another site / sensor to look at for your rocket is the ArduIMU from DIY drones.

It uses I2C I think again and they have link to sample code towards bottom of this web page:
http://unmannedtechshop.co.uk/ArduIMU-V3-Arduino-9DOF-IMU

Again, looks way too complex for me, it seems to do almost everything except make you a cup of coffee as well. All I want is a not-too-enormous block of code that gets me the raw data from the 3 accels and the 3 gyros.

On subject of a related paradox: I read an obscure book recently showing how an engineer who worked on the pulse jet of the V1, especially the shape of the exhaust, crucial for pulling more air into the front end, "ended up" working for MZ motorbikes in East Germany making exhausts for their unfeasibly powerful small racing engines. He then defected, went to Suzuki and shortly after that Suzuki starting winning world championships. Similar (and very noisy) extractor exhausts can be seen even now as aftermarket add-ons for small scooters.
schabanow in reply to XenonJohnFeb 25, 2012. 12:03 PM
> All I want is a not-too-enormous block of code that gets me the raw data from the 3 accels and the 3 gyros.

Well, should I give you those sketches we used to get diagrams above??? For I suspect my amigos are too busy amigos ))  to help us with special tutorials on I2C now. Can you edit all the proper addresses and register' names according to your actual hardware?

Concerning MZ - very interesting... Kurt Tank turned out to be much less successfull with his post-war jet-fighter in Argentina. MiG-15 - Soviet compilation of german war-time projects... Many revelations of that sort became well-known to public nowadays here in ex-USSR.
schabanow in reply to XenonJohnFeb 25, 2012. 11:26 AM
(removed by author or community request)
schabanow in reply to schabanowFeb 25, 2012. 12:06 PM
> http://unmannedtechshop.co.uk/ArduIMU-V3-Arduino-9DOF-IMU
Crooked link I'm afraid... :( "Cannot be found" - I'll try it again later...
XenonJohn (author) in reply to schabanowFeb 25, 2012. 3:01 PM
Hi again,

I think I may have found what I need here. Near top of blog are 4 code examples. 2 of them seem to read the Sparkfun 6dof digital IMU and gives raw values for the 3 accels and 3 gyros.

http://www.varesano.net/blog/fabio/my-first-6-dof-imu-sensors-fusion-implementation-adxl345-itg3200-arduino-and-processing

I will try modifying one of these and see how I get along.

Best wishes

John
free2flyus in reply to XenonJohnFeb 28, 2012. 8:15 PM
best thank to you john... i am looking forward for the code coz the 6dof (analog) is gone in the market..
webber99 says: Feb 8, 2012. 9:29 AM
Hello guys,

i'm webber, a newbie to arduino and IMU stufss but i'm trying it for my hobby. My question is this, will the code still gonna work if i use different IMU board, because the IMU board used here is already out of stock. i hope someone could answer me, i already bought IMU Digital Combo Board - 6 DOF (ITG3200/ADXL345) from sparkfun. in case the code will not work, what should i study to make it suitable for the IMU board? thanks in advance and more power!
XenonJohn (author) in reply to webber99Feb 18, 2012. 8:22 AM
The old boards were analog, i.e. they put out a varying voltage to each of your arduino analog input pins, nice and simple to just read voltage on each pin.

However newer ones seem to have digital outputs so my code examples will not work without some code alteration to read the digital data coming from the IMU.

I can search the web, find some code examples and supply a draft (untested) version of my code so one of you guys with the new 6DOF digital imu can test it out.

Keep an eye on page 1 of the instructable as I will put a note on page 1 if I do manage to find some time to do this and attach a code example.

Best wishes

John
justinpruss says: Feb 11, 2012. 9:02 AM
Here's a good one....Anyone have an issue with 24v?

I'm using a SyRen 25 (just one motor) and when I use 12v I see a small kick at start-up and then its fine.....tiltstart works and etc.

When I use 24v instead of a small nudge, the motor just takes off.....any ideas?

I have 12v going to the arduino (freeduino 1.2) and the imu is getting 3.3...not sure what is going on.
gerrymazzotta says: Feb 1, 2012. 3:23 PM
Hello, I'm very surprised by what you managed to do, congratulations. Inspired by your project I would also like to realize in my school in Italy, however, starting from a lower level until you get to 'self-balancing. The problem that I know basicstamp parallax. I have a problem in programming arduino 2009 to perform simple movements with this yojstik http://www.robotstore.it/product/293/Shield-Mini-Joystick-resistivo.html.
The two motors (left and right) should say:
- Both forward (acceleration ramp%)
- Both backward (with ramp acceleration%)
- Turn right (starboard engine spins up)
- Turn left (turn left engine plane)
- Do you reverse right or left (respectively, the engines run against each other).
I use two 180w 12V motors
Sabertooth
Arduino 2009
yojstik assembled on Arduino as links.
I suppose you are super busy but I'd be very grateful if I persuades a tip on the Arduino programming and electrical connections.
PS: I build the vehicle has two front wheels and rear swivel type robots.

Sorry so much for English .... I'm Italian!

Hello and see you soon!
TigrisLi says: Jan 28, 2012. 5:24 AM
Could you give the names of all the parts please?
Thanks!
dariokristo says: Jan 16, 2012. 5:06 PM
Hello everyone,
For people who are interested in making a remote controlled two wheeler, check this out:
http://www.youtube.com/watch?v=Yjsp1-DrsHI&feature=plcp&context=C3c668efUDOEgsToPDskIjtX14x24OF2K3_r7mJgcn
looking4ideas says: Jan 4, 2012. 6:13 AM
Howdy! ,
I have just recently tackled this project to use daily taking me to and from class. However i was wondering if this system is stable enough for daily use or just time to time to show off to your friends.. I will be using 2x 300W motors instead of 250.

You can fallow my project at www.aggiespaceprogram.com

Gig'em
XenonJohn (author) in reply to looking4ideasJan 15, 2012. 4:32 PM
Hi,

Good luck with the project. All depends on how smooth the paths are at your college. If very rough use the E300 wheels with pneumatic tyres (note they seem to come with 2 different sprocket diameters depending on the website you look at).
It is stable enough otherwise. Check out video No.9 on the front page of this instructable. His has 300 or 350 Watt motors and lithium batteries.
Make sure your deck is thick enough wood/metal so it doesn't bend under your weight and slacken off the drive chains.....this adds unintentional instability!
John
Curtis 109 says: Jan 8, 2012. 1:15 AM
Hi, I was very impressed with the self balancing skateboard and I thaught I am going to build one but as a segway, I used the same parts just put the wheels further appart and fit a handlebar. So far so good the IMU test worked out good it leveled at 340 which is close to Johns recommendation of 338, the motor test is perfect.
with the balance test I seem to have problems, I lean it forward count to 5 then activate the deadman switch and slowly bring it level and just as it gets level the tiltstart kicks in but it doesn't selfbalance at level the motors stop if I tilt it slightly forward the motors move forward if I tilt it back the motors reverse and the more I tilt it the faster it will go, of course let the deadman switch go everything stops.
What am I missing out on? I,m not a programmer nor have I an oscilloscope.
Any help would be much appreciated.
XenonJohn (author) in reply to Curtis 109Jan 15, 2012. 4:24 PM
Hi,

Jan 15th 2012
I have attached new sketches in addition to the old ones to pages 43 to 47. Old ones ran in Arduino 22. Latest version of Arduino environment is V1.0 and it has a different sofwareserial library and commands.
New sketches same as old ones but
a) Run in latest Arduino V1.0 and
b) Have the bug fixed regarding orientation of the accelerometer (I think).

John
dariokristo in reply to Curtis 109Jan 8, 2012. 3:52 AM
Change this line of code: x_accdeg = (float)((accsum - (338 + balancetrim))*0.862); //approx 1.16 steps per degree so divide by 1.16 i.e. multiply by 0.862 with,
x_accdeg = (float)((accsum - (340 + balancetrim)) * (-0.862)); //approx 1.16 steps per degree so divide by 1.16 i.e. multiply by 0.862. We actually use -0.862 as accel is wrong way around relative to gyro.

It should work.
Curtis 109 in reply to dariokristoJan 9, 2012. 1:58 AM
Thank you heaps dariokristo, it is balancing now all I have to do is to adjust the take off speed as present it is taking off too quick when I only give it a slight tilt.
dariokristo in reply to Curtis 109Jan 9, 2012. 4:54 AM
Again, try changing this:
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
with this:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);

Cheers
XenonJohn (author) in reply to dariokristoJan 10, 2012. 3:21 PM
Hi folks,

Sorry about this bug.
If your board powers up when roughly level (i.e. tipstart becomes active) then tries to balance but with a balance angle that gradually drifts (i.e. it leans more and more to one side while still balancing OK) it means the accel is not correcting for the inherent drift in the gyro and is acting in wrong direction.

Remember, the gyro corrects small instantanous wobbles of the board while the accel slowly, over a long period, gently corrects the drift in the gyro zero point. This is why, with the above accel fault, it self balances OK for a few seconds but at a gradually changing angle.

This is why changing this:
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
to this:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);

usually fixes the problem.

I will do a comprehensive code revision soon as I am still working on similar machines and still learning all the time. The code here evolved by months of trial and error and really needs a full rewrite!

Arduino sketches exist to "read" data from arduino nunchucks. I have even done an instructable on that. If anyone has the time to merge it with the self balancing code, and get it all to work, please go ahead. I am just short of time to work on these things right now.

John
tracer11lb says: Jan 11, 2012. 12:17 PM
Hi,

I know its been awhile since the last comment but I was just wondering if I can use a motor with built in motor controller? thanks
XenonJohn (author) in reply to tracer11lbJan 15, 2012. 4:20 PM
Hi,

Motor with a built in controller could be used if arduino can talk to the controller OK.
Remember it has to be able to go from forward to reverse with no delays or problems. Also need high torque ideally.
However the motor web page you gave me the link to shows brushless servo motors with integrated encoders (position encoders). These tell an external brushless motor controller how to turn the motor.
I could not see one there with a built in motor controller.

I have stuck to brushed motors with robot H-bridge controllers for now as brushless controllers seem more complex to get control of with an Arduino board.

If anyone knows how to reliably control an affordable hubless motor controller with an Arduino I would like to know as then I will get a 1000Watt Chinese e-bike wheel with brushless pancake hub motor and build a self-balancing unicycle!

John
tracer11lb says: Jan 11, 2012. 12:43 PM
sorry here is the link of the motor I want to use

http://www.teknic.com/products/servo_motor.php
mgrachev says: Oct 3, 2011. 8:40 AM
Hello! I don't have an oscilloscope, how can I measure the cycle_time? Thanks. I'm trying to use your code on an Arduino with Lego and some servos, but I have to tweak the Motor output signals. Thanks for the help! Awesome instructable btw
XenonJohn (author) in reply to mgrachevDec 7, 2011. 3:05 PM
Hi,

The code unlike earliest versions now has a timekeeper routine added.
This works out how long one cycle of the program loop has taken in milliseconds, then adds a variable delay so that the overall loop time is 10 milliseconds. This means program will loop round at 100 times per second so long as it is not so unwieldy that just doing all the calculations takes more than 10 ms.

Therefore the code that sends a pulse out to an oscilloscope is there just so you can double check how fast the program is cycling. Not actually required for the setup process so long as code all working properly.

BeerBellyJoe says: Dec 6, 2011. 8:04 PM
Looks like Universal Pictures likes The THING you built!

Check out the scooter the boy is riding!
http://movies.yahoo.com/feature/lorax.html?showVideo=1#theatrical
XenonJohn (author) in reply to BeerBellyJoeDec 7, 2011. 2:59 PM
I like it.
Wish I could ride mine in real life as well as he does in this cartoon!
dhteam says: Nov 8, 2011. 12:41 AM
once again thanks for your insight in regards to my question before about running from a power supply as well as the usb cable in the tuning stages my self balancing scooter has come a fair way since then but ive hit a small problem and was wondering if u had any suggestions to help me out ???

here is a link to my board running : http://www.youtube.com/watch?v=s9WJ29vczaU

the problem im experiencing is the shuddering in the entire board when changing from forward to reverse or reverse to forward , im pretty stuck im thinking its a program fault , maybe when changing directions i need to add a delay or a way to ramp power up, any guidance would be much appreciated
XenonJohn (author) in reply to dhteamDec 7, 2011. 2:52 PM
Hi,

I get this if the chain is a little too slack in my drive system plus the overall gain is too high.
In the wheelchair mechanisms you have, there is a little backlash in the gears. You get rattles around the balance point when stationary, as motors flip from forward to reverese and back, these are transmitted into the gyro/accel unit causing more trouble.

When rolling along you do not have the problem as motor controller is not reversing direction, just providing variable forward power.

3 possible solutions:

Let us imagine you calculate a torque value to send to each motor and then you multiply that by a value called "overallgain"
Options:
a) Reduce your overallgain.

b) Let us imagine the range of torque values that can be sent to each motor is
-100 to +100 (zero being stationary), then when the value is between say -4 to +4, then within this range reduce the overallgain to half what it is otherwise.

c) Make the overallgain value increase proportionally to the desired torque value in each direction (so it is low around the mid i.e. stationary balance point).
Actually might be better to make the overallgain a low fixed value, than ADD to that a small additional value proportional to the torque (which has a maximum possible value about the same as the baseline fixed value it is added to).

I think these would help. Need to do some experiments but b or c might be the things to try out.

Best wishes

John
dhteam in reply to dhteamNov 15, 2011. 6:44 PM
i helped reduce this problem significantly by having overall gain relative to angle of the board, still not great but better result.
karotSunoe says: Oct 23, 2011. 2:54 PM
Hello John..

I used this code for my try.
I got the tilt started point.. But the skate can't balance properly.It's look like week and the deck slowly drop.
The skateboard just go away slowly (the skateboard can't stay)..But when I push the deck, the motor still work to get the balanced.
So, what part of the code that can I adjust?
Thank you...
XenonJohn (author) in reply to karotSunoeNov 15, 2011. 3:22 PM
Just to report........... I looked at the video he sent me and we did sort it out.

John
XenonJohn (author) in reply to karotSunoeOct 26, 2011. 12:47 PM
Hi,

Send me a message with a working email and I will correspond directly with you.
Make a video of it, put it on youtube for friends only, send me the link. I can tell a lot by just looking at how it behaves.

Best wishes

John
bschulth says: Nov 6, 2011. 1:13 PM
Has anyone updated this program to work with the UNmodified Wii nunchuck? I am about 2 weeks of stuff away from attempting it myself, but I'm still working on some other fabricating. I'd like to be able to control the steering by using the accelerometers in the nunchuck but the other (excellently written) instructable is set up to export the accel readout as a varible voltage to feed to another microporcessor instead of directly into the code to the motor controller. Didn't want to reinvent the wheel if it wasn't needed.

BTW, Thanks to all for all the support so far. It's funny that the more DIY stuff I do the more I feel the support comes from so many others. I a very big way, none of us do anything entirely on their own :)
Timofte Andrei says: Nov 6, 2011. 6:06 AM
i think you can use a relay instead of that switch :D good luck
jmunsami says: Sep 14, 2011. 11:33 AM
Thanks for an amazing tutorial once again john. I really want a pressure sensor driven one... so i guess ill have to wait!

So anyway... I was thinking about what motors to use. I want to use one of these motors, but im unsure which one, and if the sabertooth will be enough to handle it.
http://www.ampflow.com/ampflow_motors.htm

Ive also found this battery which can handle the juice.

http://teamassociated.com/reedy/parts/details/626/

thanks :D
-Jaysen
XenonJohn (author) in reply to jmunsamiSep 16, 2011. 11:54 AM
The E150 motor seems to use 10 Amps. All the others use much more. The Sabertooth is 2 x 25 Amps (40 Amps for short periods).

However the main draw on a motor controller is when the motor is held stationary by mechanical obstruction, too steep a hill, and so on.

The Sabertooth does have overload protection that shuts it down allowing it to live to fight another day, which is good.

Also there is now a more powerful Sabertooth I believe that will take higher currents if this is what you want.
aniles jr in reply to XenonJohnOct 29, 2011. 9:36 AM
can i use this sabertooth


http://www.dimensionengineering.com/Sabertooth2x60.htm

thank you
aniles jr says: Oct 22, 2011. 10:50 AM
wat motor would be better the on u used or this http://www.ampflow.com/ampflow_motors.htm?
dornseif says: Oct 20, 2011. 3:33 PM
I have been able to purchase all other items for this build except these. Cant seem to find an online source for good brackets. I am in South Carolina, any idea where I can obtain them on internet?
aniles jr says: Sep 23, 2011. 5:11 PM
and wat motor would be better the on u used or this http://www.ampflow.com/ampflow_motors.htm?
aniles jr says: Sep 23, 2011. 5:09 PM
how long can u ride ur untills it dies
dhteam says: Sep 16, 2011. 12:13 AM
hey thanks "XenonJohn" for this tutorial it has been a big help i have used this and a few others and a lot of researching and incorporated them all together my code seams to be working alright and a balancing bot feels not to far away ,my question is in regards to powering the board by a second source as well as the usb cable , i was wondering what happens if u dont? and if the change is noticable? i have been using only my usb cable when debugging and testing software .

XenonJohn (author) in reply to dhteamSep 16, 2011. 11:57 AM
I found that the accel readouts changed when running the debugging "IMU tester" program when using the USB power.
When the board is running it will have its own power supply so recommend using that when using the IMU tester, especially as can use the IMU tester code to find the perfect balance point of your board to enter into the code of the full balancing software.
alexw2150 says: Sep 4, 2011. 3:27 AM
Cool, but I have a couple of inquiries;
Firstly could I use this( http://diydrones.com/profiles/blogs/arduimu-now-available ), because I have a couple floating around the place.
And secondly could you make it as an assist for a pedal (with brakes) bike like this ( http://www.n55.dk/MANUALS/SPACEFRAMEVEHICLES/spaceframevehicles.html ) (with the back wheel taken of)?
XenonJohn (author) in reply to alexw2150Sep 12, 2011. 2:06 PM
Re DIY drones arduino, yes you probably could use this!

Not sure if it could act as an assist to a pedal recumbent bike.

Could however probably use pedal power (cautiously) in combination with a self balancing system so long as pedal derived top speed did not exceed ability of electric motors to accelerate further if starting to tilt forwards.
alexw2150 in reply to XenonJohnSep 14, 2011. 12:37 PM
Cool thanks,
aniles jr says: Aug 9, 2011. 9:23 PM
thank you for answeing all of my qustions but i have a few more

im building a segway and instead of putting left-right on a SWICTH iwant to lean the handel over to the left to turn left and the father father i push it to the left or right the tighter the turns. would this mean i would have to put the gyro some were in the steering bar? and how much would i have to change in the code?

thanks
XenonJohn (author) in reply to aniles jrAug 11, 2011. 9:34 AM
I have attached a version of the code that allows you to use a potentiometer to steer the machine.

If you fix the potentiometer to the movable steering arm, it should work.
Code changes required: None or minimal.

Gyro/accel best placed in deck of segway in centre ideally.

How far have you got with your machine?
Best wishes

John
aniles jr in reply to XenonJohnSep 7, 2011. 1:40 PM
for the potentiometer would it have to go left and middle and right
aniles jr in reply to XenonJohnAug 11, 2011. 10:00 PM
thanks

im just mapping were every thing is going i m also desigining the base for it
alexw2150 says: Sep 4, 2011. 12:25 PM
I just had a thought, you should add a pressure sensor, so that if no one is on it (no pressure) it doesn't activate.
aniles jr says: Aug 22, 2011. 9:42 PM
can i do this set up?
025.JPG
XenonJohn (author) in reply to aniles jrAug 31, 2011. 3:59 PM
yes
aniles jr says: Aug 21, 2011. 4:07 PM
another question can i put the 2 motors in the middle connected dirctly to the 2 wheels?
XenonJohn (author) in reply to aniles jrAug 22, 2011. 2:07 PM
No, motors would not have enough torque (twisting-force) so you have to gear them down, and a small chain is easiest way.

You can get 250 Watt electric wheelchair motors with gears inside that do a similar thing (motor spins fast but wheel goes round more slowly - but with more torque).

This is also why toy electric scooters also use a chain drive and do not have wheel directly on the motor.

Best wishes

John
aniles jr says: Jul 31, 2011. 2:28 PM
if i want the motors to run at full speed can i get this to do that

http://www.dimensionengineering.com/Sabertooth2x50HV.htm
XenonJohn (author) in reply to aniles jrJul 31, 2011. 5:21 PM
Is this a new product?
This has been designed for big combat tank style robots and ride-on vehicles.

Control inputs and performance all the same as the 2 x25 sabertooth, just twice the power, so it should work. Looks ideal for a bigger segway style project if you need to go up steep slopes.

Your batteries have to be good enough to supply the current however otherwise you would just be wasting money.

Also motors: Mine are 250 Watts each. Watts = Volts x Amps so if running at max power from 24v battery pack then you would be using 10.4 Amps per motor. Therefore the sabertooth 2 x 25 would still be more than capable. So only spend money on 2x 50 if you are planning much bigger motors.

Motors could draw much more current than this if physically jammed/stalled, however the sabertooth will shut itself down in that situation to protect itself.....so still OK.
aniles jr in reply to XenonJohnAug 8, 2011. 12:50 PM
ok thanks

but then how come u said i cant run the mottors at 100%?
XenonJohn (author) in reply to aniles jrAug 9, 2011. 11:05 AM
I don't think I did say you cannot run the motors at 100%.

People have built machines that balance a human on a level surface using motors as small as 2 x 100 Watt. I am using 2 x 250 Watt motors in my boards. A real Segway has much more powerful motors than that.

To summarise, to balance on level surface, motors do not have to be huge, especially if using reduction gearing or the chain equivalent (i.e. large diameter sprocket on the wheel + small diameter one on motor).

For fast acceleration , high top speed and/or especially if you want to go up hills, you need a lot more power in reserve.

If you run motors flat out, you will fall off front of machine as it cannot speed up any more to stay balanced under your centre of balance. Therefore unwise to command motors to run at full power, best keep a little in reserve for this reason.

Motors, motor controllers and batteries have to be well matched. Batteries have to be big enough to provide the max current the motors can draw. Equally the motor controller has to be up to the job and be capable of handling that current as well.

All this is secondary though. The hard part is achieving self-balancing. You can experiment with huge motors/motor controllers and batteries later on if you wish to make the financial investment - which will be considerable.

John
aniles jr in reply to XenonJohnAug 9, 2011. 9:08 PM
ok thanks
jmunsami says: Aug 3, 2011. 4:40 AM
Im thinking of using a LEAD battery permanantly instead of lithuim polymer. I plan to use a 75Ah 12v battery
http://uk.rs-online.com/web/p/lead-acid-rechargeable-batteries/4363614/
and use a converter to make it 24v
http://www.virtualvillage.co.uk/12v-to-24v-dc-dc-power-converter-module-003602-013.html
Is this a good idea?
Also.... Is it possible to make the hand controller wireless? (bluetooth)
XenonJohn (author) in reply to jmunsamiAug 3, 2011. 2:12 PM
The 12V to 24V converter only handles 3 Amps. Although when these machines are rolling along a smooth surface they dom't actually use much power, when tipping over they will throw a huge current into motors so machine accelerates to get itself back underneath your centre of mass.

So, for self-balancing machines you do need some reserve.

Also when going up a slope the current draw will increase considerably.

I would use two 12v batteries in series. Lead-acids are fine, in fact they can provide high current for short periods - exactly what we need.
I would only invest in more expensive batteries once you are happy your machine balances OK.

I have one machine that uses a wireless Wii-Nunchuck for the "deadman" switch function and steering. Works fine but in public exhibitions it can get swamped by too many people using cell phones and so on, it loses connection (scary).
See here for how to do that:
http://www.instructables.com/id/Wireless-Wii-Nunchuck-control-of-Arduino-projects/

I also have a wired Nunchuck Instructable - not as cool but more reliable!

John
jmunsami in reply to XenonJohnAug 4, 2011. 1:35 PM
Thank you John :D

Im planning on using the same motors as you... are these the ones?

http://www.ebay.co.uk/itm/24V-250W-Electric-Scooter-Motor-Unite-Brush-MY1016-/170671368090?pt=Motorcycles_Parts_Accessories&hash=item27bcce679a#ht_2798wt_1139


Can you use bluetooth to link the nunchuck?(if it doesnt already use that LOL)
I now plan on using these batteries

http://uk.rs-online.com/web/p/lead-acid-rechargeable-batteries/3730366/

, 2 to make a 24v system. I was wondering... what batteries do you use and how much battery life does it give you? I was hoping to use this for at least 3 hours.
I want a design like your carbon fibre pneumatic system... but dont have access to welding and metalwork facilities. Is it possible for you to make me one and me pay you? Speaking of pneumatic, how much benefits to the pneumatic tires give?
Also could i use the pressure sensors on the board to make a dead switch?
Excuse me for asking so many questions, because im making 8 of these to sell, with a £160 profit on each, so i want to make them good :D

Thanks for your amazing advice and all the time you put into making the instructions viewable.


XenonJohn (author) in reply to jmunsamiAug 7, 2011. 9:45 AM
HI,

If you are going to sell them for £160 profit on each one, then you design 'em matey!
Make sure you have a few million $ public liability insurance, don't use any of my software and don't mention me anywhere in the instruction manual.

John
jmunsami in reply to XenonJohnAug 8, 2011. 2:34 PM
Haaahaa! Im not thinking as big as that! But Im Sure that these could make a much larger profit if made per 100's!
Positive07 says: Aug 7, 2011. 5:05 PM
Which gyro is that? it is from sparkfun?.... Oh and i have to said your board is awesome :D
XenonJohn (author) in reply to Positive07Aug 8, 2011. 9:09 AM
The Inertial Measurement Unit (IMU) has 2 gyros and 3 accelerometers.

I actually use 1 gyro and one accel to balance, and the second gyro as a way to detect and then compensate for sudden rapid changes in direction (like one wheel hitting a stone for example).

It is the Sparkfun 5DOF IMU (5 degrees of freedom)

There is also a 6DOF version (3 gyros and 3 accels) but for my needs the 5 DOF one is fine.
Making video of the new pneumatic tyre board at the moment.

Best wishes
John
miguipda says: Aug 6, 2011. 10:16 AM
Hi John,

thanks to share your arduino segway like project. Because I also think to make a segway like but my knowledge is limited in electronic. I am sure I can do it with an arduino and I enjoy to read your project.

Just two thinks I need to ask you and may be that will upgrade your project :

1) At 1:19 on this video we can see that a segway use five gyros : http://www.youtube.com/watch?v=OVCzB1AZPA0
may be for front to back + left to right + one wheel up or down the other.
What do you think about this ? I mean if your "segway" like have one wheel a little a bit up the other does it continue to run anyway ? If well what the need of five gyros on the real segway ?

2) to answer to your question concerning the fact to reduce the cost of your segway like I just discovered this gyro reduction. In place of paying it 100$ you can build it to 8$ (as he said) : http://underfinished.blogspot.com/
May be can you give us your project with this use.

3) Do you think that overclocking the arduino can help for the answer time or unneeded ?

4) Can the one chip arduino be cheaper and or more useful (consumption with some LiPo battery in place of weight battery) ?

Sincerely thanks for your informations and have a nice day.

Miguipda ;-)
http://www.geocities.jp/arduino_diecimila/obaka/project-2/index_en.html
XenonJohn (author) in reply to miguipdaAug 7, 2011. 9:39 AM
1) Why dont I use 5 gyros?
A real segway will probably work with some of the gyros failed. It is designed with redundancy in mind (2 motor windings for each motor for example) for safety where the users are not at all interested in how it works.
2) I use 1 gyro with 1 accel to balance. This is the minimum. If they fail you fall off.
3) Also there are starnge situations that can occur such as tuening while on a slope or with one wheel on a slippery surface while truning while on a slope, and so on. The 5 gyros help with the "calculations" for such situations I suspect.
4) Why overclock the arduino? My software at present only works for about 1/3 of the time, the rest is a delay, and that gives you 100 program loops per second which is ample for the balance algorithm
5) One chip arduino? Not sure what you mean, maybe the tiny versions of the arduino's you can get. They will save you space for sure if space is tight I suppose. Perhaps will use a little less power if powering them from a small battery perhaps. Marginal gain therefore.
6) $8 "gyro" is not a gyro. It has a wheel with a weight on it that "will always be closest to the ground" which is then connacted to a sort of optical position sensor. Well no actually, if you braked hard, the weight would swing forwards. It would give you a "I am tilting" reading when in fact you were not. My gyro in 2008 cost be about $200. Now sparkfun do a board with 2 gyros and 3 accels all for about $50 so to be honest I am not complaining about price of gyros any more. You can even use a WiiMotionPLus module which has gyros inside to save money, but you need to understand all the code required to decode the data from these.
Therefis already plenty to go wrong in these machines, don't make life even harder for yourself just to save a couple of dollars.

Best wishes

John
miaoichi says: Jul 25, 2011. 10:11 PM
Hi XenonJohn,

I can't find the balancing point.
please kindly find my video as below,
Do you have any comment?
Thanks.

http://www.youtube.com/watch?v=pca1R2EoUW4
http://www.youtube.com/watch?v=L409_xPT5dA
XenonJohn (author) in reply to miaoichiAug 3, 2011. 2:02 PM
Just posting this here to say that after much emailing and dodgy YouTube videos of a machine trying to break itself apart, miaoichi's board now does indeed self-balance!

The value in the code that affects the balance point had to be tweaked and also the motors may initially have been wired back-to-front (50/50 chance).

Aug1st:
The IMU tester code has been updated on the Instructable so it now tells you the exact value you need to insert in the rest of your code to get your particular machine to balance perfectly level. This compensates for slight variations in the way people mount their IMU's since "vertical" can in fact vary slightly from one machine to the next.

still on the learning curve...........

John

John
XenonJohn (author) in reply to miaoichiJul 26, 2011. 5:37 AM
Hi,

Accel is clearly cutting in when level so that "titlstart" part is OK.
Therefore thinking of gyro and the way it is combined with the accel. Something may be back to front in code or physically.

Just try decreasing the variable "ti" at start of code to smaller value, try 2.2

Send me a message with a working email address and we can correspond and sort it out.

I need a good quality photo to begin with of your IMU orientation

Best wishes

John
miaoichi in reply to XenonJohnJul 26, 2011. 7:05 AM
Hi,
My e-mail shown as below
miao.ichi@msa.hinet.net

Could you send me an email first, so that I can corresponding.

Regards,
Thanks.
miaoichi in reply to miaoichiJul 26, 2011. 5:18 PM
Hi,
I uploaded picture of self-balancing board for you.
Please kindly find below link.

http://www.wretch.cc/album/show.php?i=miaoichi&b=5&f=1786372454&p=0

What email address can I send to you? Please provide me. Thanks.
zaborrilla says: Jul 31, 2011. 4:28 PM
Hi John,

This instructable is really great!! I have in my mind the idea of building a segway clone instead of a skateboard. I am in the process of reading your code and study what is made in each step. I have a question about one feature i miss (I don`t know if it's implemented or simply I cannot locate it). If I lean forward and keep leaning there will be a moment when scooter is going so fast that the wheels can't keep up. Is the "tilt back" or some kind of speed limiter feature implemented?

Another question is about the motors you use. Do you miss more power? I would like to keep it cheap, so Im thinking to use the same 24V 250W motor you use (going to 500W ones the sabertooth might not be enough) with pneumatic tyres whells with 80 tooth sprocket to increase a bit the torque. The sprocket diamter is 165 mm, so im thinkink to use a E300 rear wheel (260 mm diameter).

Thanks for sharing your work!
XenonJohn (author) in reply to zaborrillaJul 31, 2011. 5:31 PM
Hi,

Trevor Blackwell has a monowheel site with code in "C" that implemented a tilt back feature to limit top speed. Others had trouble making it work though.

In my latest twin wheeler I simply have some LEDS come on when power being sent to motors is by arduino algorithm is 70% and more come on (red ones!) when it gets to 90%. You can also use a buzzer. Relatively crude but it works. You are right, if you accelerate to max speed then after that you will gently topple over the front end as it cannot accelerate any more to keep under your centre of mass.
http://sites.google.com/site/onewheeledselfbalancing/

You could use bigger motors with saber 2 x 25. These Chinese scooter motors also come in 350 watt and 500 watt versions (case same diameter, motor slightly longer).
500 watts from 24V battery pack would be 20.8 Amps so you could probably go to 350watt motors and still be OK with saber 2 x 25. If you really overload it, it will shut down before it burns out - which is good.

As you can see from link above, my latest machine has E200 rear wheels with pneumatic tyres and it works just fine. Posting a new YouTube vid of it in a couple of weeks time.

John
zaborrilla in reply to XenonJohnJul 31, 2011. 5:51 PM
Hi,

Thanks, I think first i will try to do a skateboard instead of a segway like thing, so, recovering from that situation is easy if you have small wheels at the top, but with the segway mode you will go to the floor easily.

Regards and thanks for the quick answer
aniles jr says: Jul 20, 2011. 3:38 PM
how do i enter the code into the borad and were do i get the software from
XenonJohn (author) in reply to aniles jrJul 23, 2011. 11:40 AM
OK.
These are my serious thoughts on how to progress as fast as possible (I know because it took me 3 months to get my first efforts to balance badly):
i) Get an arduino experimenters kit (most arduino retailers have them), about $40-50 that comes with a book of about 12 tutorials and a box of additional sensors etc as well as the arduino board itself. Work through them and the code (about 2 solid days work) and this will teach you the basics of arduino electronics and programming.
ii) Read, read and read some more about self balancing projects, segways, robots (lots of links on my website but plenty more out there for you to find). Fill your brain with everything you need to be thinking about. Spend about a month getting your head around the principles at work.
The lectures on the www.segwii.com site are a good starting point.
iii) Then, have a go at building something, even if it fails you are still learning all the time.
iv) Keep going and have fun. Treat it as an adventure, the end point is unknown.

Best wishes
John

Links to other projects:
http://sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects
aniles jr says: Jul 15, 2011. 4:21 PM
how can i use a potentiometer to adjust the how tight the turns are and i want to do this on the handcontroller?
XenonJohn (author) in reply to aniles jrJul 17, 2011. 9:13 AM
I would get it to just balance first. Concentrate completely on that.

Eveything else after that can just be classed as refinements.

Sure, you could adjust the target rate of turn in degrees with a potentiometer, you could also make it inversely proportional to the estimated speed which would be a good thing.
For example I am currently working on using 2 pressure sensitive resistors under my left heel and toe to allow it to be steered by leaning, and stopped by rolling foot sideways so not pressing either resistor. This also means you can lose the deadman switch. Lots of things you could do - after you've got it to balance!

John
aniles jr in reply to XenonJohnJul 22, 2011. 1:41 PM
wen i get mine to blance can u help me out to do that so we i lean it will turn?
tilmen says: Jul 20, 2011. 7:24 PM
cool work
aniles jr says: Jul 2, 2011. 9:58 AM
were do i get the 5volts from
XenonJohn (author) in reply to aniles jrJul 14, 2011. 4:49 PM
The terminal on the arduino labelled 5V

(the one labelled 3.3V next to it powers the IMU)

John



mickydee says: May 28, 2011. 1:55 PM
Hi John
Thanks for a great project. I am building a variance of your ible. . II am building a two wheeled balancing wheel chair. I don't have a lot of experience in this field, but I follow instructions pretty good. I will be using 24 volt wheel chair motors and all the electronics yours has. I plan on using your code as it is written. It will be a little heavy but really rugged . One question I have for you. Is it important to try to balance everything around a CG at the axles? If I am a little off , will it still balance? To get some experience I am building a small platform using an RC donor tank for the drive motors to see if I can get it to balance. If it balances I will transfer all the electronics to the larger wheel chair. I am 80 years old and it is getting harder to get around. I just won first place in the Makebot challenge and I hope I can use the 3-D printer to make some of the parts.
Thanks again for the great ible I will send you pictures as soon as I get a little further along
Mickydee
XenonJohn (author) in reply to mickydeeMay 28, 2011. 6:05 PM
There are several segway style machines around based on wheelchair motors.

The thing does not have to perfectly balance when power is off. What happens is you adjust the balance point with one of the rocker switches until your CG is above axle line. If that means you end up tilted a little forward or back when "balanced" so be it. Alternative is to vary where you put your feet. So long as total machine + rider CG is roughly above axles when you are on it, it doesn't matter if machine is slightly off balance when riderless.

I did temporarily rebuild this as mini-segway so I know it should work.

You do need to consider what happens in wheelchair mode if it goes wrong, i.e. will you fall back hit your head or will it simply tilt to a slight angle onto a caster wheel for example. Please do put some caster wheels each end just in case!
mickydee in reply to XenonJohnJun 12, 2011. 4:10 PM
Hi John!
Thanks for all the help and suggestions. I have built the frame and mounted the motors.I have installed casters front and rear for safety. They only let it tip just enough for the tip start to work. The IMU and motor tests ran well. I tested on 12 and 24 volts. After several tries I finally got it to balance. It was not quite level, but I assume that is due to the IMU placement.My next step is to wire up the hand controller and try the full balance program. I have not built the seat risers yet. I just want to prove my electronics first before I try to ride on it. I have a couple of questions for you
1. What does the soft start do?
2. Can I mount the IMU screwed to a block of wood to keep it at a 90 to the floor?
I will send you some pics soon. This thing is pretty heavy. but it sure is solid.
3. Do you think the weight will be a balance problem?
Thanks again for all the code I don't know the first thing about C++
Regards mickydee
XenonJohn (author) in reply to mickydeeJun 13, 2011. 12:16 PM
If it balances at all then you are nearly there.
I did use this code in a segway styled version for a while so I know it works OK.
http://sites.google.com/site/onewheeledselfbalancing/Home/self-balancing-scooter-airport-rucksack

1) Softstart: The motors react to angle of tilt but also to rate of tilting. Therefore if you stand on board then over-enthusiastically bring it to level point (so rate of tilt is actually very fast), the motors will really fire as soon as you go past the level point. The board will really wobble and overcorrect.
You soon learn how to gently bring it level, but what softstart does is this: when you first bring it level the overallgain is set to 50% of what it should be. Over the next few seconds after you have brought it level and motors have started up, the gain gradually comes up to 100%. This makes it feel a bit mushy underfoot for a few seconds when you first start it up, but this also stops it overcorrecting if you bring it to the level position too rapidly.
2) As well as a steering control there is also a forward/back rocker switch (3 position switch with central position as default). This can be blipped back or forward to fine-tune the balance point while you are on the board.
However, simplest way to get it more or less level from the outset is to mount IMU on a little bracket that rotates slightly then can be tightened up in perfect position (plus a little blob of glue to stop it coming loose - hot melt glue is great for this kind of thing as so long as you don't use too much, you can peel it off if you have to change something).
3) To balance you need a decent amount of torque at the wheels. If not aiming for high top speed this is easier to solve: small spocket on motor and big sprocket on wheel. You only need this "excess" power when trying to recover from a large angle of tilt, or trying to get up a slope. However, if pootling around slowly on a level floor, as you plan to, then your weight is more or less directly over the wheels all the time so in theory it should still balance without too much trouble.

Also remember when you first power it up, stationary with one end on ground, count to 5 slowly as first thinbg it does is read the value from the gyro when zero "rate of tilting." Then press the deadman switch and slowly bring it level.

If you find it too aggressive and want a softer ride, look at the line at start of code where it says "float ti = 3;" and change the value to a smaller one, about 2.2 would be OK.

Hope this helps

John
mickydee in reply to XenonJohnJul 11, 2011. 12:03 PM
Hi John
I imagine you must tire of solving our problems. I try my best to work it out but I am just frustrated at this point.
I can't get the numbers you get during the IMU test. They are all too high and all over the place. I thought I had blown my IMU so I bought a new one from Sparkfun.. The numbers looked a little better so I tried the "Just Balance sketch". When it came alive it lurched forward and ran across the room. I checked all my joints and even moved the pull down resistors to the hand controller by running a ground to the controller. This does make it neater. I hope I haven't blown the new IMU? I am attaching two pictures of the serial window during the test. Let me know what you think. Is the dead man in play for this test? I tried it both ways. The numbers seem to be a little lower with the switch depressed.
P1010037.JPGP1010036.JPGP1010038.JPG
XenonJohn (author) in reply to mickydeeJul 13, 2011. 3:27 PM
Your IMU tester data is definitely wrong.
When accel goes +ve, gyro should go +ve as you are tipping it
When accel goes -ve, gyor should go -ve as you are tipping it.

When held still, accel will give (static) tipping angle (zero being about level) while gyro should read zero (at any angle of static tilt) but will in fact give a small +ve or -ve value as it drifts a bit.

I will have a closer look over weekend and come back to you.

John
aniles jr says: Jul 12, 2011. 8:37 PM
how can i use a potentiometer to adjust the how tight the turns are and i want to do this on the handcontroller
aniles jr says: Jul 7, 2011. 3:14 PM
is this battary good?

http://www.apexbattery.com/dts-12v-6-7-amp---no-leads-battery-sealed-lead-acid-batteries-dts-batteries.html


thanks

adrian
XenonJohn (author) in reply to aniles jrJul 9, 2011. 9:19 AM
Should be OK. You would need 2 of them.
Best wishes
John
aniles jr says: Jul 3, 2011. 5:44 PM
wat dose "balance point fine tune switch" do ?
XenonJohn (author) in reply to aniles jrJul 4, 2011. 4:50 PM
By momentarily flicking switch forward or back you can make small adjustments to the angle of the board at which it self-balances. It is just for the comfort of the rider. If one foot feels a bit higher than the other when you are riding it, you can make a small correction while you are riding board.

Also, if about to go up a slope you might want to raise the "nose" of the board slightly, this is how you do it.

The IMU uses 3.3V from the arduino board which has a regulated 3.3V supply on it for just this sort of peripheral (the newer ones anyway).

The arduino board also has a regulated 5V pin on it which is a 5V supply, again for peripheral devices.

Supply to the arduino has to be in range of 7V to 12V via the power input socket.

Easiest way to get going is to connect a 9V battery to it.

You can use a so-called linear voltage regulator to convert from 24 V of the main batteries to 7V but it will generate lots of heat and waste some of your main battery power.
I have ordered a more exotic one which works in a different way and is far more efficient. If it works OK I will add it to the instructable.

Best wishes
John

aniles jr in reply to XenonJohnJul 7, 2011. 3:29 PM
thanks

but were do i get the 5 volts from the board so i could bring it to the hand controller
BuildWiz says: Jun 21, 2011. 1:40 PM
Hi,

So i have hooked up the motors (i went with 300w motors) to the sabertooth, pluged in the batteries and hooked up my ardrino uno. I go to run the motor test sketch and the dead man switch function doesn't work and it only runs one motor. i was wondering if anyone had any advice cus i've switched both motors and tested so they both work it's just the M2A and M2B ports aren't putting anything out. I checked my wiring and everything and just can't figure it out. Any suggestions would be helpful.

Thanks,
Nick
XenonJohn (author) in reply to BuildWizJun 25, 2011. 1:05 PM
Reading all these Q and A posts it does seem some people have faulty Sabertooths that don't read the serial communication from the arduino. This is one reason I wrote the motor tester sketch.

For example one person ("grunff" April 2011) had his sabertooth failing to run in serial mode but working fine in RC mode.

You could rig up a variable 0-5 voltage input (see datasheets for sabertooth) system with potentiometer, set the DIP switches on sabertooth to the analog input mode and see if both motors work then.

If there is any way you can try a different sabertooth that would be the thing to do.

Best wishes
John



mickydee says: Jun 23, 2011. 2:43 PM
Hi John!
Update
I found part of the problem. It appears that my arduino DC input is bad. When I powered it up using my laptops USB port it came to life. I was using a 9 volt battery for power. The arduino lit up but would not function in the system. I have ordered a new UNO . The excess voltage 6.8 volts coming from the arduino is causing the project to be jittery. I think I will continue testing using the USB port for power.
Thanks mickydee
mickydee says: Jun 23, 2011. 11:04 AM
Hi John!
Everything was going well, until I soldered all the wires from my hand controller to the arduino. I am not sure if I accidentally put 24 volts to the arduino or not. Now the tipstart is not working. I checked all the wires and voltages and all seems well.
The arduino is putting out 6.3 volts instead of 5 volts. The 3.3 tap is working .
I tried the motor test sketch and it works perfectly so I think I am communicating with the Sabertooth O.K. Do you think I have blown the arduino? I tested the arduino with the blink sketch and it works fine. Any suggestions?
mickydee
kriogenic says: Apr 8, 2011. 9:26 PM
Hey there, I am going to experiment but I was wondering if you knew if this IMU unit would be applicable.

http://www.sparkfun.com/products/9250

I have no idea really but think it will be fine without the capabilty of resisting sudden turns?
kriogenic in reply to kriogenicApr 20, 2011. 6:13 AM
Hey there,

I got a few things for this project underway now,

I got my motors, motor controller, IMU and arduino.

Using your examples I got the accel and gyro to give me usable figures....

Using the motor example I got my motors to run fine.

Using your balancing only code and a few tweaks I have gotten the IMU to spin the motor depending on its orinetation. however the motor controller seems to cut out after the motor reaches 100%, i am not sure why this is. I can post a video for you if it would make it easier.

Thanks,
Kriogenic.
XenonJohn (author) in reply to kriogenicJun 1, 2011. 1:49 PM
June 1, 2011:
This turned out to be a bug in the code. The "Integral" value of the PID accumulates indefinitely if you hold it tilted on a bench rig for a long time for example. Eventually it flips back around to 1 again!

I now have put a limits check on it so it cannot do this any more.

John
XenonJohn (author) in reply to kriogenicApr 23, 2011. 2:53 PM
When both motors running at 100% then current draw on batteries may be pretty high.

Not sure what batteries you are using but if the current draw exceeds what batteries can give, voltage across them will drop. If it goes too low the sabertooth will shut down. I am not sure at what voltage this happens but might be worth measuring voltage across batteries and seeing how low it goes when you are running both motors at 100%.

In the motor testing sketch they only go to 50% each then decrease again.

John
aniles jr in reply to XenonJohnJul 3, 2011. 5:29 PM
what if you put it up to 80% because i want mines to go fast

thanks

adrian
XenonJohn (author) in reply to kriogenicApr 9, 2011. 1:41 PM
This should work OK

Minimum needed to balance is one accel and one gyro

ursine100 says: Apr 28, 2011. 8:28 AM
(removed by author or community request)
Montspy in reply to ursine100Apr 29, 2011. 12:51 PM
Hi, where did you buy the wheels please ?

Regards,
Val'
XenonJohn (author) in reply to MontspyJun 1, 2011. 1:45 PM
Here is one:

http://www.razorbase.co.uk/E100_Complete_Rear_Wheel
as you can see they will be "in soon" !

Here is another (delivery 1 month) which is where I originally obtained mine from.
http://www.skatehut.co.uk/acatalog/Razor_replacement_whees.html

It looks like if you can find any anywhere in the world you should buy them wherever they may be, even with import cost added, or find a usable alternative.

John
XenonJohn (author) in reply to MontspyMay 29, 2011. 10:26 AM
If you cannot get hold of E100 wheels which are the smallest ones with solid tyres you could maybe try the E200 wheels (200mm diameter) with chain drive which would be bigger but perhaps better over rough surfaces as have a pneumatic tyre.

Example:
http://www.monsterscooterparts.com/e200rearwheel.html
ursine100 in reply to XenonJohnJun 6, 2011. 5:17 PM
I've got 2 pneumatic tires on order. I plan on rebuilding when they get here.

Dave
XenonJohn (author) in reply to ursine100Jun 25, 2011. 12:57 PM
I have just built yet another version of the machine with Razor E200 wheels (i.e. pneumatic tyres) with drum brake mechanism cut off each wheel and axle rods shortened.

Had to make quite a complex welded frame as I wanted tops of wheels to poke through top of frame, but it does work just fine from mechanical perspective.

http://sites.google.com/site/onewheeledselfbalancing/

John
Montspy in reply to XenonJohnJun 26, 2011. 1:12 AM
Nice build !
My skateboard balanced and I ride it yesterday before the Sabertooth microcontroller burnt today... Apparently it's because wheels turned when no batteries were connected. Back EMF is bad !
Need to buy another one :/
Sometimes,when I bring the board to it's balancing point, with the deadman button pushed, the board will go crazy and turn on the motors near 100% in the wrong way to balance :/ Do you have an idea ?

Regards,
Val'
XenonJohn (author) in reply to MontspyJul 1, 2011. 4:44 AM
You have to bring it to the balance point very gently. Takes practice. Harder to do if your board is high off ground. Try it while leaning with both hands on a desk and you will get the idea.

There is a term in the algorithm that says "if I am tipping fast then send more power to motor to correct against it - proportional to the rate of rotation of the board"

So, if you bring it to level point fast, i.e. rapid rotation in degrees per second, as soon as it is level, even though the absolute angle of tilt is zero, the software goes live and motors really kick in as your rate of tilting as actually still a high value. Your instinct is to fight it which makes it oscillate even worse.

I have tried to soften this with the "softstart" added to the code recently.

Also at the start you see we define the variable "ti" as 3.

Try changing it to about 2.2, it gives you a slightly mushier ride quality though.

Also you need the deadman switch to be a decent quality switch - no "intermittent" dodgy contacts allowed!

Also remember to leave it tilted on ground stationary, turn it on, leave it alone for 5 seconds, then bring it level as after you switch it on it "zeroes" itself (takes readings from the gyros when board not moving and uses them as the zero values).

Also once you have let go of deadman, you have to turn power off then on again and go through above startup routine again. If you press deadman again after you have let go of it (while board is now tipped) it will fire off across the room as it tries to balance itself.

Best wishes

John
ursine100 in reply to MontspyApr 29, 2011. 3:48 PM
www.razorama.com
Montspy in reply to ursine100Apr 30, 2011. 5:38 AM
Thank you ! I thought they don't ship outside US but their is an hidden "international checkout" button ;)
Waiting for arrival !

Thanks again ursine100 !

Regards,
Val'
ursine100 in reply to MontspyApr 30, 2011. 1:20 PM
No problem. I'm hoping to get mine next week.

Dave
Montspy in reply to ursine100May 17, 2011. 9:11 AM
Got them ! Building th thing :)
Can't wait to ride it int he campus !

Regards,
Val'
kriogenic says: May 24, 2011. 7:24 PM
Hey there, I am in progress of building one of these.

I have hit another bump.... i bought a new IMU which is the EXACT same as which you have 5DOF from sparkfun. and have wired it EXACTLY as you have.

When I run the IMU test sketch. when the gyro is mounted as accuratly as possible to yours i run the sketch and recieve 60 degrees when lying with left end down (component side of IMU facing the downward side of board).

When i tilt it the other way on to the other tilt it registers 0...

Not sure if you understand and I plan to make a video to show you. But I am not getting anywhere near 0 degrees when then board is directly level with ground. Also my gyropersecond is always at about 1-2 :S

Im confused.
Thanks.
XenonJohn (author) in reply to kriogenicMay 29, 2011. 5:02 AM
Just to clarify so no confusion at all:

I have component side of the IMU facing to my left.
IMU is mounted almost vertically with the 2 holes for the bolts both along the lowest edge nearest the ground.

When you run the new IMU tester sketch, when board is held level the accel value (in degrees) should be more or less zero.
It then goes -ve if you tip it one way or +ve by a similar amount if you tip it the other way. The angles of tilt displayed should be roughly the same as those you see when tilting the board.

Meanwhile the gyro reading is giving you a RATE of tilting. Ideally this is zero when board is at any angle (not just when level) but being held stationary.
In reality it gives a small reading even at rest due to the fact that its baseline value drifts with time. When actually in the act of being tilted, the gyro rate of tilt should increase or decrease in same direction, momentarily, as you see with the accel value.

If you can position IMU so this is what you see, then you are nearly there!
John
XenonJohn (author) in reply to kriogenicMay 28, 2011. 5:57 PM
OK here I am again:

1) The IMU tester code has been improved. Open serial view window and check that as you tilt it, the gyro just transiently reads same sign direction as the accel value, i.e. they both go +ve one way then both go -ve the other way.
NOTE: the gyro reading at zero or "level" will not be zero as it drifts. My gyro reads 6 degrees per sec even when stationary for example. This is why we have an accelerometer - to correct for the "drift" in the gyro readings.

2) Both the final versions of the code (rocker switch steering and potentiometer steering versions) have serial view windows now that allow you to watch what is going on with any variables you want to look at.
This works in real time as it is balancing and the loop time of 100 cycles per second is NOT affected by this feature, thanks to some clever timekeeping code borrowed from another instructable.

Hope it helps,

John
kriogenic in reply to XenonJohnMay 28, 2011. 6:06 PM
Thanks I wasn't sure if it was accurate or not.

As I have all the same components as you do here and have checked everything more then once.

with the old IMU I was using I managed to get my board to trigger and try to balance at the right point. Using the 5DOF from sparkfun it is trying to trigger (and assume balance point) is lying fully tilted to the right.

I will do some more tweaking within the next few hours and let you know how it all goes.

Thanks for updating the test sketches and source,

Andrew.
XenonJohn (author) in reply to kriogenicMay 28, 2011. 1:01 PM
The test sketch is not that great to be honest. It was just an attempt to stop people connecting their accel and gyro facing backwards with respect to each other (a mistake I have made more than once).

When have time will rewrite it so all the values it spits out are accurate (they arent at present - they just give you an indication of whether accel and gyro are moving the same way or opposing each other).

I will post something on page 1 when I have made this upgrade. Hopefully within next few days.

John
DrWilson says: May 28, 2011. 1:25 PM
Well done on making it onto the gadget show, seen it this morning! Loved the t-shirt! :)
XenonJohn (author) in reply to DrWilsonMay 28, 2011. 6:12 PM
Here is the relevant clip from that episode of gadget show (I missed it too, someone phoned and told me it was on):
http://fwd.channel5.com/gadget-show/videos/feature/maker-faire

It was also on the New Scientist web TV channel so now I must be a proper scientist!
http://www.newscientist.com/blogs/nstv/2011/03/make-your-own-self-balancing-skateboard.html

ursine100 says: May 27, 2011. 4:46 PM
Thanks John for the great post.

I just finished mine a few days ago. Lots of fun ( although I'm nursing a pulled hamstring from one of the first few rides). I left the sketch pretty much as is except for modifying the level balance number, but I noticed my rate of turn is slow.
http://youtu.be/vhbH_AmIKZA
XenonJohn (author) in reply to ursine100May 28, 2011. 12:56 PM
Hi,
Yours balances roughly as mine does.

Am trying to build a unicycle at the moment and have learned a lot more about PID balance control. I may well redo the code soon with a few small improvements.

Meanwhile the regarding the rate of turn:

//steer one way SteerValue of 512 is straight ahead
if (k1 < 297) {
if (gangleratedeg2 < 8) { //will turn clockwise at 8 degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > 8) {
SteerValue = SteerValue - 1;
}
}


//steer the other way
if (k1 > 697) {
if (gangleratedeg2 < -8) { //will turn anticlockwise at 8 degrees per sec and if not, more power fed into steering until it does
SteerValue = SteerValue + 1;
}
if (gangleratedeg2 > -8) {
SteerValue = SteerValue - 1;
}
SOLUTION
If you want to turn faster change the 8's and -8's to a larger value. I would suggest doing this in stages! Remember at present as the code is now the rate of turn will be the same in angle of turn per second even if you are going fast. A fast turn rate is cool when near-stationary but you will fall off if it turns at same angular rate when you are going along fast!
The value (8 at present) should actually be larger when speed is slow and become smaller when speed is fast. You could try making it vary inversely with the cur_speed term. There are lots of ways to improve my code.

One bug that needs to be fixed (now fixed in latest attached code):
Where it says:
level = level * 200; //changes it to a scale of about -100 to +100

ADD THESE 2 LINES OF CODE
if (level > 100) level = 100;
if (level < -100) level = -100;


WHY? because if you hold it tilted a long time (to go up a slope perhaps) "level" can get larger and larger then flip back to zero causing motors to throw you off.
Has never happened to me when riding it but can be seen to do it when bench tilt-testing with wheels off the ground.
Best wishes

John
kriogenic says: May 22, 2011. 7:00 PM
Hey there,

I see your using pull down resistors for all the inputs.

I think it may have already been mentioned but instead of all the resistors you can use the atmegas internal 20k pull up resistors. you can do so with the following

pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

this makes them a steady 5V in which you can reverse the check of the inputs to see if they are "LOW" then trigger.
screighton says: May 20, 2011. 10:56 AM
I have just finished building a segway version of this. It preforms very well. I will submit a link relatively soon.
pstone2 says: May 19, 2011. 8:32 AM
where did you get the razor back wheel kit and how much was it?
ursine100 says: Apr 30, 2011. 9:26 PM
While waiting for my wheels, I went to work on wiring the wii nunchuck. As it mentions in the instructable, the screws on the wiichuck require a special tool available on ebay. Not wanting to buy a tool I'd use only once, I ground down an old screwdriver and fashioned a 3 lobed driver with a Dremel abrasive wheel. Works great!

Dave
Montspy says: Apr 27, 2011. 11:58 AM
Thank you for this instructable ! I'll follow it as soon as I... can find those wheels -_-'
It's been near 1 year they are out of stock !

Regards,
Val'
miaoichi says: Apr 20, 2011. 9:20 AM
Hi John,

Could you share me how to mount the batteries underneth ?

Thanks.
regards,
Jack
XenonJohn (author) in reply to miaoichiApr 23, 2011. 3:06 PM
I had some spare angle brackets of the same type used to hold the wheels.

It is not a work of art but I bolted them together so they formed a Z shape, and bolted one flat edge up under the board, one of these at each end of the board. This forms a suspended support you can slide the battery onto.
With some additional bracketry underneath and tape, the batteries can be held steady under the board.
John
miaoichi in reply to XenonJohnApr 24, 2011. 5:36 AM
John,
Thanks for your response.
I'd like to see the pictures of battery, if you can sharing with me.

Regards,
Jack
miaoichi says: Apr 19, 2011. 10:53 PM
Hi, John

Could you tell me who to change the chain length ?
What tool should I use ?

Thanks.
Best regards,
Jack
XenonJohn (author) in reply to miaoichiApr 23, 2011. 3:02 PM
I learned by trial and error:

Get a vice and open the jaws about 3mm.
Put chain on its side with one of the pins linking between links of the chain exactly above the gap. Use tape or a helper to stop it all sliding off onto the floor!
I used a 2.5 mm broken drill bit (the shaft part) as a drift to tap out the pin so it drops out downwards between the gap in the jaws of the vice. Gap should be only just a tiny bit wider than width of the pin else the sides of chain will get bent.

When I say "tap" I actually mean hit it hard with a big hammer. A nail is too soft, it will just bend. That is why I used a broken drill bit. Hold drill bit tightly in pliers or locking pliers from the side and hit top with the hammer.

This is very fiddly to do. Do some trial runs with some spare chain.

Assembly is reverse of this and slightly easier.

You can get proper devices for splitting a chain, and a special removable link that is used to join the shortened ends back together again (this link is visible in one of the chain photos in the instructable but in the end I didn't use it).

I would ask a bike shop to help you out possibly.

John
prateekk says: Apr 1, 2011. 11:19 AM
hi john i am really inspired by this thing and looking forward to make one for me.
so would u plz help me out with this...by sendind codes to:
prateek.matrixx@gmail.com

and one more thing can u plz tell me can i make this with an atmel atmega8 microcontroller??
plz send me d circuit diagram and wiring things too
plzzz i am really looking forward to your reply !!!!
XenonJohn (author) in reply to prateekkApr 3, 2011. 1:55 AM
It's all there in the instructable folks, including the wiring.

You could use an Atmel atmega8 but the code will have to be written in "proper" C. Although the Arduino boards do indeed use Atmel microcontrollers the big advantage is that they use a simplified form of C which speeds things up hugely, plus masses of code online on the forums as an inspiration to you if you get stuck. This is why they are so popular with hobbyists.

I know because my first balancing machine used an Atmel microcontroller board and it took me 3 months to get the code working. Unless you code for a living or really know what you are doing I would use an Arduino every time.
miaoichi says: Mar 25, 2011. 9:00 PM
Hi, John

Could I have code as well ?
miaoichi@gmail.com

Thx!
XenonJohn (author) in reply to miaoichiMar 26, 2011. 5:33 PM
Check out the improved instructable.
All code attached to last few pages.

John
miaoichi in reply to XenonJohnMar 26, 2011. 10:12 PM
Thanks John.

I can't find the e100 rear wheel and motor in Taiwan.
Do you have provide Kit already now ?
If yes, i'd ordering from you.
Rikain says: Mar 24, 2011. 12:14 AM
Hi
Really interested, can I have the code please.
email rikain@live.co.uk

Thanks
XenonJohn (author) in reply to RikainMar 25, 2011. 6:17 PM
Hi Rikain,

I have just made quite a few improvements to the instructable. The arduino sketches keep disappearing so I have now attached them as simple text files to the last few pages.
Have added a number of test routines with video links to help people set up the IMU correctly, wire the motors up the right way around and so on.
Check out the last few pages and code should be attached.

Best wishes

John
eyeo says: Mar 9, 2011. 4:58 PM
hi.. can i have the code please ? A full version 1 and a balancing 1. thanks in advance.. my email is shadowboyz89@hotmail.com
XenonJohn (author) in reply to eyeoMar 10, 2011. 10:20 AM
code sent
trike road poet in reply to XenonJohnMar 19, 2011. 10:27 PM
I'd love a copy of the code, this is just begging to be built!
Question, what sort of heat dissipation from the controller, would a micro fan aid cooling and circuit stress loading? email trike.road.poet@gmail.com
kpp says: Mar 18, 2011. 12:39 PM
Hi, can i have the code please?
Seems like a fun project my email kunal_p_pat@yahoo.com
Thanks
screighton says: Mar 4, 2011. 12:11 PM
High I have two questions. The first is can someone who has never used arduino before do this, or do you need to be an arduino expert. ( I have done a little bit of java programing.) The second is could you please send me the code so that I can try to understand it. samhcreighton@gmail.com
Please help this is for a school project.
XenonJohn (author) in reply to screightonMar 10, 2011. 10:20 AM
Code sent.

Would suggest reading a book such as Getting Started with Arduino.

I think you would pick it up very quickly, it is a simplified form of C.

John
kevman0044 says: Mar 10, 2011. 12:02 AM
I've got mine built and balancing but it is real twitchy. How do I go about solving this problem. The chain has good tension on it and thats all I really knew to check.
XenonJohn (author) in reply to kevman0044Mar 10, 2011. 10:17 AM
Hi,

Firstly well done in getting it to balance. Hardest part done.
Twitchy: First thing to try is to turn down the gain potentiometer a little.

If you are using the code version that just gets it to balance and nothing else there are two places in the code where it says "overallgain = "
Reduce the value a little (same value in both places) and try it again.

Failing everything put a video on youtube and message me with the link so I can take a look at it.

Best wishes

John
screighton says: Mar 6, 2011. 1:31 PM
Can I please have the full version of the code, and the code that is just for balancing. samhcreighton@gmail.com

Thank you
kevman0044 says: Mar 2, 2011. 12:03 AM
I have it all wired up but when I turn it on I get nothing out of the motors when I bring it to the balance point. The only way I get anything out of the motors is if I take the OV ground cable from the sabertooth out completely. When I do that motor number two spins like crazy. Any ideas what might be wrong. Also could you send me the stripped down debugging code at kwbarnes1@buffs.wtamu.edu.
XenonJohn (author) in reply to kevman0044Mar 2, 2011. 3:21 PM
I would try the code that just balances it. Only peripheral required apart from a working single gyro and single accel from the IMU is the dead-man switch.

failing that send me a hi res photo and I will see if I can see any obvious wiring problems.

best wishes

john
xiodene says: Feb 26, 2011. 9:15 AM
Help!
I turned this on for the first time today as was very careful to get the + and - the right way round, started off fine, pressed the deadman switch and it spun. So i turned it over and pressed it agai, it ran for around 2 seconds before the sabertooth burst into flames!!

Is there anything else that could have done this??
as i had the batteries connected up fine!
XenonJohn (author) in reply to xiodeneMar 1, 2011. 7:10 AM
I have emailed you a new stripped down version of code that just balances the board, nothing else.

No extermal pots, values for overall gain, balance trimming etc all hard coded for now.

Once you can get it to balance you are 90% of the way to success. You can then add steering and other peripherals back in one at a time.

If anyone asks me for code from now on I will send this version also with main code.

John
XenonJohn (author) in reply to xiodeneFeb 27, 2011. 4:13 PM
All I can say is that according to the instructions, the sabertooth is supposed to be resistant to almost all forms of abuse except being connected up to battery the wrong way around. If overloaded it is supposed to have thermal cutouts to protect it for example.

Sorry not to be more helpful.

John
xiodene in reply to XenonJohnFeb 28, 2011. 7:31 AM
I have emailed the company i bought it from so will hopefully have some joy as i cant see what has gone wrong.

Silly question.... but you can use the ground on the digital site of the arduino board as a normal ground cant you?

XenonJohn (author) in reply to xiodeneMar 3, 2011. 4:53 AM
Yes, the GND connections on the arduino are all connected together, you can use any of them.

The 0V on the Sabertooth is connected to GND on Arduino.
The S1 on Sabertooth is connected to digital pin 13 on arduino with current software.
The other two sabertooth connections are not used.

The "dead man" switch is set up to feed a signal of +5V (from +5V pin) to digital pin 9, I put a 300 Ohm resistor in this line just to limit current, not sure if essential to do that..
Digital Pin 9 is also connected to GND via a "pulldown" resistor - about 5K will do. This holds it at 0V when the dead man button is not being pressed else the voltage the arduino "reads" at that Pin would drift around.

For the version of the code that just self-balances the board, then, assuming Gyro/accel outputs are connected to the correct analog pins, your board should balance.

A reminder:
analog pin 4 is used for accelerometer voltage intput to the arduino
analog pin 3 is balance gyro low-res input pin. (Y-rate)
hi res balance gyro input is analog pin 0. (Y-rate 4.5)

IMU also requires a power supply: +ve from the 3.3V output on the arduino and a wire back from IMU to GND on the arduino.

best wishes

John
kevman0044 says: Feb 20, 2011. 10:07 PM
What would I have to change in the arduino code if I wanted to use a potentiometer for variable turn rate?
XenonJohn (author) in reply to kevman0044Mar 1, 2011. 7:07 AM
There is an image on front page now of a version with a wii nunchuck attached. All I have done is solder wires to the two 10K potentiometers in the chuck thumb joystick, and to the buttons on the end to use them as my "deadman" switch.

Good thing about this is that the pots self-centre at about 5K resistance point. So with some experimentation you can connect them to an analog input each for steering left right and to fine tune the balance point using the forward back motion.

Two main values in code affect steering:
Steercorrect is a variable that is generated by second "headlock" gyro to make it resist slight turning forces, for instance if one motor has more friction than the other, to keep it in a straight line.

The other variable is "Steer". A value of zero is no steering i.e. keep going straight ahead, a -ve value is left and a +ve value is right. Do some experiments with hard codinjg in values for this but you need your potentiometer to vary the value of "Steer" remembering to code the data from your pot so that a Steer value of 0 is straight ahead.

Hope this helps

John
mwagner63 says: Feb 28, 2011. 3:35 PM
can you please send me the code my email is mattwagner92597@aol.com thanks
BIGHAIRYDUDE says: Jan 1, 2011. 4:21 PM
would the motors do well with 13" tires or would it require to much torque? for a segway type scooter not a skateboard
XenonJohn (author) in reply to BIGHAIRYDUDEJan 17, 2011. 10:07 AM
In theory tires can be any diameter. If the chain sprocket on the wheel is large, then you will have just as much torque as if using a small wheel.

Regarding torque, the key factor really is the diameter of the large sprocket on the wheel vs the diameter of the wheel itself. Big wheel with big sprocket means more torque but lower top speed, big wheel with smaller sprocket means higher top speed but less torque. If torque too low it won't have the power to balance you.

Somewhere in the middle is the "happy medium" and that is what may take some experimentation to get right.

Have a look at the original Focus Designs unicycle. It has a ???500W motor, a bike wheel and a fairly small sprocket on the bike wheel but it goes OK on the level. Hills might be a different matter.

I would start with larger sprocket so you know it will have the torque to balance you, then once it is working, go down a size if you have no intention of going up hills and would rather have a high top speed.

John
BIGHAIRYDUDE in reply to XenonJohnJan 18, 2011. 4:35 PM
thanks man and about the code you just copy and paste right?
emailadityaa says: Jun 28, 2010. 9:25 AM
hey pls send me the code and parts details from the list at my email addr :- emailadityaa@gmail.com 1.rhdolabz.com 2.simplelabs.co.in 3.technophilia.co.in 4.robokits.co.in thanx.
pramlie in reply to emailadityaaOct 13, 2010. 9:12 AM
Me too please. My email is pppramlie@yahoo.com. Thanks
glitchcannon says: Dec 12, 2010. 12:43 PM
how fast does it eventually go?
brian-finch2comcast.net says: Nov 18, 2010. 4:06 PM
Can i Have the coding you used for this
My email is brian-finch@comcast.net
neshavozdovac says: Nov 16, 2010. 12:30 AM
great project,
would you send to me code on email elmusic@open.telekom.rs
thanks
xiodene says: Oct 16, 2010. 6:49 AM
Hi this is a really great project!
I have started to buy the parts to build my own, could you send me the code just to make it balance please?
email addr : darkshadow242@hotmail.com
thanks
johndavid400 says: Sep 27, 2010. 7:11 AM
Nice instructable...
In some projects, you can get rid of the pull-down resistors by using the built-in pull-up resistors in the Arduino (no built-in pull-down resistors).... You must reverse the readings - ie. instead of activating the dead-mans switch when it is HIGH, you would activate it on LOW and leave it pulled-up the rest of the time.

just a thought.
XenonJohn (author) in reply to johndavid400Oct 7, 2010. 4:12 PM
Good point. Anything that makes it simpler is welcome!

When I find some time I will try that.


John
lgcalex says: Mar 21, 2010. 9:55 PM
 I wish there were more profound words for 'you rock'.

I've always wanted one of these. I think i'd be tempted to go for a one wheeled option and save on the motor but rely on more skateboard lean style turns. 

I think the cool factor is pretty important on these boards, its something the segway missed. 
XenonJohn (author) in reply to lgcalexOct 7, 2010. 4:04 PM
Here is a one wheeled one with a "Syren" motor controller (which is similar to half a sabertooth) and a 500W chinese electric scooter motor.
http://redmaxmonowheel.co.uk/uniboard.html

Here is a video of him on it and my attempt at a stand-up one wheeler:
http://www.youtube.com/watch?v=ygX7ukAIWn0&feature=player_embedded

It runs some of the arduino code from this instructable.


Also here is more info on my original one wheeler:
http://sites.google.com/site/onewheeledselfbalancing/

To be honest I still prefer my 2 wheeler skateboard having now tried most variations of the theme. It is very handy to have a machine light enough to just pick up and walk away with when you have finished playing with it.

Next mod will be to replace the nunchuck steering on my really nice twin wheeler with pressure sensors (pressure sensitive resistors) in the deck under the griptape so it becomes truly hands- free and more like a skateboard. This is main criticism of skateboarders/snowboarders who have had a go on it. I will have a switch so you can select between wireless chuck (easier for beginners) or pressure sensors to steer.

John
XenonJohn (author) in reply to lgcalexMar 22, 2010. 2:06 AM
Thanks for the feedback. One way to steer a 2 wheeler by leaning is to make the deck tilt and use a tilt sensor to provide the steering input to the microcontroller. This has been tried before with "Emanual" - see bottom of this page:
http://www.ebikes.ca/projects/Emanual/index.shtml
My problem with this was: it looks tricky to control / I knew in the end I wanted to but the batteries in the deck / I wanted everything under the board not on top, if it could be done. I could have cheated with a battery backpack and power cable down the trouser leg (which after you have stopped laughing would actually give you a really cool thin-decked small twin wheel board - as well as instant power shut off if you fell off), but I didn't want to do that.

I may use a carbon sheet for top of my deck just for cool factor. Also plan to improve turning software so the gyro that stops sudden spins is actually used to control the rate of turn proportionally to thumb joystick deviation. Should make turns more intuitive so you can lean into them.
John
mrityunjay in reply to XenonJohnSep 26, 2010. 11:11 AM
Hey can u plz send me your email add. i want to send u a code for varification wich i hav modified for l298 motor driver using your code.

my id is devilianmj@gmail.com

neways u hav done a very outstanding job...
thanx
XenonJohn (author) says: Sep 25, 2010. 5:00 PM
Wow, 5 stars. Thanks everyone.
John
geekflytk says: Sep 20, 2010. 8:43 PM
Can I lay this down horizontally, or does it HAVE to be standing upright? If it were to put it horizontally would I have to modify code?
XenonJohn (author) in reply to geekflytkSep 25, 2010. 4:34 PM
If horizontal the balancing gyro would still work OK as it measures rate of turning, not actual angle.
The accelerometer I have used would become the wrong one. You would have to measure voltages coming out on each accel pin to find the correct accel in the IMU for the new orientation.

The second gyro which detects sudden turns to left or right (when viewed from above) would now be in the wrong orientation. This second gyro is not required for balancing but the algorithm it feeds into is there to help resist sudden spins left/right as you are moving along if one wheel hits a small stone for example.....keeps you going in roughly a straight line until you enter a steering command....as in model helicopters.

In the photos you will see I soldered up ribbon vable to ALL the outputs of the IMU, even though I only use some of them, as much easier then to mount the IMU and work out with a voltmeter on other free ends of the wires which outputs I needed to use for any given mounting position.

So, in summary, you could lie it flat but some experimentation will be required. In particular one gyro needs to be turning on the fore-aft vertical "tilt" plane of the machine while the second (optional) "headlock" gyro needs to be turning on the horizontal plane to detect sudden turns to left or right as you are moving along. As there is an accel in all 3 planes, you need to just find the right one for the fore-aft plane once you have laid it flat.

Its a pretty small item compared to everything else, do you really need to lie it flat?

Best wishes

John
geekflytk in reply to geekflytkSep 22, 2010. 9:12 PM
What I meant was can I place the IMU down horizontally, or does it have to stick straight up somehow?
jrcnelson says: Aug 1, 2010. 12:41 PM
I have just about completed my Segway Clone utilizing your instructable, but would like to debug it before I put power to the motors. I am looking for the "test" code you have to verify that the accel and gyros are working right. On the instructables site, both links to the code examples are the same and are not the "debugging" code. Could you send it to me or tell me where else I can download it from? Thanks very much - this is the best instructable I have seen. -Jeff
XenonJohn (author) in reply to jrcnelsonAug 7, 2010. 1:59 PM
I keep attaching it to this instructable on first page and it keeps being magically removed after a few days - not sure why. Send me a message with your email address and I will send it to you. Best wishes John
Pooloop says: Jun 29, 2010. 3:32 PM
What the maximum amp that I can use on the baterrys?
XenonJohn (author) in reply to PooloopJul 15, 2010. 4:43 PM
Lead acids will give a very high current at least for a short while. This is one advantage of lead acids in this application (i.e. when about to fall off, motor really needs to rapidly move so it is balanced underneath you again - so draws high current just for a very short moment). The more exotic batteries such as the LiFePO4 ebike ones vary but are lower regarding peak current thery can supply (although store more charge for their weight in total). I burned out an OSMC motor controller the other day with 2 lead acids on it on my monowheel. It was hot day, poorly ventilated OSMC with no fan so my own fault. However with new one I now have a current limiting circuit breaker that will shut everything off if current goes above 75 Amps.
nielsdewinterr says: Jun 26, 2010. 12:56 PM
hi, i am dutch but can you please send the code... and also can you tell me witch motors you used?? because you say that u use 24 v but where did you get them... e-mail: nielsdewinterr@live.com tnx
XenonJohn (author) in reply to nielsdewinterrJul 15, 2010. 4:36 PM
Code link on title page. Right click and download it. It is an Arduino sketch. Motors: 24V scooter motors from ebay. 250Watt each. Search under "electric motor" or "electric scooter motor" and they will all come up.
nielsdewinterr in reply to nielsdewinterrJun 27, 2010. 12:35 PM
srry nielsdewinterr@live.nl
emailadityaa says: Jun 26, 2010. 1:13 AM
hey really nice project,Great Work..! would like to build my own could you please send me the code at emailadityaa@gmail.com pls suggest me the parts cauz here at india we dont get the parts that you have used. rhydolabz.com simplelabs.co.in technophilia.co.in http://robokits.co.in/ pls reply as soon as possible thanx in advance.
XenonJohn (author) in reply to emailadityaaJul 15, 2010. 4:34 PM
Code is there for you to download on title page 1 of the Instructable. You will have to adapt it to whatever micro you plan to use. You need a gyro and an accelerometer to get it to balance, again depending on what you can buy. John
Pooloop says: Jun 25, 2010. 7:20 AM
I think the input resistor are 25k ohms, http://www.instructables.com/image/FBIS0N6G6MPCNAP/Inputs.jpg Cheak pls
XenonJohn (author) in reply to PooloopJul 15, 2010. 4:31 PM
Brown Green Orange is 1, 5, x1000 = 15K Ohms John
emailadityaa says: Jun 29, 2010. 10:15 AM
emailadityaa@gmail.com
karandex says: Jun 11, 2010. 10:10 PM
I want to use h-bridge to make small segway with small gear motors, So how can i change code for serial output to sabortooth to l293's pwm and direction output. I know how to use h-bride , i just want to know how to interpret the serial code to pwm and 2 dir pins
TXTCLA55 says: Jun 11, 2010. 7:54 AM
Would it be possible to buy one? :P seriously!
karandex says: Jun 4, 2010. 7:48 AM
I read your code. I want to use a hbridge chip like l293. It got 3 pins for each motor, 1 for pwm and 2 for direction. I cant understand how to translate sabertooth serial to h-bridge. A code for h-bridge will be great. Thank you
tuzzer says: Jun 1, 2010. 12:19 PM
What kind of lead-acid battery did you use there? How many amp-hour should we get? And do the motors actually draw 20amp all the time? Just want to know how long could this skateboard run in one charge and see if I should get a heavier but a higher rating battery.

I am trying to build this and powered it with Lead-acid battery. However, I have not used lead-acid battery before. I read that the lead-acid battery cannot be discharged too much. How do you know when it has been discharged too much and when to charge it??
XenonJohn (author) in reply to tuzzerJun 3, 2010. 6:15 AM
They were two 12V 7 Amp hr batteries (but only because I had them from an old project).

Motors draw very little current maybe one or two amps from experience of others (the "Emanual" project) when balancing or moving along gently on a level surface. Some discussion on this lower down this page of questions and answers.

I used a 5 LED voltmeter display from a robot shop to tell me when to recharge (when only 3 of the 5 are lit I recharge it.

Here is a link to the ones I use:
www.technobots.co.uk/acatalog/Shop_Front_Battery_Monitors_24.html

Best wishes

John

xained says: May 31, 2010. 12:25 AM
Hi there!

First off: great project, thanks for sharing your knowledge!

I'm trying to build a similar project, and I'm following different instructables for this. (I must say yours is the biggest part, lol)

Could it be possible to get the code you wrote, for the Arduino ?!
(It's just that I don't want to invent 'hot water', when it was allready invented, years ago. Plus I'm more able to adapt code than to write it from scratch. I guess I'm not smart enough for that, lol)

My email is : Xained@gmail.com

Thanks for your time,
Keep on building !
Xai Ned
XenonJohn (author) in reply to xainedJun 1, 2010. 8:56 AM
There is a link to the code below the main picture on the main title page (which is below the 2 video boxes)

If having problems come back and I will email it to you.

best wishes

John
karandex says: Jun 1, 2010. 8:51 AM
 i want to make a smaller ver with 12 dc hobby motors , and a l293 motor driver. But can u suggest changes to motor driver part of code ?
As i can see its a closed loop robust system so can i scale it to a segway design or small self balancing robot ?

karandex says: May 28, 2010. 11:24 AM
I am from india and i dont have access to 5 axis can i use 3 axis accelerometer and single gyro ? I have access to this shop please suggest parts
rhydolabz.com 
XenonJohn (author) in reply to karandexMay 29, 2010. 9:59 AM
If I were buying from this supplier I would use:
MMA7260Q Accelerometer Module (1.5/2/4/6G ) as it has an analog voltage output.
LISY300AL Single Axis Gyro (300 degree/sec) as it has, again, an analog voltage output.
I put a link to my page describing how you scale the output from these devices in my previous reply.
This should get you going. You are going to need to do some experimentation and modify the code somewhat, I cannot give any guarantees everything will work first time. However I see no reason why these sensors shouldn’t work OK. I am happy to give advice but not going to rewrite the code for every single accel / gyro combination on the market – just don’t have the time. Best of luck.
 
John
XenonJohn (author) in reply to karandexMay 29, 2010. 9:50 AM
The minimum you need to get something to balance is a one axis accel and a one axis gyro like my original monowheel board has.
I put some notes on reading and scaling these here on my original website:
sites.google.com/site/onewheeledselfbalancing/Home/software-with-all-explanatory-notes-removed

The nunchuk / wiimote+ combination looks pretty complex to me. I put a link to it on page 1 of this instructable - good luck if this the way you really want go. I am no expert on that combination.
Montspy in reply to XenonJohnJun 4, 2010. 8:05 AM
I rewrote your code to use it with the WM+ and Nunchuk code from the Arduino forum (complementary filter). I'm waiting for parts to be delivered but I can send you the code if you want. Actually it's quite sure it won't work beacause I can't test the whole thing
karandex in reply to MontspyJun 4, 2010. 11:13 AM
Thanks but i desided to use IMU as i found a vender in my country. My thinking is that if there is project make it as the instruction say and then improve or customize on it and not to start from scratch
karandex in reply to XenonJohnMay 29, 2010. 9:10 PM
 thank you but i got a vendor in india with 5dof tenet technologies
is this code robust that if i keep the electronics same it will work with any low CG configuration ? I was thinking to build a prototype with DC motors, what rpm or voltage should i use ?
Also one more thing , can i make segway with it ?

Thank you for your valuable time.
mrityunjay in reply to karandexAug 5, 2010. 11:07 AM
hey i m from india too can u plz help wer u got 5dof ?
XenonJohn (author) in reply to karandexJun 1, 2010. 8:53 AM
To be honest more or less all of this has been discussed in this Q and A section.

Here is a page I made with links to every single amateur built self balancing skateboard / segway and other oddities I can find on the net. Plenty of people have built segway style vehicles along these lines (i.e. 2 x cheap 24V scooter motors from China).
Link:
sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects

So my answer is a) probably with some adjustments to code, b) 2 x 24V cheap scooter motors 250W or above, but on level ground may be OK with lower power motors c) Yes.

Best wishes

John



karandex says: May 28, 2010. 11:28 AM
 What your say on using wiimotion plus and nunchuck because the part you suggesting is twice the price of both in my country and i already have nunchuk
what changes should i make to code and hardware ?
Snoochy says: May 18, 2010. 2:07 PM
Hey John, I found your Instructable inspirational and decided to get off my procrastinating butt and try and build one for myself. For the past two months I've been slowly saving for and purchasing the parts and just made the final one for the Sabertooth motor controller. I'll post where I sourced and the prices if anyone wants to see the cost involved from my round of purchasing (I live near Seattle, WA).

For anyone else doing this (with less experience on the electronics side, like me), I strongly suggest starting out by buying the Arduino board and some supplies...or learning to recycle from old equipment. I bought my first board with a couple used books as my first purchase and have thoroughly enjoyed playing with it while saving for the other parts. It's kind of an eye opening journey. 

Thank you for the wonderful Instructable and great responses to comments and questions. I'm sure I will have some before I successfully complete the project.

Peace.
TSC says: May 11, 2010. 7:15 PM
5 stars!!!
Accentrix says: Apr 26, 2010. 1:40 PM
I think this project has globally caused the 'Razor E100 rear wheel set' to be out of stock.
XenonJohn (author) in reply to AccentrixMay 8, 2010. 3:04 PM
Any chain driven wheel from rear of a small electric scooter would probably do. It was just that the razor one seemed so "all inclusive" as a package.
Montspy in reply to AccentrixApr 28, 2010. 10:09 AM
Yes ! monsterscooterparts.com should have new stock 03/05 or 05/05 I don't remember what they said
Accentrix in reply to MontspyMay 7, 2010. 11:23 AM
I have all of the part to build this with exception of the wheels... :(

Razor should have been better prepared for this :)
Montspy in reply to AccentrixMay 19, 2010. 8:59 AM
MonsterScooterParts ETA is now June 14th -_-'
Accentrix in reply to MontspyMay 19, 2010. 12:11 PM
I managed to order and receive mine from:
http://www.scooterpartscatalog.com/e100-chain-wheel-assembly-119-46.html

Although it was a bit mor expensive at $29.99 each.... : /

aaronbot3000 in reply to AccentrixMay 20, 2010. 5:38 PM
Razorama has stock!

http://www.razorama.com/razor-e100-e125-e150-e175-rear-wheel-.html
djdenny56 says: May 7, 2010. 6:19 PM
will the file for testing the gyro and accelerometers outputs work with ONLY the IMU 5 dof connected to the arduino and nothing else? or do i need the motor controller, steering etc. connected as well?
XenonJohn (author) in reply to djdenny56May 8, 2010. 3:02 PM
Motor controller does not need to be connected.
It will display the value from the overall gain potentiometer so you can check it is working but will still work if pot not connected.
Steering inputs all disabled.

All you need is arduino powered up and the IMU connected.

Start it with IMU tilted and stationary, then slowly bring it level (IMU board board now perpendicular to ground as it would be in real board) and it should start spitting out data into the serial viewer window.

John
BIGHAIRYDUDE says: May 3, 2010. 3:07 PM
hey, i am building my own but i am modifying more to a segway type thingy and just so you know it costs roughly $350 in u.s. i should be done with the instructable in about 4 months because i have to save up for the motor controller and gyro. pretty cool, this instructable is.
Kresjan says: May 2, 2010. 3:38 AM
Hey thanks for this great instructable!
im building my own at the moment.

Could you tell me a little about the lithium battery you bought for your other board?
the problem is we're running two motors and its hard to find packs with a bms that can handle the peak currents this build theoretically can do.
what are the specs of your pack and where can i buy it?
XenonJohn (author) in reply to KresjanMay 2, 2010. 5:04 PM
The other thing is that I really would not spend big money on batteries until you can get it to balance.
Could always use 2 car batteries and some 6ft long wires if it came to it. That would be enough to test it. Due to the reduced weight of not having the batteries "on board" you might have to turn gain down a bit (or put some weight on it) else would be a bit twitchy, but it should still balance.
XenonJohn (author) in reply to KresjanMay 2, 2010. 8:18 AM
It was a 24V 10Amp-hour LiFePO4 e-bike battery from a Hong Kong supplier on ebay. It was not this one but very similar to it:
cgi.ebay.com/24V-10AH-LiFePO4-Electric-Scooter-E-Bike-Li-Fe-Battery-/260579935187

You are right though: The max "rated" curent is 10Amps and as you say, the Sabertooth and motors can in theory draw more than that.

I have not had any problems so far however but have not tried this board up hills just very slight inclines.

My monowheel worked up hills but that had 2 biggish lead-acids in it.  
Also when dissecting the ebike battery, I noticed the metal strips joining the banks of cells together were very thin, like thick foil almost. Therefore I am not sure if the 10Amp rating is due to the thin metal inter connections, or a property of the cells themselves.  What happens when an e-bike goes up a hill? Does everything just burn out? I find this “rating” odd when the intended commercial application (an e-bike) is such that the battery pack will be used most when going up hills – where all the same problems and concerns would also apply.

Maybe best to try an e-bike forum as these guys spend a great deal of time discussing different types of batteries.

 Best wishes  John
technoguy94 says: Apr 29, 2010. 9:57 AM
I know you're trying to keep it cheap, but could you at least have the wiring diagram+program for the nunchuck? I don't know about anyone else, but I would prefer it if/when I build one.
XenonJohn (author) in reply to technoguy94May 2, 2010. 5:01 PM
Here is an instructable on a general purpose arduino / standard Wii Nunchuck interface I have just done. There is plenty on the net on this but this should be a reasonable way to get something working.

www.instructables.com/id/Wii-Nunchuck-as-general-purpose-controller-via-Ard/
XenonJohn (author) in reply to technoguy94Apr 29, 2010. 2:16 PM
Having enough trouble keeping up with all those attempting to self-balance!

I think best thing would be for me to make a separate instructable on how to steer something with a wired and a wireless nunchuck and then put a link to it here.

My wireless nunchuck board uses an arduino just to continuously read data from the wireless nunchuck. It then varies voltages on the output pins which are sent to the steering inputs of a separate (older, non-arduino) board that is controlling the balancing and power to the wheels.
Montspy says: Apr 20, 2010. 10:19 AM
Thanks a lot for this awesome Instructable !
I'm trying to modify your code to use it with Nunchuk and Wii Motion Plus IMU but I don't understand this line :
x_accdeg = (float)((accsum - (350 + balancetrim))*0.862);
- How did you found the 350 value ?
- if I understand, accsum is the filtered value of the Z axis accelerometer, so how do you find an X axis accel value ?

Thanks again.
XenonJohn (author) in reply to MontspyApr 29, 2010. 2:05 PM

accsum is a value from 0 – 1023. It is derived from the most recent seven accraw readings (also on the 0 – 1023 scale) from the accelerometer (one reading per loop of the program). You could just use mean of last 7 readings but the Savitsky Golay filter I have used (hence the strange maths to calculate accsum) filters out more noise than a rolling mean and yet still gives a more up to date “true” value. A rolling mean is always slightly out of date.

If the mid point output voltage from the IMU (when IMU held vertical) for the accelerometer we are using was 2.5V then the arduino analog input pin (which reads 0V as a value of 0, reads 2.5V as a value of about 512 and reads an input of 5V as 1023) would return a value of 512.

However this particular IMU is supplied with 3.3V, not the 5V we are maybe more used to, and when level (board perpendicular to ground) the voltage coming out is about 1.7V (I measured it with a digital voltmeter), not the 2.5V we might be more used to expecting.

So 1.7V at the arduino input (designed for inputs from 0V to 5V) gives a value of about 350 when board balanced (i.e. not 512).

Tip it one way and the value will drift below 350 and the other way and it will be more than 350.

In all our subsequent maths we want "balanced" to give a value of 0, tilt one way and value goes -ve but tilt other way and it goes +ve.

So we get the value of accsum (which using above logic will be 350 when board level) and we subtract 350 from it to get a value of zero when the board is level. Tilt one way and the value will now go -ve, tilt other way and it will go +ve. We add a small "balancetrim" value to the 350 that is then subtracted (it can be a -ve or a +ve number) according to use of the balancetrim switch. This adds a little bit to the 350 or takes a bit away from 350 before their total is then subtracted from accsum and this feature just allows user to fine tune the balance point of the skateboard.

We then multiply [accsum - 350 (plus or minus the small correction factor)] by 0.862 to convert it to an angle in degrees - just a small tweak - a scaling factor. We use degrees at this stage just because we remember from school what 90 degrees looks like, and can roughly work out what 30 would look like and so on.


I use the Z accelerometer simply because the way the IMU is bolted to my skateboard, it is the z-accelerometer which actually ends up in the correct plane of movement to measure the tilt of the board - that is all.

I hope this helps everyone

Montspy in reply to XenonJohnApr 30, 2010. 7:53 AM
Thank you !
I unerstood everything, I hope my board will balance !
jongscx says: Apr 16, 2010. 11:33 AM
Just a couple of things that might have been addressed already:

1) I'm sure it was because you already had the board up side-down when you were building, but mounting the electronics on the underside seems super risky.  Sure, it's fine when you're demonstrating in an controlled environment, but one stray rock and you could brick your arduino or ESC.

2) Same thing wth the exposed motors and drivetrain.  you could probably add some cheap sheet-metal skid plates and it'll double as a chain-guard.

3) wiimote nunchuck! as hand controller.  http://hackaday.com/2009/03/30/arduino-wii-nunchuck-servos/

hope that helps.
XenonJohn (author) in reply to jongscxApr 29, 2010. 2:24 PM
I agree, my board with the batteries in the deck has the controllers etc under the board but encased in polycarbonate so you can see everything but damage resistant to small stones etc.

There is still no way I would ride it on a wet surface though!

It does take longer than you think to make neat enclosures.
dbasner says: Apr 5, 2010. 8:16 PM
 First I would like to say that you are doing a really great job documenting this, as well as answering everybody's questions.  I am a highschooler trying to scavenge some leftover parts to build something like this.

  Here is my question:
although they are of a much lower spec, I have a few Victor 884 motor controllers (handle 12V, I know, pretty low) laying around from FIRST robotics (dean kamen sponsors it!), and I was wondering if I could use them instead of OSMC's as they are really expensive, specs:

      Victor 884:
12V 
PWM input
40A capacity

If they aren't up to spec, could I use lower power motors and just deal with the slower speed? If so, any motors in mind? If you can't answer the last question that is fine, I don't expect anybody to know any off the top of their head.  Again, I really appreciate you documenting your build!

Thanks,
Daniel
agent in reply to dbasnerApr 18, 2010. 6:12 PM
Test the Victors, then see if you can test some Jags :D
Foxx in reply to dbasnerApr 14, 2010. 9:40 PM
 Criten and I have made a board that works rather well in less than 4 days. As he mentioned, we're using Victor 883's, 2 CIMs and the Kit Transmissions from 2005. here is a video of it balancing and riding around a small space. It doesn't have controls for turning yet, but its a work in progress
Criten in reply to dbasnerApr 12, 2010. 5:26 PM
 I'm using Victor 883s and they work great. I am using them with CIMs and they are MORE than powerful enough for this application. Although you do need to re-do the motor controller code. IM me if you ever get around to the coding part and ill send you what you need. Unless you already got it figured out :P
dbasner in reply to CritenApr 12, 2010. 7:53 PM
 Thanks for the information! I sent you a private message thing, but it didn't give me any conformation on if it was sent, so I will comment here as well.  I want to do the coding myself, but if I could look at your code/whatever you plan on sending for a basic idea of what need to happen, that would be great! what exacty is wrong with the original motor control code? my email address is (dbasner (at) gmail (dot) com) I really appreciated this!

Thanks,
Daniel
XenonJohn (author) in reply to dbasnerApr 6, 2010. 7:03 AM
They would probably work OK on level ground.

12V 40A is equivalent to 24V 20A in terms of power they can handle in Watts. The sabertooth controller I used is 24V 25A each channel (40A peak) per channel, so I presume yours might work OK.

Also they have to be able to run in both forward and reverse directions to enable balancing on the spot (but interestingly not while moving along where it is just acting as a variable throttle - think of a motorbike doing a very long wheelie).

The guy who built the "emanual" board measured just a  couple of amps being drawn when he rode it along a level sidewalk. http://www.ebikes.ca/projects/Emanual/

You only really need max power when going up a hill, or about to fall off when motors need to speed up very fast to rebalance underneath you.



Could use a pair of powered wheelchair motor/reduction box/wheel combinations but I think they are usually 24V as well.

Alternative is motor/rear wheel assemblies from two broken electric childrens scooters. Smaller ones are 12V. Not sure if powerful enough to keep you balanced but might be if you are taking things easy on a smooth level surface.

I hope this helps a little.
dbasner in reply to dbasnerApr 5, 2010. 8:19 PM
 Also, I already have a broken electric scooter (the pin on the charger got bent and fell off, inside is OK I think), Could I just use the motors and wheels from the scooter? Its the same model if not more powerful/new.
XenonJohn (author) in reply to dbasnerApr 6, 2010. 7:10 AM

I think the smallest scooters like this have 100W motors. Not sure if a 2x 100W skateboard would be powerful enough to balance your weight but it might ust about be on a level surface.
If not, well you would have just built yourself a self balancing robot platform.

The hardest part is getting it to balance. If you get that far you might have the confidence to scrounge/beg/blow some more money on bigger motors - you would already have done the hardest part.

2 x 200W or above would be fine. The board I showed has 2x 250W motors and I am a far from "average" 70kg male (think heavier!).

By the way, there are two other guys from FIRST robotics also having a go at building one of these from old robot parts and things they already have lying around.

John

thelastonekills says: Apr 17, 2010. 11:04 PM
it is cool. could you put a few tilt sensors or some thing in it so it balances it self and all you have to worry a bout is direction and speed 
agent in reply to thelastonekillsApr 18, 2010. 6:11 PM
Can't you read? "Easy build self balancing skateboard"
XenonJohn (author) says: Apr 3, 2010. 4:14 PM

4th April 2010:
I have added pages at the end showing the same hardware now mounted onto a large skateboard deck. This has allowed me to ride it and compare with my other board.

Consequently I have adjusted the software to tighten up the ride, fixed a small bug, and have also altered the steering so the rate of turn is now held constant under guidance of the second gyro.

Link to new code is still on page 1.
Everyone who has previously emailed me for the code has been sent a copy of the improved version.

John

longhairedartist says: Apr 1, 2010. 9:51 PM
Have you considered an "in line" arrangement of the wheels along the length of the board instead of parallel? I mention this with a throwback to the cars on orbs in the movie iRobot. I think orbs on the far ends would allow much greater turning torque potential (for those crazy enough to attempt a triple lutz). By using orbs, you can operate the balancing feature in more dimensions and not just in the same direction of travel. It seems like this orientation is the next step.
cdogjune says: Mar 31, 2010. 7:33 PM
Has anyone started playing with the cheaper accelerometer?  Is it a direct wire?  Do you need to modify the code?
XenonJohn (author) in reply to cdogjuneApr 1, 2010. 4:20 AM
For any gyro / accel combination you may have to modify the code. The thing is to look at the datasheet (usually downloadable as a pdf). It will tell you how much for example the output voltage from the gyro changes for any given rate of turning.
The things to alter in code then are the scaling factors.

In my code I always start by calculating rate of tilt (tipping) in degrees per second, or in the case of accelerometers, the angle from vertical in degrees. -ve values are tilting/tipping anti- (or pehaps counter-) clockwise, while +ve values are tilting/tipping clockwise.
If the scaling of the voltages from the sensors allows you to get that part right, the rest of the code should then still work OK.
Also is very easy to accidentally get one of the accel and gyro pair back to front, so the effect of one is opposing the other! Not such a problem nowadays as they tend to come on the same small circuit board.
Kresjan says: Mar 29, 2010. 10:48 AM
Hey great instructable i am thinking of building this and was wondering about the Sabertooth can it run on 29v and can the motors be 350w? would this kill the sabertooth or will it be ok?
XenonJohn (author) in reply to KresjanMar 30, 2010. 10:21 AM
It does say 24V max (6v min) on data sheet.

It can supply 25A per channel. (50A peak)

Watts is Amps x Volts so can theoretically cope with 600 Watts per channel.

So, 29V - maybe risky.  350W no problem by the look of it.

Check out combat robot websites if you want to look at other makes of controller that will take higher voltages, lots of them out there. Sabertooth is just quite easy to set up, has lots of modes, just 2 input wires, and current overload protection which is why I chose it.
OSMC for example has 5 input wires as opposed to just 2 on sabertooth so a little more fiddly to set up, bearing in mind I was trying to make this project as easy as possible to build.
Kresjan in reply to KresjanMar 29, 2010. 10:53 AM
 oh and also can i use a Pot for directianal control as in left right?

XenonJohn (author) in reply to KresjanMar 30, 2010. 10:14 AM
Yes you can. You need to change the code slightly. There is one spare analog input I have not used. You could read that pin with a potentiometer sending a variable voltage to it, then use the value to control the relative power sent to each motor.
Basically you let the balancing algorithm do its job then when it has worked out the motor speed it wants, add a bit to one motor setting and subtract same amount from the other depending on the pot value.

If you look at the code you will see what I mean.

I have also just worked out some code to make the second gyro control the rate of turn proportionally to the pot setting.

Maybe I should post 2 sets of code. Basic to get it balancing (the most important part by far), then another set with some extra features added.

John

fixitmankeith says: Mar 29, 2010. 10:35 AM
My parts are ordered. The 10K potentiometer has three connecting points. I can only see where one wire is connected. Would tell me where to connect all three wire's. I can't wait to get my parts and start riding.
XenonJohn (author) in reply to fixitmankeithMar 30, 2010. 10:06 AM
Potentiometer has three pins in a row. Resistance across the far left and far right ones should be 10K Ohms. This means centre one is the "wiper" moved by the control knob.

Connect the far right one to a +5V supply pin on arduino (designed to supply things like this).

Connect the far left one to one of the GROUND pins (marked as Gnd).

In each of these 2 wires put a small resistor about 150Ohm just to stop the full 5V being sent to the analog input pin with no limit on the current when wiper is turned fully across to the 5V side. May not be essential but I have done this just to be on the safe side.

The wiper (middle pin) now will read anything from 0 to 5V (approximately)as you move it around, if you put a voltmeter between it and ground - worth doing just to check it is working properly.

The wire from this centre pin therefore is now connected to the analog input for the "overallgain" control.

Once you have it working you might want to just fix an "overallgain" value in the arduino code later on and get rid of the potentiometer. However it is also useful for experimenting with other variables in the program while machine is running.
siedpe13 says: Mar 29, 2010. 7:55 PM
anti-clockwise, lol, i believe the correct term is counter-clockwise. But im seriously considering to follow this tutorial as it is so well done putting this together should be do-able
john henry says: Mar 28, 2010. 6:18 PM
i live in the US and i found all this would cost me 366 but i picked 350V motors so its a little more costly . i added 2   12V jell acid batteries. and not including shipping cost.
it would be 189.62 GBP but some of my parts dont ship internationally sorry UK.
but for US people here my list.
motors
http://www.monsterscooterparts.com/24-volt-350-watt-motor-razor-dune-buggy.html
motor driver
http://www.robotshop.com/dimension-engineering-sabertooth-2x25-6.html?utm_source=google&utm_medium=base&utm_campaign=jos
arduino
http://store.fungizmos.com/index.php?main_page=product_info&products_id=180&zenid=f83805e1ebcc8fa5832924e5a80ad755
wheels
http://www.monsterscoothttp://www.monsterscooterparts.com/rae1rewhasch.html
IMU
http://www.sparkfun.com/commerce/product_info.php?products_id=9268
batteries
http://www.ambientweather.com/tdwgi12vb.html

your welcome!
alienwear says: Mar 26, 2010. 3:10 PM
I don't have any idea how realistic this comment may be, but how about using some form of piezoelectric for turning? This would enable leaning and remove the need for any form of hand controller (so long as the adjustable balance point was not needed).
XenonJohn (author) in reply to alienwearMar 27, 2010. 3:54 AM
I agree. The turning software is at present quite crude - tacked on at the end. I want to use the gyro that stops sudden spins to actually maintain a set rate of turn, slower turn rate if you are going faster, and make it proportional to input (joystick or pressure sensors). That way the nature of the terrain within reason should not affect it.
By making the turns feel better for the rider this way, should be able to turn while going fast and lean into the turns, like you do on a normal skateboard.

Incidentally, for balancing, the machine does not have to be symmetrical i.e. weigh the same each side of the wheels, as you just stand a tiny bit off centre to compensate.
For turns though at speed it would matter (think of an early Porsche 911 swapping ends on a bend).
mspark400 says: Mar 22, 2010. 11:44 AM
Excellent project and excellent documentation. The world of diy self balancing projects was really in need of a step by step low cost solution, myself included.
One question however. your motors peak at 250W each. your motor controller is much much less than that. Now i understand that you would probably need to have a death wish to try an use all of the motors power but couldn't speed be greatly increased (if desired) by using a higher wattage motor controller. This might increase cost a little but an OSMC (1 or 2) might be an option to consider for those seeking speed. The batteries would  be able to provide more amperage (shorter ride time of course) but also higher amp hour batteries would increase speed and runtime if the constructor was willing to pay a little more. However your design is an excellent one for the price and I am sure it will be very helpful to those wishing to duplicate this design.

Cheers,
   Mspark400
XenonJohn (author) in reply to mspark400Mar 22, 2010. 3:18 PM

Well spotted error of mine!

I have changed page 26 describing the Sabertooth. I said 2x25Watts when of course I should have said it can handle 2x25 AMPS (40 peak) per channel (forward or reverse).
   This is a Sabertooth 2 x 25Amp (40Amp peak) robot motor controller for medium sized robots with 2 motors.
The motors I have are 250 Watt 13.7 Amp peak (that is what it says on them). Watts = Amps x Volts and I have 24 Volts so that makes 10.4 Amps using that calculation. Anyhow, well within limits of the Sabertooth. Could actually go up another motor size.
   My one wheeler has an OSMC and a golf cart motor rated at 500W but it is a real beast of a motor. It will easily get up a modest slope. Have not tried it on steep uphill as don't want to risk burning out the OSMC (although you probably wouldn't).
   On the Emanual 2 website he had 2 hub motors from ebikes and measured just a couple of Amps being drawn when going along a level pavement.
   Re batteries: My really nice twin wheeler has LiFePO4 batteries from an ebike (good for 20 miles plus) dismantled and laid out flat within the deck. Entire deck is actually a battery. This was a seriously expensive battery, even from Hong Kong supplier, and it ran all day long at maker faire and charge status LED bar was still saying full charge. Lead acids however do have an advantage that they can throw out a very high current for a short time - useful in this sort of project if you are about to fall off as motor wants to boot up very fast to prevent this happening.
   With this project I have really seriously honed in on bringing down the cost. If someone is unsure of they will get it to balance - a reasonable concern, they don't want to spend a fortune straight away. Once you can get it to balance, you then have the confidence to blow a load of money on a clever battery, I agree. Could have bigger wheels, bigger motors, sure.
   Combat robot builders point out that best way to burn out a motor controller is go go for full power while motor i.e. wheel is jammed stationary for some reason. However, the Sabertooth has an overload cutout that should save it from burning up in this way.

Thanks for spotting my mistake and nice words.
John

PS I am really amazed, I am getting about 200hits an hour right now. It must level off soon. Can only be so many people out there into this niche subject.

Bowtie41 in reply to XenonJohnMar 26, 2010. 11:11 PM
It's not a niche subject by any means.Loads of us would like to have a Segway,but this is a neat,fun,CHEAP alternative,that people can say"I made it myself"!!Excellent Job!
lgcalex in reply to XenonJohnMar 23, 2010. 9:13 AM
hackaday.com/2010/03/21/balancing-skateboardsegway/ You were posted on hackaday.com


XenonJohn (author) in reply to lgcalexMar 25, 2010. 10:26 AM
Instructables viewers seem to be a much nicer and more constructive bunch of people!
valhallas_end says: Mar 26, 2010. 6:45 PM
Heh, this came at an opportune time - the day after we learned our final project for my Control Systems course will be to write a control code (from scratch) for a self-balancing robot.  Granted, ours won't be applicable to Arduino platforms without serious revisions, but I'm quite tempted to build something like this myself now.  I'd like to see if I can create my own custom code.
Excellent instructable!
Rportal says: Mar 26, 2010. 11:41 AM
would it be possible for a parts list, for the two wheel.
all you have on your site and instructables are for the one wheel
XenonJohn (author) in reply to RportalMar 26, 2010. 3:06 PM

The parts list on front page is for the two wheeler in the instructable. You do need two of the motors and two of the E100 rear wheel units.
I have said wheel sets (x2) and used the word motors.
I should maybe say chains with an "s" at the end.

You only need the one sabertooth 2x25 though as it is designed for 2 motors, one for each side of a robot, one arduino board and one IMU. I will change the parts description slightly.

Best wishes,
John

PerfectionLost says: Mar 25, 2010. 2:38 PM
What is the top speed?  You dont seem to cover distance in any of your videos either.
XenonJohn (author) in reply to PerfectionLostMar 25, 2010. 3:17 PM
Not sure why so many (on other forums mainly to be fair) find the top speed so important. When you are riding on 2 wheels being balanced by a computer you are limited by raw fear rather than the mechanicals. Not the best design for outright speed.

500Watts of combined motor should push you along pretty fast on the level if you have courage enough. My 2 wheeler seems to peak at about 10mph at the moment but that may be software related (always need some power in reserve in case you are tipping forward at speed so it can speed up some more to correct it). Monowheel has a buzzer warning you when at 75% of max power to motors (have never been brave enough to make it go off).
  Distance: Segways, electric scooters, go-peds etc all banned from public sidewalks in UK. Will actually be stopped by police. Private land only i.e. my front driveway in early videos (which slopes).
Makerfaire video was first time I had big space to ride it round (a large marquee and an indoor exhibition centre). Also rode around large open square (not filmed).
UK much smaller, built up and densely populated than US!
Maybe should take it to the Netherlands: big, flat, open, everyone cycles, segways legal. Someone there may build one by the look of it.

For speed I would get an e-skateboard, the big ones do up to 35mph.

The advantage of these are actually low speed control: I could ride it between all the visitors at any speed down to completely stationary (but still balanced) also able to turn round while stationary. The visitors didn't have to jump out of the way when they saw me coming.

John
PerfectionLost in reply to XenonJohnMar 25, 2010. 4:57 PM
Top speed is important, though I suppose actual speed is just if not more important.  My car can probably go around 200 mph even if I usually only drive it around 65.

Maybe a better question is, would I want to use this for a short commute, where I would be walking otherwise.  All the videos seem to be using it in a fairly confined space.  That would make this a novelty item.  If you could use it for a short commute, or while bar hopping that extends it to something that is generally useful and awesome.

As someone who has never been on a device like this its somewhat important for a frame of reference.  I've biked distances, and I tend to go between 10-15 mph.


Fox-san48 says: Mar 23, 2010. 8:11 PM
Uk rules :D,

and i love it, altho i dont know what that aurd... thing is, i have seen it in loads of insturcibles
XenonJohn (author) in reply to Fox-san48Mar 24, 2010. 11:19 AM
The Arduino is an AVR microcontroller (a small computer on a chip) mounted on a small circuit board. The board has power supplies sorted out for you plus pins down one side that accept variable voltages from sensors for example (0-5V) and pins on the other side to that can be used to control other devices (in my case the unit sending power to the motors).
It is open source so anyone can make and sell them. Anyone can write software for them and put them on the forums. Loads of code on the forums you can use and modify for what you need to do. They are great for beginners as you program them in a version of the language "C" that essentially has had most of the tricky bits taken out and done for you.
You program via a USB cable. You can send data (various variables in your code for example) from the program back to the screen of your PC very easily to help debugging. Also they are quite cheap for what they do.
If you look on Amazon for example, there are books on getting started with Arduino. If you are more keen on getting something up and running fast than having perfect code, at reasonable cost, with huge friendly forums to help if you get stuck, Arduino is a great way to go.
Hope this helps,

John
Fox-san48 in reply to XenonJohnMar 24, 2010. 4:22 PM
thanks, although is "C" easy to learn, atm i know Batch basicly and some html. i looked Arduino up, im guessing having a soldering iron would be useful for connecting to other devices? unless ofcourse they have those screw connetion things. sorry about my bad techical language, funny i did electronics last year and year before only reason i stopped is i moved to australia (sucks i know, england is better still lol) anyway getting off topic
thanks anyway :)
it did help
XenonJohn (author) in reply to Fox-san48Mar 25, 2010. 7:35 AM
I bought an arduino beginners kit which some websites sell that gives you an Arduino board, a breadboard, a set of small peripherals (simple temperature sensor, small motor, some LEDs and so on) and a set of tutorials that take you through basics of writing code, reading from sensors and controlling things as a result.

Work through that (wouldn't take that long) then start looking at examples of code on the forums.

I would say that is probably fastest way to learn.

Don't need to solder to get that far just use the breadboard and jump wires.

I think for projects generally though it would be worth learning to solder. It's a bit like how you learn to weld (get some old steel and just start having a go) but a lot easier - just get some old components and boards and start having a go!

Maybe start by trying to make up one of those small electronic project kits where everything is in the kit.

Hope this helps,

John

Fox-san48 in reply to XenonJohnMar 25, 2010. 3:59 PM
ah thanks, i was just wondering, i know how to solder though, did it during electronics
thanks :)
Fox-san48 in reply to Fox-san48Mar 23, 2010. 8:15 PM
Arduino*
gabo90 says: Mar 25, 2010. 12:16 PM
Congratulations!!! I think it woulb be so cool if the board was made of plexiglass instead of wood, so people could see through and how it works... ;)

XenonJohn (author) in reply to gabo90Mar 25, 2010. 2:11 PM

Motors bolted to deck to avoid welding. Has to be pretty rigid else chain tension would vary as base flexed. Maybe very thick plexiglass might be OK!

Could put motors on top and batteries underneath, see page 13, that would give you a machine with loads of visible moving parts.

Also, I spent so much time dismantling an e-bike battery and arranging the cells flat in the deck of my own twin wheel board that I did make the underside of clear polycarbonate.
Here:
sites.google.com/site/onewheeledselfbalancing/Home/2010-twin-wheeler-rebuild
Also I can then see if anything is melting when I am charging it!
Unfortunately as the cells are pink it looks like rows of sausages.

godofal says: Mar 25, 2010. 5:58 AM
this looks pretty interesting, and im thinking of building one, but i could use some more specs on the parts, especially the battery, the motors and the wheels that you used.

and any chance on an instructable with the nunchuck version?
godofal in reply to godofalMar 25, 2010. 11:28 AM
btw, i just realized.
isnt it cheaper to just use an atmega328 with some components like the crystal and such soldered to eachother on a protoboard of some kind?
just use a 6pin header for the programming (use a DAPA cable if you want it really cheap)

maybe im talking really dumb atm, i havent exactly looked at the prices, but i cant imagine that a loose chip, some components and a piece of protoboard is more expensive than a full arduino...
XenonJohn (author) in reply to godofalMar 25, 2010. 2:04 PM
Yes, you are probably right.

There were 2 aims, low cost but also relatively easy buildability (no welding for frame for example).

I am using a standard Arduino board just to make the microcontroller part as simple as possible to build and program.

XenonJohn (author) in reply to godofalMar 25, 2010. 8:03 AM

Find an electric scooter website thats sells the Razor E100 scooter.
Early versions had a belt drive but most now have chain drive.

Go to spares section and find an "E100 rear wheel assembly" this gives you entire wheel, with sprocket fitted, bearings, and axle all assembled for you.

Go to ebay and look under "electric motor".

Among all the rubbish, some motors that look exactly like the ones I have used will come up. They just vary in maximum Wattage rating up to about 500W. They have a small sprocket already fitted.

One or two old stock smaller ones have toothed belt drive wheel fitted - you do not want one of those. Check the image before you order and check there is a chain sprocket on the motor spindle.

I dont want to really post links to any specific sites but google will find them for you.

John

XenonJohn (author) in reply to godofalMar 25, 2010. 7:52 AM

Battery was nothing special. Two 12Volt 7 Amp/hr lead-acid batteries in series to make 24V. Can be any physical shape. My monowheel has 2 x 12V 14 Amp/hr batteries - just gives you more endurance.

NOTE: Don't put 24V into Arduino board - the smoke will come out. This is why in mine I gave it its own 9V battery.

Car batteries would be fine for playing about but way too big for finished vehicle.

Electronics shops like Maplin just have them in stock all the time, as do robot websites if nowhere local has something you can use.

godofal in reply to XenonJohnMar 25, 2010. 11:37 AM
thanks for the quick response!

ive been looking at the razor site, but they dont ship to the netherlands as far as i could tell...

as for the motors, i can find alot of 24V 250W motors that look like the ones that you used, and the price is about the same, but shipping is about the same price as the motor itself, did you have this also?

as for the battery, how long do you last with those 7 amp/hour?
i can find alot of 12V lead-acid batterys, so that shouldnt be a big problem...
XenonJohn (author) in reply to godofalMar 25, 2010. 2:22 PM
OK, here we go, this is the webstore in UK I got the rearwheels from. Scroll down page to the E100 rear wheel (has picture to left of it):

www.skatehut.co.uk/acatalog/Razor_replacement_whees.html

They may not ship from US, but you may be more lucky with an EU distributor like this regarding shipping to Netherlands.

Motors are strange. 2 years ago there were masses of them on ebay. Now far fewer. Not sure why. Again if you are desperate, the scooter shops themselves sell them of course.
NOTE: the “proper” motor for the Razer E100 is actually quite small. You need motor designed for a bigger scooter (if you are trying to get it from a scooter shop spares dept, around 250Watt or more I would say).


godofal in reply to godofalMar 25, 2010. 11:47 AM
one more question, how do you charge those batterys?
XenonJohn (author) in reply to godofalMar 25, 2010. 2:26 PM
Electronics catalogues have small 12V trickle chargers with clips on end of red and black wires. I got mine from a local Maplin store. Not fast but safe. Buzzes when battery fully charged (overcharging can shorten battery life).
All online robot shops have chargers too.

Car charger might be too fierce.
godofal in reply to XenonJohnMar 26, 2010. 5:29 AM
hmm, i might have a try with the barebones atmega328 (interested in pictures?)

i loved the fact that the euro is high and the dollar is low, so i might check some other shops online in the US, and maybe the netherlands, to see wich one sells the stuff the cheapest (hey, its supposed to be low-cost XD )

and about the charging, ive got a 12V trickle charger solar panel, im guessing it wont charge fast, but would it charge or just maintain the voltage?
godofal in reply to godofalMar 26, 2010. 6:01 AM
i just found this:
razor e100 rear chain driven wheel

this is the cheapest i could find, but they dont do international shipping standard, so im not sure if anyone outside the US can get them easy, havent tried yet, il post my experiences with them when i get them...
EmmettO says: Mar 25, 2010. 10:25 AM
 I've been slowly collecting parts for a personal vehicle like this (slightly larger). Other than the Sabertooth I have all the parts! The code for the Arduino will be very helpful. If I'm ever rich (unfortunately don't bet on it) I'll gladly fund your ultimate skateboard project.

One question. I have two lead acid battries that are for a lawn tractor. They're not as big as full car batteries, but a bit bigger than the ones you show here. The question is, would they have enough juice to do things like climb hills? I'm using big knobby tires so I would like it to be able to handle grass etc. Do you think these motors with lead acid batteries would hack it?
XenonJohn (author) in reply to EmmettOMar 25, 2010. 11:09 AM
I am not sure is honest answer.
Lead acid batteries would give high current no problem and get you up hills, the endurance would be the unknown factor. Huge amount of discussion on this on ebike forums by the way. They obsess over battery types / motor ratings. Vehicles are different but the maths is probably similar.

For a big machine going up hills the bulletproof way is to use two OSMC controllers. These can take huge currents, but cost a lot more than Sabertooth as you need two of them. The Sabertooth is described as being for "medium sized robots" You need something that will run uphill with maybe 100-120kg total all up weight.
This is where the costs and the size of the machine start going up. Really big motor controllers are not cheap. 

Take a look at this website for example. It is a segway clone called the "Meta" by Geoff Bennett with biggish lead acids and two OSMC's. It illustrates these points.
www.netcraft.com.au/geoffrey/meta/

Based on original segway clone by Trevor Blackwell.
EmmettO in reply to XenonJohnMar 25, 2010. 1:58 PM
 So I should keep it light or pony up for a pair of OSMCs. That's actually why I've been waiting to finish the project. I think I'll try the Sabertooth and see if it's enough. If it isn't I can use it on another project.
PerfectionLost says: Mar 25, 2010. 6:20 AM
Could you add the cost of each item on this page?
XenonJohn (author) in reply to PerfectionLostMar 25, 2010. 7:38 AM
Can do.

It's on page 36 at moment.

£273 plus batteries, a few cheap switches and a some thick wire.

John
PerfectionLost in reply to XenonJohnMar 25, 2010. 1:35 PM
Actually, I meant to put that on Step 1.  A list of each part and price w/ the pictures would be a huge help.  I think I might give this project a shot with a friend.
EmmettO says: Mar 25, 2010. 10:15 AM
 This is a brilliant point. 
everywhere says: Mar 25, 2010. 6:51 AM
for the one wheel verioin how wide must the wheel be like could i use the wheel form a e200?
XenonJohn (author) in reply to everywhereMar 25, 2010. 8:12 AM
Here is another related monowheel idea:

Lock two wheels with pneumatic tyres to one single axle, driven by one sprocket (so both wheels driven together).

So long as tyres not inflated rock hard, then leaning to one side will compress one tyre more (reducing effective diameter of that wheel) and skateboard will gently turn.

Adjust wheel spacing according to your balancing skill!

John

XenonJohn (author) in reply to everywhereMar 25, 2010. 7:57 AM
Wheel has to be wide enough to stop you falling off sideways. The Ben Smithers monowheel (the first one I think of the skateboard monowheels) had a go kart wheel one size smaller than the one I used.

If you have a great sense of balance, you might get away with a smaller wheel in terms of width. I played it safe with widest wheel I could find!

Also, the higher the deck off the ground, the easier it will tip you off sideways if one side of wheel goes over a pebble for example.

In terms of fore-aft self balancing (controlled by the motor),  you could make machine as tall as you like - use a ladder if you want and sit on top! It might even work better.

Just remember with a monowheel, a lower centre of gravity makes it much easier to ride and steer (by tilting left or right) in terms of falling off sideways.

This is why I rebuilt my monowheel with deck lower to the ground. I found out this the hard way.

Hope this helps,

John
everywhere in reply to XenonJohnMar 25, 2010. 2:57 PM
thanks i just have an old e200 in my garage and wanted to convert it

BHStibal says: Mar 24, 2010. 5:49 PM
 how very very cool. I love this idea, and it gives me a ton of ideas. What did this whole project cost you, material wise?
XenonJohn (author) in reply to BHStibalMar 25, 2010. 7:47 AM
£273 plus batteries and a few odds and ends.

Would be cheaper in US I suspect though.

John
joren says: Mar 24, 2010. 2:57 PM
Really nice 'ible.  Thanks for posting.  I've ordered parts and hope to build one soon.  350w motors and 8" mountainboard wheels.  Q:  What is the chain ring tooth count on the razor wheels you use?

To further reduce cost, have you considered using a wii motion plus and nunchuck for the IMU?  Would you need a second serial port on the arduino?

Alternately, although I'm not sure if it'll work as well, cheaper IMUs can be found that are 1/3 less the price than sparkfun:

www.gadgetgangster.com/find-a-project/56.html





XenonJohn (author) in reply to jorenMar 25, 2010. 7:46 AM

About 50 teeth on the razor E100 wheel chain ring.

The motors I used have 11 teeth.

The more powerful motors of the otherwise same design on ebay seem to have 16 teeth.

If there are cheaper IMU's I would go for it. Take some photos as you go along for the rest of us!

If you go on Arduino forums there is an ongoing discussion concerning the Wii Motion Plus module. Basically there IS now an arduino hack that will read data from the Wii Motion Plus unit. NOTE: This has gyros in it only as it is designed to augment the accelerometers already in the Wii-Mote handset.

Nobody has yet managed to read both the 3 axis accel data from WiiMote as well as the 3 axis gyro data from the wiiMotionPlus (only a matter of time though)

However there IS an arduino hack for the WiiNunchuck and that WILL read the 3 axis accel data from those within the chuck.

If you can combine the code to read a WiiMotioPlus with code to read the Wii Nunchuck accelerometers this would give you all the data you need to control a self balancer - in all 3 axes.

This would be a great programming challenge for someone much better at it than I am.

Best wishes

John

 

PopEye42 says: Mar 25, 2010. 7:16 AM
Wow.  this is great man.
Senseless says: Mar 23, 2010. 8:44 PM
Excellent Instructable!

Faved it for future use super nice job on everything.
merijnvw says: Mar 23, 2010. 2:09 PM
 cool, happened to make a mini segway on school just today from legos together with lego dacta! But yours is much more stable haha
grunff says: Mar 23, 2010. 1:51 PM
Wow, what a fantastic write-up! Thank you very much John for putting all that effort into documenting it so well. I've long admired your original board (with the gokart wheel). You've made this an easy weekend project, so I'm off to buy some parts :-) 
xesive says: Mar 23, 2010. 9:50 AM
I am excited to get started on recreating this project but have a few questions before i start getting my hands dirty:

Do you have a copy of the arduino code available?

What is the max speed? (estimate)
What is the max incline?

I live in a city that is more or less a big hill, I want to ensure that this is powerful enough to travel up hills.

Thanks for such a grerat and comprehensive instructable :D
XenonJohn (author) in reply to xesiveMar 23, 2010. 1:08 PM

Electric motors are quite efficient things. PWM from motor controller very fast so not much loss as heat.

Someone may help you here. Should be able to calculate how many watts power needed to get say a total of 100kg up a 1 in 10 slope for example. Then work out motor requirements, take account of gearing between the small and large chain sprockets, and motor controller requirements from that.
My one wheeler went up hills, in early videos (on YouTube) you can see a huge sprocket on wheel and tiny one on motor (500Watt with hefty OSMC combat robot power controller).
Not sure if this smaller one will go up hills. Have not tried. However, the motors I have used can be found on ebay up to 500 Watts each (but they usually have a larger 16 tooth sprocket on them - which would also make it faster on the level of course).
Also this is why you can adjust the balance point: otherwise to go up a hill you would tip nose down and it would hit the hill. So now you adjust until nose up position with balance point adjust switch, then tip nose down (i.e. back to level position) to get up a slope.
Also link to the sketch is now on first page of the instructable.

Best wishes
John
 

johndeligdisch says: Mar 23, 2010. 11:59 AM
Awesome job, well done.  I have been working on my software but has a few bugs.  Can I get a copy of yours and see where I am going wrong please.

Thanks, this is a great project that I am going to get a bunch of kids in our neighbourhood to build.
jeff-o says: Mar 23, 2010. 6:56 AM
Another excellent project.  Well done, and thanks!
me says: Mar 21, 2010. 2:02 PM
 that looks really awesome
knife141 says: Mar 20, 2010. 7:13 PM
Wow!  I can't even begin to imagine the time you spent putting this instructable together.  Great job!
unigamer says: Mar 20, 2010. 4:49 PM
lovely instructable! Well written and clear. I definitely want to make one in the summer.
rimar2000 says: Mar 20, 2010. 2:04 PM
 This is A-WE-SO-ME!!!

Congratulations.
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!