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 ads by
Signing Up
























































































Visit Our Store »
Go Pro Today »




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
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
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
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!
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
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
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
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
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.
Any update on on the SIXDOF digital unfinished code?
Thanks.
Regards
William Seow
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
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
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
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).
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
Did you try changing the values already?
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
"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.
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
And yes, my ACCSUM is about 290 when horizontal. I don't really know why, but it doesn't seem to matter.
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
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
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 :)
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.
And what was the deal with the IMU?
I really hope you can help me.
Thank you!
Must have uploaded it over 20 times since this I first put this up.
Do you have any spare anlalog IMU-5DOF or 6DOF that I can purchase from you? Please advise.
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.
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.
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!
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 ?
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
I have the 60amp sabertooth, so might end up using 8S LiPo after I'm done testing with 24V SLA.
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.
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
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.
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
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?
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
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.
Do you think the speed of the communication is the issue, or could solething else be causing the overshoot?
Balances fine, but has a tendency to wander around the garden slowly on its own.
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
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!
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!
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.
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
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
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).
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?
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
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
Thanks,
Tim
Hard to deal with yet, I might need to try to see why later .
NM
I m still trying to figure out why it won't balance itself though.
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
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).
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.
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.
I have (2 )100W 24V motors from the E100 scooter, will these work instead of the 250W motors you used?
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
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
I am pricing my materials and was wondering what gauge wire do you recommend for connecting the batteries to the Sabertooth?
Thanks
I often use a double pole switch but wire up both sides in parallel to maximise the current carrying capacity.
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
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
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
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
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
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!
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
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
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
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
John
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
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
Thanks
TRANCT
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.
dreniles
thank you
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
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.
Thank you very much
In main code for balancing machine, it can go up to 100%.
thank you
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
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
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 :)
Make sure wheels are going in same direction, if not one of your motor wires are back to front.
John
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.
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
Thanks
Jon
thank you
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.
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
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
If you could please provide me your assistance.
Thank You.
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
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...
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
in your motor calculations the tilt angles and gyro rates passed are in degrees and degrees/sec respectively? or are they the raw values?
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
thank you
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?
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!
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.
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
You will not need the gyro scaling factor in old code, just remove it or set it to 1
Best of luck
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-----
(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
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
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
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
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
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
just tested IMU tester code with ebay clone 5dof works!
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
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
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.
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.
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
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
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
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?
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
Or if no luck with that I just wait your 6dof digital version code...
br
Pumo
Thank you,
Nick
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
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?
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.
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 :-)
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
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.
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
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.
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
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
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
John
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.
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?
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.
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
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. ))
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.
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.
Crooked link I'm afraid... :( "Cannot be found" - I'll try it again later...
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
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!
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
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.
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!
Thanks!
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
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
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
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.
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
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.
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
with this:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);
Cheers
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
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
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
http://www.teknic.com/products/servo_motor.php
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.
Check out the scooter the boy is riding!
http://movies.yahoo.com/feature/lorax.html?showVideo=1#theatrical
Wish I could ride mine in real life as well as he does in this cartoon!
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
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
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...
John
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
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 :)
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
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.
http://www.dimensionengineering.com/Sabertooth2x60.htm
thank you
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.
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)?
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.
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
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
im just mapping were every thing is going i m also desigining the base for it
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
http://www.dimensionengineering.com/Sabertooth2x50HV.htm
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.
but then how come u said i cant run the mottors 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
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)
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
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.
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
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
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
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
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
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
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
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.
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.
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!
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
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
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
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
(the one labelled 3.3V next to it powers the IMU)
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
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!
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
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
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.
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
http://www.apexbattery.com/dts-12v-6-7-amp---no-leads-battery-sealed-lead-acid-batteries-dts-batteries.html
thanks
adrian
Best wishes
John
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
but were do i get the 5 volts from the board so i could bring it to the hand controller
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
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
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
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
http://www.sparkfun.com/products/9250
I have no idea really but think it will be fine without the capabilty of resisting sudden turns?
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.
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
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
thanks
adrian
Minimum needed to balance is one accel and one gyro
Regards,
Val'
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
Example:
http://www.monsterscooterparts.com/e200rearwheel.html
Dave
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
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'
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
Waiting for arrival !
Thanks again ursine100 !
Regards,
Val'
Dave
Can't wait to ride it int he campus !
Regards,
Val'
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.
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
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
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.
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
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
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
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
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.
Dave
It's been near 1 year they are out of stock !
Regards,
Val'
Could you share me how to mount the batteries underneth ?
Thanks.
regards,
Jack
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
Thanks for your response.
I'd like to see the pictures of battery, if you can sharing with me.
Regards,
Jack
Could you tell me who to change the chain length ?
What tool should I use ?
Thanks.
Best regards,
Jack
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
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 !!!!
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.
Could I have code as well ?
miaoichi@gmail.com
Thx!
All code attached to last few pages.
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.
Really interested, can I have the code please.
email rikain@live.co.uk
Thanks
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
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
Seems like a fun project my email kunal_p_pat@yahoo.com
Thanks
Please help this is for a school project.
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
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
Thank you
failing that send me a hi res photo and I will see if I can see any obvious wiring problems.
best wishes
john
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!
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
Sorry not to be more helpful.
John
Silly question.... but you can use the ground on the digital site of the arduino board as a normal ground cant you?
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
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
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
My email is brian-finch@comcast.net
would you send to me code on email elmusic@open.telekom.rs
thanks
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
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.
When I find some time I will try that.
John
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.
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
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
my id is devilianmj@gmail.com
neways u hav done a very outstanding job...
thanx
John
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
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??
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
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
If having problems come back and I will email it to you.
best wishes
John
As i can see its a closed loop robust system so can i scale it to a segway design or small self balancing robot ?
rhydolabz.com
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.
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.
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
what changes should i make to code and hardware ?
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.
Razor should have been better prepared for this :)
http://www.scooterpartscatalog.com/e100-chain-wheel-assembly-119-46.html
Although it was a bit mor expensive at $29.99 each.... : /
http://www.razorama.com/razor-e100-e125-e150-e175-rear-wheel-.html
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
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?
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.
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 Johnwww.instructables.com/id/Wii-Nunchuck-as-general-purpose-controller-via-Ard/
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.
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.
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
I unerstood everything, I hope my board will balance !
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.
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.
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
Thanks,
Daniel
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.
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
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
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.
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.
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
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.
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!
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).
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
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.
Excellent instructable!
all you have on your site and instructables are for the one wheel
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
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
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.
and i love it, altho i dont know what that aurd... thing is, i have seen it in loads of insturcibles
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
thanks anyway :)
it did help
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
thanks :)
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.
and any chance on an instructable with the nunchuck version?
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...
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.
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
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.
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...
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.
All online robot shops have chargers too.
Car charger might be too fierce.
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?
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...
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?
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.
It's on page 36 at moment.
£273 plus batteries, a few cheap switches and a some thick wire.
John
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
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
Would be cheaper in US I suspect though.
John
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
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
Faved it for future use super nice job on everything.
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
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
Thanks, this is a great project that I am going to get a bunch of kids in our neighbourhood to build.
Congratulations.