Instructables
Picture of Easy build self balancing electric skateboard
Titlepic2.jpg

What is it?
Twin wheeled skateboard that works like a Segway. Electric skateboards exist already with powered rear wheels. 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 and 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 photos if you are more ambitious).
Upper photo is original budget version with two lead-acid batteries and solid wheels. Lower photo is 2013 not-so-easy-build version, with pneumatic tyres and Headway LiFePO4 batteries just to see how far I could push this overall concept. More on the new one is here: https://sites.google.com/site/onewheeledselfbalancing/Home/18-2013superskate

UPDATE regarding IMU's and CODE (December 2014):
This Instructable is a little old now and the IMU used is no longer available. Therefore I have removed the pages that describe the IMU wiring and the code as it is confusing people.

If you use a digital Sparkfun 6dof IMU (which is much more easily available) then for instructions on how to use this with an Arduino, to control a self-balancing skateboard, with code, then look at this new Instructable of mine here:
http://www.instructables.com/id/Arduino-Self-Balance-Controller-using-DIGITAL-IMU-/

Also there is a scooter I have made inspired by the 1970's Raleigh Chopper with updated (December 2014) software using the same easily available digital IMU from Sparkfun: Raleigh Chopper inspired self-balancing scooter.

If you want to build a big unicycle check out this one I built with two friends for the 2014 Hackaday competition, called the MediCycle: http://hackaday.io/project/1156-Medicycle---Urban-...


Can I buy one ready built?
Well, looks as if you now can. The German S-Walker looks strangely familiar!
http://www.s-walker.com/index.php/de/products/board

Also there is the "One-Wheel" single wheeled skateboard which was a recent Kickstarter project: One-Wheel

For a good electric unicycle you can buy check out this very recent Russian one (about US$1000): Russian electric Monocycle

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 is called a "PID" control system and is used for all sorts of control situations. Think of the 363 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 swivelling mounts hydraulically controlled by a PID control system (lots of analog electronics I think involved too). First stage projected guidance system failure rate was approx. 1 in 256 which was considered an acceptable risk (!)

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. Advantage of two wheelers is that they turn more easily and can turn and balance even when stationary - which is fun. I (used to) prefer skateboards to segway clones as you just jump off if it goes wrong without tangling in the handlebars.


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. 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! 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.

Why do it?
i) For the challenge of doing something original. 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 might become a world expert, there are no textbooks so you are genuinely pushing into the unknown with each machine you make. Few things as an individual hobbyist allow you to truly do this.
iv) These machines are really good fun to ride!

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.

Additional information:
I have documented all my machines both good and bad on another website here:
http://sites.google.com/site/onewheeledselfbalancing/

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 and more recently the Jackal: Jackal

Has anyone else built one?
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

Potential areas of improvement
It would be cool if people took this design and improved upon it.
The only way I can envisage further improvements in terms of weight reduction and compactness on my 2013 design with Headway cells and pneumatic tyres would be as follows:
a) Make frame from welded alloy.
b) The cheap scooter motors are quite heavy so use equally powerful but lighter, smaller combat robot motors.
c) To reduce length and make even more compact, someone, say a mech eng student, could design a neat hub motor for each wheel using epicyclic reduction gears.


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

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

John



 
Remove these adsRemove these ads by Signing Up

Hello,

can I use MPU6050 (6DOF) gyro instead of 5DOF gyro..

Thank you.

danmellow3 months ago

this is a free ride :-)

Tjoydavi4 months ago

Hello,Im in search of someone that has the skills to build an electronic device.

If you can be of service let me know tyffanij5@gmail.com

umerji10006 months ago

is there any way to build this without the hand controller

anthology6 months ago

hello

i have found your code for grove analog gyro and accelerometer with the nunchuck

but actually i cant found it

can you publish this ?

thanks a lot

zetowe10 months ago

i found this IMU http://dx.com/p/gy-85-6dof-9dof-imu-sensor-module-for-arduino-148436#.Uv_JhfldVwx it is a reliable website

XenonJohn (author)  zetowe9 months ago

Hi,

Just pointing out that the IMU above is a digital output one that does not work with the code in this instructable that was written to work with analog (variable voltage) output IMU's. These are becoming quite hard to find however.

This is why I have had to recently rewrite the code and add a new related instructable that shows you how to make a balance control system using a digital IMU.

John

zetowe XenonJohn9 months ago

Oh, i already ordered this IMU, i even started the project. I am making more like a onewheel-frame. i got all the aluminum parts and cut them up to shape, i picked the aluminum frame up from the welder today, i am using a small 24 volt DC motor. i got 4 small 7 ah 6 volt batteries and a velleman P8004 motor controller. I dont know if it works with my arduino UNO yet but its what i have (i am using a cigarette lighter 24-5 volt adapter as a power supply for my arduino, they're really cheap and function well) , otherwise i will buy an arduino motor controller like the sabertooth. Also, i am planning to add a light sensor as a dead-man switch, that way when somebody steps off the board it stops, i dont need a steering switch etc so i think i am just gonna remove those lines of code. i added pictures (the pics of the frame have low quality because my camera sucks at low-lighting). maybe i am going to upload videos someday. Thanks for the new code, helps a lot!

Sorry, i dont know why but my English is sort of broken today, usually it's better. :/ (i am dutch).

DSC00351.JPGDSC00352.JPGDSC00353.JPGDSC00354.JPGDSC00355.JPGIMG_20140225_231035.jpgIMG_20140225_231119.jpgDSC00356.JPGDSC00357.JPGDSC00358.JPGDSC00359.JPGDSC00360.JPG
XenonJohn (author)  zetowe9 months ago

Looks good. I have no idea if the digital IMU you have bought will work with my new digital IMU code as I have only tested it with the 6dof digital IMU from Sparkfun. I am sure you will find out soon enough!

John

zetowe XenonJohn9 months ago

If you want, let me know maybe i can send pictures in the future.

zetowe

XenonJohn (author)  zetowe9 months ago

Please do. Your metalwork looks really neat and tidy.

John

zetowe XenonJohn7 months ago

Hello XenonJohn,

I have not done an update in a long time (i think about 2 months). I have been working on it but i ran into a lot of problems and i didn't quite get the time to fix them because school is busy lately. No time for excuses tough. I am gonna do an update once it is finished, nothing in between. I will make a video of me riding it and showing the inside lay out etc. I will post it right here. See you then!

Zetowe

zetowe XenonJohn9 months ago

Ok, no problem, but please note, i am not doing this project bcause i know how to do it, i am doing it to learn how to do it so there might be a bit of a time-gap between every update.

Zetowe

You are a great genius John!

Congratulations, you have given new hope to all of us,

regards,

Gerry

eyrecamp zetowe9 months ago

Hi zetowe,

can I please ask what is the logic you intend for your light sensor?

Without your advice I am thinking it is like a solar cell and if you block it with your foot and so your logic is drive the motor when the sensor is not generating or sending any voltage (if solar cell). But problem in my mind is if you put some dirt from your shoe on the sensor then it stay in drive mode when you are off it?

Such that I am interested to learn what you think about the logic for this process. thanku

XenonJohn (author)  eyrecamp9 months ago

Another option is the Sharp infra red rangefinder available from robot sites. It fires an infrared beam at an angle and looks at the reflected light. If you have it facing upwards and you are on the board, it will see light reflected from your foot. If not on the board it will not. You would have to recess it about 3cm into the board (for the shortest range one they make).

Another option is a cheap pressure sensitive resistor mounted under a rubber disc. Look how its resistance changes, set up a voltage divider with another resistor, feed the changing voltage into an analog input and with some adjustment of the limits in the code it will work.

You can also use a rugged metal push to make foot switch that you stand on, - recess it into the deck. These exist as foot switches to trigger alarms by shop cashiers for example.

zetowe eyrecamp9 months ago

Hello eyrecamp,

You have a very good point, but i think that my shoes don't get dirty enough to completely block the light sensor, i live in a city with mainly pavements, i dont think dirt will be a problem for this idea. (i included a pic of the light sensor)

(general update)

I also just got the IMU in the mail! It has the right voltage and the pins have the same names (i included a pic of the soldering so far), i hope it works, if it doesn't it will be hard to determine what doesnt work, its either the IMU not working with the code or it's the motor controller not working with arduino. i still need to find the 2 100 Ohm resistors. I really hope it just works, that way it stays simple.

zetowe

DSC00361.JPGDSC00362.JPG
eyrecamp zetowe9 months ago

Hi zetowe,

you are fortunate that you can keep your shoes so clean!

Personally I cannot yet bring myself to trust this as a fail safe.

Do you have any specific identifier data on that light sensor?

I would like to learn more about that one.

My current thought is a two wheel unit with a pressure sensitive system. No pressure applied is signal to cut out the motor, then I'd like to be able to bias left and right side pressure to bias drive to one motor in order to steer. Probably there are some floors with this concept.

zetowe eyrecamp9 months ago

Hello eyrecamp,

Personally i have decided to use a switch because it indeed is more reliable. If you are still interested here is some info.

http://m.eet.com/media/1049853/C0086-Table1a.gif

http://en.wikipedia.org/wiki/Photoresistor

I hope this was helpfull to you.

Zetowe

eyrecamp zetowe10 months ago

Great mate, thanks I had no problem finding this option.

gerrymazzotta9 months ago

Hello to all,

can anyone tell me if the IMU is oriented correctly?

Thank you, Regards

ORIENTATION IMU.JPG
XenonJohn (author)  gerrymazzotta9 months ago

Other way up. The edge with the two large holes in it faces upwards. Then run the IMU tester sketch.

John

Ciao Giovanni, ho ruotato l'Imu di 180 ° e allegato inviare le immagini del monitor seriale. Pensi che i valori sono coerento o sto facendo qualcosa di sbagliato? Grazie, cordialità, Gerry
Platform level.JPGPlatform tilted back.JPGPlatform tilted forward.JPG
XenonJohn (author)  gerrymazzotta9 months ago

Hi, we can correspond by email and I am sure we will sort this out.

John

XenonJohn (author)  XenonJohn8 months ago

We did sort this out and his machine works now.

John

eyrecamp10 months ago

Hi, I'm needing to get a copy of the code for this project!?

eyrecamp eyrecamp10 months ago

my mail is eyre.c@hotmail.com.au

further, I am considering using the hub motors (8 or 9 inch), in order to reduce mass. Do you know if sabertooth motor driver will provide the power and control through to these motors....? I will chase up some specs if necessary.

XenonJohn (author)  eyrecamp9 months ago

The Sabertooth only works with brushed motors. There are some small brushed hub motors out there, but in general, hub motors tend to be brushless nowadays. I have built a machine like a segway with brushless hub motors and a very expensive Roboteq Brushless motor controller but that is another story. It can be done but it was expensive and it would not go up any kind of slope (lack of torque).

Also, hub motors do not generate as much torque (twisting force) as a regular wheel with a sprocket chain or toothed belt drive from a motor, i.e. small sprocket on motor and big one on wheel). With self-balancers a generous amount of torque is very useful to have, rather than a high top speed.

so what I can determine is that I can get a hub motor (9inch) to give 12N.m of Torque which would allow drive up a slope incline of 0.054 (on a 0 to 1 scale), I guess if I had two of these it would double the Torque capacity and allow for slope incline of 0.108 (all based on a 100kg loading). This suggests capability to climb a 9 degree slope best case.

So now I am interested to find what your design rates in terms of Torque generated through the motor and sprockets. Maybe your design can carry a 100kg load on a 20 degree slope!?

eyrecamp eyrecamp10 months ago

Here is links to the 8 inch and the 6 inch hub motors.

http://www.uumotor.com/air-tyre-8-inch-gearless-hub-motor-36v-350w.html

http://www.uumotor.com/6-inch-36v-250w-small-hub-motor-20kmh.html

Seems that the 6 inch motors are reversible, there is a 9 inch version that has variable speed options, however i have a feeling that a control circuit should be able to provide such convenience with any of these hub motor selections (??)

eyrecamp9 months ago
John,

thanku for the feedback on the hub motors. It is unfortunate that there is a problem with the torque. I assumed that because they are advertised for scooters and wheelchairs that torque would not be lacking.
DR42969 months ago

Suppose I wanted to build one of these... but I wanted to add a third caster wheel and not worry about the whole self-balancing thing. I just want something I can stand on, be self-propelled, and be able to turn it by some really simple means.. What all electronics could I eliminate? Just the IMU's? Can anybody point me to maybe a SIMPLER Instructable that might show me such a thing?

XenonJohn (author) 9 months ago

Hi everyone,

Big development: I have finally managed to get all this to work with the Sparkfun DIGITAL 6dof IMU Code No: SEN-10121.

It has taken 2 years but there we are.

Uses code from all over the web chopped and changed and merged with my existing code. Use the very clever Kalman balance filter algorithm too.

See the new Instructable here:

http://www.instructables.com/id/Arduino-Self-Balan...

John

_Champ11 months ago

What electrical output does your skateboard produce?

XenonJohn (author)  _Champ10 months ago

Motors 250 Watt (times 2 as there are 2 motors) and whole things runs at 24V

nsandland11 months ago
Would a 24V battery charger work OK?
Noaharfarf1 year ago
I am building a regular electric skateboard with four wheels that tilts forward for acceleration. I am using a 2G accelerometer to measure the forward tilt but it does not go full power unless I tilt the board to almost a 90 degree angle. Should I use a higher G accelerometer like the ones capable of measuring up to 250G so that it can go full power at less than a 45 degree angle? Or should I use a gyroscope sensor instead? I am just using analog accelerometer that outputs 0-5 volts to the generic speed controller as I do not know how to program. Any help will be much appreciated. Thanks!
XenonJohn (author)  Noaharfarf1 year ago
Alternative to the above is to use a 1G accelerometer that will give faster rising voltage as you tilt it.
Thanks John. The lowest and readily-available I could find is 1.5G. I am also using Dimension Engineering controllers and they told me that I can use their DEScribe software to modify its voltage range. I am checking on this right now. Great instructable BTW.
XenonJohn (author)  Noaharfarf1 year ago
Hi,

Yes it will not go to 5V until it is tilted over 90 degrees.

I would use a microcontroller to look at voltage from accelerometer and send correct voltage to the motor controller, altering the performance by tweaking the code.

You could alternatively have an electronic circuit design that outputs double the voltage coming in from the accelerometer. Accelerometers are also very sensitive to vibration so the signal to your motor power controller when at less than full speed will have higher voltage spikes in it especially on rough ground that may make it behave oddly. You could also use a capacitor to smooth out these spikes.

John
pbecker831 year ago
Has anyone written any complete code for the more common digital IMU's? I am getting to the electronics part of my build but my 5DOF's got held up in customs and I have no idea when or if Ill get them now. Wouldn't mind ordering a digital one if I can find some instructions/code that tried and true. Thanks!
Hello pbecker83, I have the same problem with the China's customs ...
I don't know what I will do. I asked the seller from Ebay to try again but expecting fail again. I already bough everything only this thing left ....
Maybe we should make little group and work together to make good working code for 6DOF digital unit.
XenonJohn (author)  _Rommel_1 year ago
Completely agree with you.
What we all need is a basic self balancing sketch that runs with a digital IMU. It is a bit beyond my programming ability to keep the self balance program running at 100 samples per second and also maintaining reliable communication with the digital IMU.
XenonJohn (author)  pbecker831 year ago
Nearest I know of is Thomas Feminella. His code did work he tells me but every now and then there would be a momentary communications glitch between IMU and Arduino which would cause a big wobble in his self-balancing unicycle - not ideal. Link on front page.

I agree it would be great if someone could write some self-balancing code that works reliably with a digital hobby IMU.
gmiguy1 year ago
Has anyone had succes utilizing the motor control shield for the Uno as opposed to purchasing the Sabertooth. I am just looking to test my skills on small motors before I purchase the Sabertooth. Can even be a 1/10 scale setup to dial in my code?
I'm in a build and I'm running the just balance sketch and running into some problems you can see in this video: http://m.youtube.com/watch?v=Q9tm9rSYzhw

I've been tuning the pid values as well as working with a few other values as follows:

Acc sum 353.3
Overall gain .1
Overallgaintarget .5
Balance target 353.3
P 5.5
D .495
I is commented out

Any thoughts on what is happening, John?
XenonJohn (author)  gbredemeyer1 year ago
It looks very much as if the accelerometer is slowly correcting for the tilt, which is what it is meant to do. It is mainly the gyro that does the very fast responses to change in angle of tilt.
Can I just check what IMU you are using and what code? The latest code is attached to the arduino self balancing shield instructable, it is set to work with one particular analog IMU that is still available.
John
I'm using the old code found at the bottom of this link: http://www.instructables.com/id/Easy-build-self-balancing-skateboardrobotsegway-/step45/CODE-Just-balances-nothing-else/ AS for the IMU, we are using the GY-66. Yeah, we could tell it was doing what it should be, we're just not sure if we're going the wrong direction with certain values as we adjust or what. We just can't seem to adjust our way out of this mode and wanted to see if you had any thoughts/ recommendations or if you saw something that could tell you we have something else going on. Thanks, let me know what you think.
XenonJohn (author)  gbredemeyer1 year ago
That is your problem.
The code attached to this Instructable is out of date now and uses an IMU with different gyros inside it that is no longer available.

The gyro the code was written for (that you are using) had a bigger voltage change for any given change in rate of tilting. The GY-66 gyro puts out a smaller voltage change, but the accelerometer inside has same voltage change per degree of tilting as the one in the old IMU you cannot buy any more.
That is why your machine behaves as if the gyro is not really working but the accelerometer is working.

In the sketch attached to my Self-balancing Arduino Shield you will see 2 sets of comments. one refers to the gyro voltage output (of the GY-66) and one to the accelerometer output voltage. It shows how to scale the outputs so the code will work.
I will need to take a look at it but from memory you need to take the gyro reading from the GY-66 and multiply it by a bigger number than is used in the old code attached to this instructable.

Hope this helps. At some point soon I will remove all the code from this Instructable as it is confusing people and refer everyone across to the new one with the new code.

John
CUSTOMIZER1 year ago
hi john

now my scooter balances perfectly but i cant stand on it. there is not enugh power to keep me balanced on it.

i did edited the code to
balance_torque = (float) (9 * anglerads) + (0.95 * gangleraterads);

but still cant stand on it.

do you have any idea how to fix that ?

XenonJohn (author)  CUSTOMIZER1 year ago
Usually means you need more reduction gearing so more torque and less speed
Bigger motors ok but usually a bigger diameter sprocket on the wheel is the solution. My earliest machines had wheel sprocket almost same diameter as the tyre itself.
Have you increased the overall gain target term in the code as far as you can go before it starts oscillating?
Also look at the Sci-tech instructables which are very similar.
MaleBuffy1 year ago
Go the correct code. OK for some odd reason I had an older version!?

Anyways, i think it works better even with the smaller sprockets now! Got the bigger ones on Friday. They aren't that big though but at least bigger than the older ones.

Will try and post
XenonJohn (author)  MaleBuffy1 year ago
Looked at your video,

er, it looks fine to me. It balances, the tip-start works, it responds to your kicks in correct way!

The weight of the handlebar arrangement on the front makes it want to "fall" forwards. The self-balancing compensates for this by powering the motors forwards, NOT until it is "balanced" again, BUT until it is LEVEL again (not the same thing at all). When level again, still more weight on front of machine than back, so still tries to fall forwards again, so accelerates forwards again to stop this and stay LEVEL, so it keeps rolling forwards.
If you were standing on it you would lean back, and pull stick back, until it stopped rolling forwards so would become a non-problem. If not standing on it the above happens.

Options,
You can balance rear of machine with a weight OR stand on it 1 or 2 cm behind centre line until it works nicely (with bigger sprockets) OR alter the value of 350 in the code by small amounts until machine considers itself to be "level" when the machine is actually leaning back a little so weight of handlebars is then balanced directly over the axle line.

Hope this helps

John
LOL, its the same code! I did change the layout of the machine and motors. They are now more stable, I guess that made the change.

Will take the part of the new code however and adapt it to the old one.

I see the new code needs rewiring etc.

Will have to try it at a later point of time.
MaleBuffy1 year ago
Well I managed to balance it quite well now. It I bring it to balance, it stays level without any movement.

The problem starts when I tilt it a bit forward. It corrects itslef but moves forward and doesnt stop. If I tilt it backwards however, it corrects itslef imediately and stays there.

What could be the problem?
XenonJohn (author)  MaleBuffy1 year ago
Are you riding it when it does this?

It has no idea of where it is in terms of position on the ground.
It does not know how fast it is going or whether the wheels are going round or not (if stationary on a slope it could be sending power to motors just to keep you still on the slope).

If you tip it back a bit when "moving forwards" will it then slow down or will it just go forwards and not stop whatever you do?

Unusual fault actually, usually if something is wrong it is equally wrong in both directions.
No it does it when it is balancing by itself.

Can the angle be the problem; the 350 value for example may be to high?
I made a video.

Didn't fit the new sprockets yet. I think the problem I have is not sprocket related, so I try to figure this one out first.

Any ideas why it moves forward and doesn't stop;

https://www.youtube.com/watch?v=k0303u0Q_OA&feature=youtube_gdata_player
MaleBuffy1 year ago
Hello,

I am still waiting for my larger sprockets to come, so I am looking at the code to see if I can finetune anything. Something that comes to mind is the situation when for some reason, I let go of the deadmans switch. When I try to get on again and press the deadmans switch, the motors act crazy at full speed. In order to overcome this, I have to switch the machine off and on again, and do the 5-10secs calibration process.

How can I "correct" this, so that when I press the deadmans switch again, it doesn't start at full speed again? Would tipstart = 0; help? (since it is 5 when pressed for longer time)

This would make sense, since when I for example fall off and let go, by falling the deadmans switch can be accidentaly pressed and the thing can hurt somebody or something. By forcing it to start with limited power (like the softstart function), I would have time to switch it off.
XenonJohn (author)  MaleBuffy1 year ago
I would get your board to work first then I can suggest code mods.

My newer code in the Self-balancing shield instructable has a value that counts down from 50 to zero over half a second if you let go of the deadman. If it reached zero the motors cut and they will not restart until you reset the board.

This has additional advantage of not cutting the power if you let go of the deadman just for a tiny moment, or the switch comtact is dirty (same effect) but it still cuts the power if you fall off. You can adjust the decay time value in he code. Seems to work quite well as once I made a board with a cheapo deadman switch which had dodgy contacts.

John
XenonJohn (author)  MaleBuffy1 year ago
My newer software does not do this. You have to restart the board after you have let go of the deadman switch for safety as you say.

John
MaleBuffy1 year ago
Here is the youtube video

http://youtu.be/eLy4-fsIdgs

It works now.

Thanks a million for your explanation. I really appreciate it.
XenonJohn (author)  MaleBuffy1 year ago
OK I have seen your video. Basically it is working.

You need much larger diameter chain sprockets on your wheels. 2 reasons:

a) Any slight slack in the chain causes a small rattle (picked up by the IMU) every time it changes direction. This is magnified if the wheel is large diameter compared to the wheel-sprocket diameter and the IMU can pick this up and causes oscillation.
When starting to develop a machine like this you are much better to have a very large sprocket on the wheel, say 2/3 the diameter of the wheel itself. On my skateboard the wheels may be small but the sprockets on the wheels are about 2/3 of the diameter of the wheels themselves.
b) If the motor sprocket is small and the wheel sprocket is large, it gives a slow top speed but very high torque at the wheel (turning force). You want this. Self-balancing machines need this as when they start to fall, the wheel speed has to increase very fast, with no delay due to a lack of torque.
The machine you have now may just about balance on its own but may not do so with you standing on it.

Suggest you either use larger diameter wheel-sprockets or use smaller wheels. When it works, then you can experiment with smaller sprockets.

Do not worry, you are nearly there.

John
MaleBuffy1 year ago
(removed by author or community request)
XenonJohn (author)  MaleBuffy1 year ago
Your video is showing up as private so I cannot see it.

The two key lines are:

balance_torque = (float) (4.5 * anglerads) + (0.5 * gangleraterads);

cur_speed = (float) (cur_speed + (anglerads * 6 * cycle_time)) * 0.999;


The 4.5 is the “P” term i.e. proportional to the actual current angle of tilting
The 0.5 is the “D” term i.e. reflects the RATE of tilting
The 6 in the cur-speed line of code is the “I” term.

Note, it will balance without the I term at all. Could change this line to cur_speed = 0; until the rest is right then put it back in and experiment with the I term.

I would put whatever you changed back to initial value then work on the terms above.

One way to “tune” PID (of many) is to set the I and D terms to zero or near zero, then just increase the P value until board oscillates wildly. Then reduce it a bit, some say reduce to about 2/3 the value that made it oscillate.

Then gently increase the P term and you will find it recovers from sudden changes in tilt much better. If it “overshoots” i.e. over compensates to a sudden tilt by going too far the other way, then reduce the P term. You want board to react by rapidly coming level again, not tilting too far the opposite way.

The I term makes it more likely to stay in one place than running off. It reacts to how LONG the board is held tilted for. So if going up a slope, you hold front end down a little, at first it will not get up the slope, but wait until the I term increases to larger and larger value, then it WILL eventually start to go up the slope.

Get the P and D right first on level ground.

Don’t worry about steering until it balances.

If turning rate gets faster and faster as you command a turn, there is a simple code fix for that. Let me see the vid and I can work it out usually.

John
XenonJohn (author)  XenonJohn1 year ago
In the above explanation I meant to say increase the P term until it oscillates then back it off a little. Then increase the D term until it tecovers from sudden disturbances optimally.

John
MaleBuffy1 year ago
Well I managed to make it balance. I rewired everything and it started to behave like it should.

At first it balanced but it was very slow in correcting itself, until a point that it couldn't keep up and fliped over.I then doubled the torque and power to 9 and 2 and it kept level. It jitters a little bit, but it stays level.

Thing is now when I turn, it becomes very unstable. Note that I test it without being on the board. Is the software made so that you don't have to be on the board and turn without it going crazy?

Can you suggest more setting to make it stop vibrating? Increase power or torque even more?
MaleBuffy1 year ago
I need help. I have a balancing Segway based on this project. However althoug when keept level, my IMU readings seem ok, when I press the deadman switch, the motors turn at full speed and the thing flys off. At the following link I have the serial monitor output at the time the board is level a almost 0 degrees, the deadman switch press. Motorvalues go to -100 for both motors and level value also -100.

If I let go of the deadman switch, the motor values go to zero. I don’t understand why whenn press they turn full speed, since values are zero.

Here is the link of the picture

http://db.tt/f8YkphtM
XenonJohn (author)  MaleBuffy1 year ago
Also, the startup procedure is to leave one end on ground,NOT moving at all, power up arduino, count to 10 for gyros to zero, press deadman in (nothing should happen) then bring it slowly level. When it is ;level, (still pressing deadman) the self-balancing algorithm should go active and it should start to try to balance.


John
XenonJohn (author)  MaleBuffy1 year ago
Try reversing both motor wires where they enter the Sabertooth. This is what it does when they are backp to front.

When testing keep wheels on the ground but hold bothe ends ready to pick it up if it misbehaves.

Wheels should turn in direction of the lowest end of the board. if right hand end pushed down, for example, it should roll to the right and so on.

John
I'm a mechanical engineering student interested in building one of these to ride around campus. I was wondering if anyone can tell me the top speed and how it handles hills. Thanks.
XenonJohn (author)  USAFpirate6001 year ago
How about a nice hub motor design with epicyclic reduction gears? Not thinking e-bike direct drive brushless here but a small but powerful brushed combat robot motor, and epicyclic gears to give you the torque, with small pneumatic tyres. A bit like this........
Go to this webpage and select image no 5 for his V2 machine.
http://cargocollective.com/kdoerksen/Onewheel

That could be a real neat drivetrain kit to go with this control systems kit.
XenonJohn (author)  USAFpirate6001 year ago
See video link number 4 on title page.

Buffalo State College project.

You can see it goes up a standard concrete wheelchair ramp, although the rider probably weighs a lot less than me.

Should go as fast as Razer scooter the drivetrain is based on, although never get to 100 % speed else you will fall off the front as unable to self balance at full speed!

John
el_walto1 year ago
Finally got my electronics hooked up. My platform seems react in the correct manner, but with a huge reaction speed delay. Any suggestions on a variable change? I upped the gain to a huge number, but the platform just rocks back and forth.

Maybe if my quick gyro wire is not correct this could happen?

I'm using the 2x60 sabertooth and unite 24v500w motors.
XenonJohn (author)  el_walto1 year ago
Sounds like the accelerometer is working but the gyro may not be.

The fast response is due to the gyro, with a slow correction of any drift in the gyro provided by the accelerometer. If accelerometer only working then you will get generally the correct response, but it will be very slow.

You could contact me and post a video on youtube as I can often diagnose problems by watching how it behaves.

See also my recent update where I have further simplified the build of the balance control system.

John
Yup, this isnt right for sure. I'll have to check wiring / inputs.

balancegyroDegrees:0.00 accelDegrees:48.27 overallAngleofTilt:49.02 accsum: 282.00
3,10
\n
balancegyroDegrees:0.00 accelDegrees:48.27 overallAngleofTilt:48.98 accsum: 282.00
3,9
\n
balancegyroDegrees:0.00 accelDegrees:48.27 overallAngleofTilt:48.94 accsum: 282.00
4,8
\n
balancegyroDegrees:0.00 accelDegrees:48.27 overallAngleofTilt:48.91 accsum: 282.00
So yeah, i had a small short between vref and Y-Rate.
XenonJohn (author)  el_walto1 year ago
If you apply 5v to the IMU instead of 3.3v the gyros will blow but the accels will still work - as I have found out the hard way in the past. Hope yours is still OK.

John

BuildWiz1 year ago
Would it be better to use an Arduino Mega because of the faster speed or is there no benefit between the Uno and Mega??
XenonJohn (author)  BuildWiz1 year ago
My latest board just uses an Arduino Uno. It is fast enough to read the sensors then make decisions 100 times per second, with some processing speed to spare, which is about right for a self-balancing machine. Going faster than that would not confer any real-world benefit in terms of ride quality.

Advantage of a Mega really is if you have several devices attached that use serial communications, as it has several hard-wired serial outputs, or if you have a big program and just need the larger memory or finally, if you just need more digital input/output pins. For example if I want an LCD display I tend to use one that uses serial communication to save on Arduino pins. If you use a regular LCD display this alone will use up most of the digital pins on an Uno.

If you get the older version of the Mega online, they are not actually much more expensive than an Uno.

Hope this helps

John
thanks for replying so quickly. I also had another question. On your newest board you have a row of leds I assume maybe to show battery status. I was wondering how you achieved that through the arduino?
XenonJohn (author)  BuildWiz1 year ago
It is a module you can get from one of the online robot shops. there is a 24 V version and a 36v version. You can get led voltmeter kits online too but the robot shop battery indicators seemed to be neatest solution to a simple easily visible battery voltage monitor. It is just wired across where the power leads come into the Sabertooth motor controller.

The 4 LEDS in centre console are each controlled by an arduino pin. When it first balances as you bring it level they all come on, then 3 go off. After that they come on in sequence as the torque being sent to the motors passes 70'then 90 percent as a warning to slow down a bit else you are about to fall off.
XenonJohn (author) 1 year ago
If I wrote this Instructable again I would set the internal pullup resistors in the Arduino to HIGH which can be done using software, and then make it so when you pressed the deadman it would pull the Pin down to ground (GND). i.e. when deadman not being pressed the Pin "sees" +5V and when it is being pressed the pin "sees" 0V. That way you would not need any extra resistors. The Sci-Tech group have done it that way in their version of the software.
As my code is written for this instructable at present, pressing the Deadman connects 5v to the Input Pin. The rest of the time, when the deadman button is not being pressed, the pin is pulled "down" to GND via the resistor.
If I changed it now it would confuse everyone even more!

John
XenonJohn (author) 1 year ago
You put one end on floor, let us say the left side, and wait approx 5 secs while it takes zero readings for the gyro. Then stand on the end that is on the ground with, in this case, your left foot. Press deadman switch in. Put right foot on board, then slowly bring it level. When about level the self-balance algorithm engages.
It has to be like this else, when you pressed the deadman in, while board was tipped, it would shoot off across the floor as it tried very hard to become level.
Softstart: This means when slef-balancing first engages, the overall "gain" of the software starts low then gradually increases to a target value. This stops it being too violent when you first bring it level.
The first time you do this I would lean forwards on a desk with both hands (deadman in one of them) and support about half your weight on your hands. If board then goes crazy just lean forward some more and lift your feet right up out of the way!
John
zaki44841 year ago
Hello John,

I am using 24v 350w electric scooter motor. Do you think that the 350watt motor is good for this project? because apparently that is the only motor that I could get from my supplier.
I have tested with a RoboClaw 2 channel 30amp motor driver. It burned out the first time I tried.
Do you think that the motor driver burned out possibly because of the high peak current (80amp) of the 350w electric motor?
XenonJohn (author)  zaki44841 year ago
If you hold a motor so it cannot turn, it will draw a very large current. For these projects you need reduction gearing so lots of torque, low top speed. Easiest way is a chain but segways for example have gearbox.

350watt motors would be fine, but do have to have the correct reduction as in the examples in the instructable.

John
nboyajian1 year ago
Hi there XenonJohn! Really great page you have assembled here! I have been working on a self balancing skateboard with my friend for the past 6 months or so and we have been using tons of your advice. Here is a photo of our board.

http://imgur.com/jaxF4Yv

We used a digital IMU and have the board fully balancing and rideable. We are still fine tuning the software to optimize the ride but we are happy with how far we have been able to come.

As you requested in a previous comment on this page I have set up a forum for this group to use. You can find it at www.selfbalancingskateboard.com I will post many pictures and videos of my own board very soon. Thanks again!
XenonJohn (author)  nboyajian1 year ago
Thanks for setting up the forum. Have noted it at top of the front page of this instructable.
It has no messages yet so I just posted one!

Your board looks great. If you used a digital IMU could you share the code with us or do an Instructable? There are many people out there who would benefit from it, see all messages below, instead of having to scour the globe via the web looking for an old-stock analog IMU.

Best wishes

John
kennyng1 year ago
Hi XenonJohn and friends,

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

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

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

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

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

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

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

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

John
XenonJohn (author) 1 year ago
If you just have one wide wheel, then you can ride it like snowboard and turn by tyre deformation.

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

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

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

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

John
sgovaerts1 year ago
Hey John

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

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

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

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

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

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

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

Hope this helps.

John
him2anshu1 year ago
Can you please add the 6DOF digital code again please, its been removed again, or mail me at hemu.rockz@gmail.com
XenonJohn (author)  him2anshu1 year ago
See the note I have added to the title page. I would if I were you modify the code of Thomas Feminella as he has a unicycle self balancing using a digital IMU. Therefore he is the most advanced person so far as regards getting anything capable of carrying a human to self balance using a digital IMU and Arduino.

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

John
eyhseow1 year ago
Hi All

My self-balancing likes to move left and right and doesn’t stay still in one position. Anywhere in the code where I can change to make it stay still?
Please help. Thanks.
eyhseow1 year ago
Dear Xenon John

Any update on on the SIXDOF digital unfinished code?

Thanks.

Regards
William Seow
XenonJohn (author) 1 year ago
HI everyone,

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

All the best,

John
Pizzapie5002 years ago
Hey, I got to the Just Balances point, but mine isn't balancing. I did the accsum thing, however it continues to violently waver up and down. Also it drifts a little bit forward. Any ideas?
Hello Pizzapie500,

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

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

Thanks,
Tim003
Yep. That's the exact problem, except I don't have to tilt it that far to engage tilt start. Did you figure out a solution? Your deadman switch is probably short circuiting. I had the same problem with my wii nunchuck.
Hi.

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

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

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

Thanks,
Tim003
Tim003 Tim0032 years ago
Hi again,

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

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

Here is a picture of what I did.

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

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

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

Did you try changing the values already?
Tried switching my accsum to 344 and changing the derivative gain to .7. Unfortunately, it's acting like a bucking horse.
Can you do something for me (and everyone else on this website). Could you copy and paste your serial data on here? I will put mine on her tomorrow. We should compare our data.
Some data of a bucking horse:

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

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

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

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

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

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

I see. Well, to get the correct gyro reading, I just soldered exactly the same way he did, and I mounted it using removable blue tac. Now I just have to figure out why my skateboard is over compensating and bucking.
XenonJohn (author)  Pizzapie5002 years ago
Hi,

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

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

Best wishes

John

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

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

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

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

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

John

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

SaberSerial.print(byte(0));

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

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

And what was the deal with the IMU?

I really hope you can help me.

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

Thats odd, must be frustrating I bet its a pretty popular request. Would you be willing to send it to my email? natsud1@yahoo.com or maybe post it on github? i would really appreciate it
davidwjib1 year ago
Could you re-post your code that works with the digital 6DOF IMU please?
eyhseow1 year ago
Dear Sir
Do you have any spare anlalog IMU-5DOF or 6DOF that I can purchase from you? Please advise.
eyhseow1 year ago
Dear Sir
Do you have the software code for the whole project using the digital 6DOF, and the full schematics diagram for the whole project. If not the connections between the digital 6 DOF and the Arduino. I will greatly appreciate for your help.
eyhseow1 year ago
Dear Sir,

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

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

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

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

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

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

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

I have the 60amp sabertooth, so might end up using 8S LiPo after I'm done testing with 24V SLA.
grunff2 years ago
Hi XenonJohn,

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

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

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

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

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

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

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

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

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

Hope this helps

John
Thanks for your help John, I appreciate it.

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

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

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

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

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

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

John
Thanks very much for that John. I will spend this evening trying to tune it :-)
Did you ever figure out the solution? Please tell!
Pizzapie5002 years ago
My +5V and Gnd short out doing this. Any ideas? I think it might be that I connected both +5V together since there's only one +5V pin.
Solved it. I soldered a 1.8k resistor to the +5V, and it doesn't short out anymore.
grunff3 years ago
Hi John,

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

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

Did you have any problems getting the Arduino to talk to the Sabertooth? Any tips?
XenonJohn (author)  grunff3 years ago
Don't have any easy suggestions to be honest.

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

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


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

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

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

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

John
Thanks for your help John. After spending much of yesterday playing with it, trying everything I could think of (including packetised serial), I am now 99% confident that my Sabertooth doesn't talk serial.

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

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

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

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

Balances fine, but has a tendency to wander around the garden slowly on its own.
Tim003 grunff2 years ago
Hi,

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

~Tim
grunff Tim0032 years ago
Hi Tim,

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

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

Good luck!
Tim003 grunff2 years ago
Hi grunff,

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

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

Thanks!
grunff Tim0032 years ago
Hi Tim,

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

Have you tweaked overallgain? Try increasing this from the current value, and note how this affects the behaviour.
XenonJohn (author)  grunff3 years ago
More on this:

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

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

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

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

I learned all this by falling off!

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

John
Tim0032 years ago
Here is a copy of my serial monitor. Could you please take a look?

http://pastebin.com/LpUd3PFp

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

Is something wrong somewhere?
Tim0032 years ago
Hello John,

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

Thank you!

Tim
Tim003 Tim0032 years ago
Never mind this, I found the solution. It's on the schematic with the Arduino.
nimith2 years ago
Hi John,

Sorry to Bother you again,

I am new for the Gyro and ACC concept.

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

Connected as your schematic to analog port of Arduino,

Motor Test anticlockwise -- OK !!

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

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

like this :-

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

Tilted Clockwise :-

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

and hold still to Level:-

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

so i will use 292 for the accsum then recompiled

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

I cannot get it balance Motor spin like crazy.

I think GYRO board already failed.

Thank you,

NM






Tim003 nimith2 years ago
I'm actually having the same problem as you do. Did you find the solution to get the motor spinning at its max RPM?

Thanks,
Tim
nimith Tim0032 years ago
No, I still do not figured that out.

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

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

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

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

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

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

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

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

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

Best wishes

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

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

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

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

Thank you.
XenonJohn (author)  kevinsundar2 years ago
Yes, the rear wheels from the razor e300 scooter have pneumatic tyres. They seem to come with 2 sizes of chain sprocket fitted, ideally you want the bigger sprocket for slower speed but more torque.

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

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



mbril2 years ago
Do I need this and if so do you know where i can get it from?
mjg23812 years ago
Hi,

I have (2 )100W 24V motors from the E100 scooter, will these work instead of the 250W motors you used?
XenonJohn (author)  mjg23812 years ago
The first segway type machine by the sci-tech group in australia used 100watt motors from rear of scooters. They have a couple of instructables. So, answer is yes, at least on level ground.
mjg23812 years ago
If I wanted to make this a segway platform do I need to make any changes to the code? I would think there would be some changes in regards to the IMU since its position would be different.
nimith2 years ago
Hi John,

Sorry to bother you for some question-

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

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

3. Just Balance nothing happen?

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

Thank you for helping

Nimith
XenonJohn (author)  nimith2 years ago
Note that I uploaded new version of the justbalance code quite recently.

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

John
kevinsundar2 years ago
Hello,
I am pricing my materials and was wondering what gauge wire do you recommend for connecting the batteries to the Sabertooth?

Thanks
XenonJohn (author)  kevinsundar2 years ago
At least as thick as wires on your motors, ideally thicker since you have 2 motors. Also make sure your main power switch is good quality.

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

John
nimith2 years ago
Hi John,

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

I believed the same of your configuration.

Thank
XenonJohn (author)  nimith2 years ago
I think it has its own built in voltage regulator.

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

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

John
I believed it said on the Sparkfun website

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

Features:

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


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

Nimth
cjustini2 years ago
Hi John,

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

Thanks!
XenonJohn (author)  cjustini2 years ago
Came to 7 by trial and error. Actually if you take mean of more than this it has increasingly smaller benefit. I just take 7 readings very fast almost at the same moment.

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


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

John
Thanks John, its very clear. I have managed to get an angle calculation using the gyro and accel combined, same method you suggest. However, I do not understand why we need a gyroscalingfactor, when in theory we are using the right units to get the angle... do you understand why this is necessary? Mine is closer to 3.0 rather than your 2.2.
XenonJohn (author)  cjustini2 years ago
No idea either

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

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

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

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

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

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


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

thank you

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

http://www.youtube.com/watch?v=ontfrH56gxM&feature=youtu.be
aniles jr2 years ago
i almost done i have everything together i did the imu test and the motor test and everything worked fine. but i tried to put the JUST BALANCE code on it and i followed the directions and wired everything up right but when i bring it to balance point and nothing happened i tried to open up the serial moniter and it is blank..............can you please help me my project is due on 5/31/12 thank you for all the help.
XenonJohn (author)  aniles jr2 years ago
send me a message with a working email in it and I will send you variations of the code to see where the problem is.

John
XenonJohn (author)  aniles jr2 years ago
er, you mean as in 3 days from now?

John
tranct2 years ago
Hi John,
I am a beginner. As I see on Ebay lots of Sabertooth >But they are not the same with yours -
Please, could you show me where to buy this one
Many thanks
TRANCT
XenonJohn (author)  tranct2 years ago
I googled "sabertooth 2 x 25 buy" and here are a few webstores it came up with:

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

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

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

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

John
Where can I find a complete list of all objets to buy ?
Thanks
TRANCT
XenonJohn (author)  tranct2 years ago
I didn't actually do one, naughty me.

Do it in stages.

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

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

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

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

Merci John
XenonJohn (author) 2 years ago
The code can be altered so the motor speed is limited to 50 percent. Buzzer can be added to give warning when power reaches any value you want to set.

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

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

John
thank you how long do you thing it will take me to get it to balence
XenonJohn (author)  aniles jr2 years ago
Took me 3 sleepless months first time around. I have saved you so much hassle.
If you follow instructable sometimes people get the IMU back to front and things like that. Should be pretty quick so long as no faulty components or dry solder joints, misaligned drive chains and so on.

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




Thank you very much
aniles jr2 years ago
two questions how do i wire the POT for steering and i want to limt my motors to go 50% is there a way i could put a buzzer for when it gose above 50%?

thank you
XenonJohn (author)  aniles jr2 years ago
Pot has 3 connections. Suggest using 10k Ohm pots. Connect 5V pin to one of the side connections, GND pin to the connector on the other side.

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

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

John
thank you
XenonJohn (author) 2 years ago
In the motor tester sketch motor power goes up to 50% in 10% steps, it seemed safer that way.

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

For the main code can i limit it to 50%. and when im useing the POT to steer do i turn the POT to the middle and then turn left to right?
and how do i wire the pot's
XenonJohn (author) 2 years ago
Motor tester should go to 10% power, then 20% then 30% then 40% then 50% then 40% then 30% then 20% then 10% then round the sequence again.

Make sure wheels are going in same direction, if not one of your motor wires are back to front.
John
XenonJohn (author) 2 years ago
Send me a private message with a working email address and we can correspond on this until problem fixed.

John
cjustini2 years ago
John,

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

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

Best.
XenonJohn (author)  cjustini2 years ago
I used lithium iron phosphate battery 24V from an electric bike shop on ebay.
Lots of batty summaries and discussions on electric bike forums. Some ebike shop websites have battery discussions.

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

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

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

Hope this helps
John
Delpap2 years ago
Could you send the code please, my email address is: d.prajitno@gmail.com
Thanks
XenonJohn (author)  Delpap2 years ago
Code is attached in several versions to last few pages of this instructable
Jon
aniles jr2 years ago
i know this seems like a dum question but if i put two arduino boreds toghter would it go fast like will it give faster resuslts.


thank you
XenonJohn (author)  aniles jr2 years ago
One goes plenty fast enough

If you want one to run the self balancing and for example one to read a wii nunchuck you can do that. To begin with though you just want it to balance, add all the clever controls later in the V2 rebuild.
ld'sa2 years ago
Hi Xenon,

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

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

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

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

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

Best wishes
John
ld'sa XenonJohn2 years ago
yes i tried getting the code from page 53 but i couldn't get a link to download. could you help me on that?

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

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

Best wishes

John
ld'sa XenonJohn2 years ago
i will surely give you the resources to my project if it works even 50%

thank you
ld'sa ld'sa2 years ago
in a comment i seen you have mentioned to use a 2.2K resistor what is the reason for it?
i have used varesano's code for testing my IMU and they worked just fine without the resistors...


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

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

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

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

it will stay in my head
XenonJohn (author)  ld'sa2 years ago
In theory yes!

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

Best of luck

ld'sa XenonJohn2 years ago
have one more doubt..

in your motor calculations the tilt angles and gyro rates passed are in degrees and degrees/sec respectively? or are they the raw values?
XenonJohn (author)  ld'sa2 years ago
I get raw databthen convert to degrees for accelerometer values and degrees per second for gyros. Commented saying where I do this.

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

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

Best wishes
John
aniles jr2 years ago
Were should i place my gyro im almost done :D
XenonJohn (author)  aniles jr2 years ago
In theory gyro should be in centre but in reality it does not matt that much. See the segway builds on instructables by the scitech group in Australia
2012-04-20 08.50.05.jpg
aronzitti2 years ago
Hi,
for set the accsum variable
i have insert in the foot of Setup() subrutine:
Serial.print("Setup:");
delay(3000); //3 sec delay
digitalWrite(beepPin, HIGH); delay(100); digitalWrite(beepPin, LOW);
for (int i=0; i < 50; i++){
fSetup += analogRead(accelPin); //read the accelerometer pin (0-1023)
delay(1);
}
fSetup /=50;
Serial.println(fSetup);
Serial.print("Start");
----end-----
XenonJohn (author)  aronzitti2 years ago
That does make more sense. I am working on a new project where I have added a $2 piezo buzzer. If you have a buzzer it is also very good to make the time delay between each beep proportional to (i.e. a multiple of) the measured tilt angle, in the tipstart routine. This means as you first bring it level after turning machine on, the beeps become faster and faster so you know exactly when the tiltstart is about to go active (continuous tone).
XenonJohn (author) 2 years ago
These look OK.

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

Best wishes
John
XenonJohn (author) 2 years ago
Good news.
Sparkfun have released an updated version of their 5dof analog output IMU.

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

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

John
pumo2 years ago
I got today ebay 5dof, I try to find time tomorrow night so I'll post here did it work with imu test.
one question do I need anymore those pulldown resistors to digital input?

there have been replacement for 5dof from sparkfun :http://www.sparkfun.com/products/11072
XenonJohn (author)  pumo2 years ago
If you alter code slightly you do not need the pulldowns.

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

Best wishes
John
pumo XenonJohn2 years ago
thanks I try (I am newbie with arduino) :)
just tested IMU tester code with ebay clone 5dof works!
XenonJohn (author) 2 years ago
Hi,

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

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

Best wishes
John
aniles jr2 years ago
can i use The E150 motor that seems to use 10 Amps. http://ampflow.com/ampflow_motors.htm with this motor controller http://www.dimensionengineering.com/Sabertooth2x60.htm and two 35ah batterys please HELP ME
XenonJohn (author)  aniles jr2 years ago
Hi,

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

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

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

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

A 2 x 25Amp Sabertooth would be fine.

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

If your motors are 10 Amp then you could even use the smaller Sabertooth.
i cant thank you enough

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

Thank You
XenonJohn (author)  aniles jr2 years ago
You need low speed high torque, not high top speed, at least initially when developing and learning.

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

Best wishes

John
XenonJohn (author) 2 years ago
Clone of Sparkfun 5dof IMU found on ebay:

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

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


This may help a few people.

John
XenonJohn (author) 2 years ago
Code is written for the old 5 DOF IMU with analog outputs but nobody can find one for sale any more.

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

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

Best wishes

John
pumo XenonJohn2 years ago
Thanks for your help and info, I did order that 5dof version from ebay if it wont work I just have to find 6dof analog.
Or if no luck with that I just wait your 6dof digital version code...


br
Pumo
BuildWiz2 years ago
Hi! I was just wondering if it was possible to use two motor controllers for this? and if so how would you connect them? I was looking at this one: http://www.robotshop.com/dimension-engineering-syren20-4.html.

Thank you,
Nick
XenonJohn (author)  BuildWiz2 years ago
You can definitely use one syren so can probably use two.

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

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

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

Best wishes

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

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

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

Perhaps I will buy bigger wheels like these: http://www.razorama.com/e300rearwheel.html
For doing a bit Segway off-roading :-)
skynard2 years ago
Hi XenonJohn!

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

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

Thank you.


sincerely,
han
XenonJohn (author)  skynard2 years ago
Yes I think chain is the same type.
schabanow2 years ago
> Gyro is L3G4200D, Accel is LIS331DL from ST.
Both are of 3-axis and I2C.

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

Alex.
XenonJohn (author)  schabanow2 years ago
I have just obtained a Sparkfun 6dof Razor analog IMU board. It works fine but scaling constants have to be altered a little.
This is only a stopgap as although many places still have it in stock, it is also being discontinued.

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

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

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

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

John
hello john, where did you get the 6dof razor analog imu? can you send me the store name... thanks...
XenonJohn (author)  free2flyus2 years ago
You could try these, they are UK stores:

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

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

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

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

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

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

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

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

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

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

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

All the best
John
I see. I'll try to do sth.
XenonJohn (author)  schabanow2 years ago
Example code (not fully tested) for 6dof DIGITAL Sparkfun Imu attached to page 53 of my Instructable.

John
Here some Arduino--I2C' videolessons for the meantime - I'm sure you can find these without Russian audio: http://www.youtube.com/watch?v=RcAg9XpgALI
XenonJohn (author)  schabanow2 years ago
Hi Alex

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

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

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

John
> Attached to page 53 of my Instructable.above.

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

Alex.
ps: It's a pity but I have no news on sbj from our community yet.
schabanow2 years ago
Hi XenonJohn!

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

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

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

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

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

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

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

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

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

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

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

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

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

No "another application". A4 only. My dream. ))
XenonJohn (author)  schabanow2 years ago
Another site / sensor to look at for your rocket is the ArduIMU from DIY drones.

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

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

On subject of a related paradox: I read an obscure book recently showing how an engineer who worked on the pulse jet of the V1, especially the shape of the exhaust, crucial for pulling more air into the front end, "ended up" working for MZ motorbikes in East Germany making exhausts for their unfeasibly powerful small racing engines. He then defected, went to Suzuki and shortly after that Suzuki starting winning world championships. Similar (and very noisy) extractor exhausts can be seen even now as aftermarket add-ons for small scooters.
(removed by author or community request)
> http://unmannedtechshop.co.uk/ArduIMU-V3-Arduino-9DOF-IMU
Crooked link I'm afraid... :( "Cannot be found" - I'll try it again later...
XenonJohn (author)  schabanow2 years ago
Hi again,

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

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

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

Best wishes

John
best thank to you john... i am looking forward for the code coz the 6dof (analog) is gone in the market..
> All I want is a not-too-enormous block of code that gets me the raw data from the 3 accels and the 3 gyros.

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

Concerning MZ - very interesting... Kurt Tank turned out to be much less successfull with his post-war jet-fighter in Argentina. MiG-15 - Soviet compilation of german war-time projects... Many revelations of that sort became well-known to public nowadays here in ex-USSR.
webber992 years ago
Hello guys,

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

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

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

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

Best wishes

John
justinpruss2 years ago
Here's a good one....Anyone have an issue with 24v?

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

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

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

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

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

You can fallow my project at www.aggiespaceprogram.com

Gig'em
XenonJohn (author)  looking4ideas2 years ago
Hi,

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

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

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

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

Cheers
XenonJohn (author)  dariokristo2 years ago
Hi folks,

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

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

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

usually fixes the problem.

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

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

John
XenonJohn (author) 2 years ago
Hi,

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

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

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

John
tracer11lb2 years ago
sorry here is the link of the motor I want to use

http://www.teknic.com/products/servo_motor.php
mgrachev3 years ago
Hello! I don't have an oscilloscope, how can I measure the cycle_time? Thanks. I'm trying to use your code on an Arduino with Lego and some servos, but I have to tweak the Motor output signals. Thanks for the help! Awesome instructable btw
XenonJohn (author)  mgrachev3 years ago
Hi,

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

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

Looks like Universal Pictures likes The THING you built!

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

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

the problem im experiencing is the shuddering in the entire board when changing from forward to reverse or reverse to forward , im pretty stuck im thinking its a program fault , maybe when changing directions i need to add a delay or a way to ramp power up, any guidance would be much appreciated
XenonJohn (author)  dhteam3 years ago
Hi,

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

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

3 possible solutions:

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

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

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

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

Best wishes

John
dhteam dhteam3 years ago
i helped reduce this problem significantly by having overall gain relative to angle of the board, still not great but better result.
XenonJohn (author) 3 years ago
Just to report........... I looked at the video he sent me and we did sort it out.

John
i think you can use a relay instead of that switch :D good luck
jmunsami3 years ago
Thanks for an amazing tutorial once again john. I really want a pressure sensor driven one... so i guess ill have to wait!

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

Ive also found this battery which can handle the juice.

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

thanks :D
-Jaysen
XenonJohn (author)  jmunsami3 years ago
The E150 motor seems to use 10 Amps. All the others use much more. The Sabertooth is 2 x 25 Amps (40 Amps for short periods).

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

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

Also there is now a more powerful Sabertooth I believe that will take higher currents if this is what you want.
can i use this sabertooth


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

thank you
XenonJohn (author) 3 years ago
Hi,

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

Best wishes

John
aniles jr3 years ago
wat motor would be better the on u used or this http://www.ampflow.com/ampflow_motors.htm?
dornseif3 years ago
I have been able to purchase all other items for this build except these. Cant seem to find an online source for good brackets. I am in South Carolina, any idea where I can obtain them on internet?
aniles jr3 years ago
and wat motor would be better the on u used or this http://www.ampflow.com/ampflow_motors.htm?
aniles jr3 years ago
how long can u ride ur untills it dies
dhteam3 years ago
hey thanks "XenonJohn" for this tutorial it has been a big help i have used this and a few others and a lot of researching and incorporated them all together my code seams to be working alright and a balancing bot feels not to far away ,my question is in regards to powering the board by a second source as well as the usb cable , i was wondering what happens if u dont? and if the change is noticable? i have been using only my usb cable when debugging and testing software .

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

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

Could however probably use pedal power (cautiously) in combination with a self balancing system so long as pedal derived top speed did not exceed ability of electric motors to accelerate further if starting to tilt forwards.
Cool thanks,
aniles jr3 years ago
thank you for answeing all of my qustions but i have a few more

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

thanks
XenonJohn (author)  aniles jr3 years ago
I have attached a version of the code that allows you to use a potentiometer to steer the machine.

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

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

How far have you got with your machine?
Best wishes

John
for the potentiometer would it have to go left and middle and right
thanks

im just mapping were every thing is going i m also desigining the base for it
alexw21503 years ago
I just had a thought, you should add a pressure sensor, so that if no one is on it (no pressure) it doesn't activate.
aniles jr3 years ago
can i do this set up?
025.JPG
XenonJohn (author)  aniles jr3 years ago
yes
aniles jr3 years ago
another question can i put the 2 motors in the middle connected dirctly to the 2 wheels?
XenonJohn (author)  aniles jr3 years ago
No, motors would not have enough torque (twisting-force) so you have to gear them down, and a small chain is easiest way.

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

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

Best wishes

John
aniles jr3 years ago
if i want the motors to run at full speed can i get this to do that

http://www.dimensionengineering.com/Sabertooth2x50HV.htm
XenonJohn (author)  aniles jr3 years ago
Is this a new product?
This has been designed for big combat tank style robots and ride-on vehicles.

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

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

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

Motors could draw much more current than this if physically jammed/stalled, however the sabertooth will shut itself down in that situation to protect itself.....so still OK.
ok thanks

but then how come u said i cant run the mottors at 100%?
XenonJohn (author)  aniles jr3 years ago
I don't think I did say you cannot run the motors at 100%.

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

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

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

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

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

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

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

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

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

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

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

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

John
Thank you John :D

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

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


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

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

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

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


XenonJohn (author)  jmunsami3 years ago
HI,

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

John
Haaahaa! Im not thinking as big as that! But Im Sure that these could make a much larger profit if made per 100's!
XenonJohn (author) 3 years ago
The Inertial Measurement Unit (IMU) has 2 gyros and 3 accelerometers.

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

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

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

Best wishes
John
miguipda3 years ago
Hi John,

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

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

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

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

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

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

Sincerely thanks for your informations and have a nice day.

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

Best wishes

John
miaoichi3 years ago
Hi XenonJohn,

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

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

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

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

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

John

John
XenonJohn (author)  miaoichi3 years ago
Hi,

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

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

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

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

Best wishes

John
Hi,
My e-mail shown as below
miao.ichi@msa.hinet.net

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

Regards,
Thanks.
Hi,
I uploaded picture of self-balancing board for you.
Please kindly find below link.

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

What email address can I send to you? Please provide me. Thanks.
zaborrilla3 years ago
Hi John,

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

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

Thanks for sharing your work!
XenonJohn (author)  zaborrilla3 years ago
Hi,

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

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

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

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

John
Hi,

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

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

Best wishes
John

Links to other projects:
http://sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects
aniles jr3 years ago
how can i use a potentiometer to adjust the how tight the turns are and i want to do this on the handcontroller?
XenonJohn (author)  aniles jr3 years ago
I would get it to just balance first. Concentrate completely on that.

Eveything else after that can just be classed as refinements.

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

John
wen i get mine to blance can u help me out to do that so we i lean it will turn?
tilmen3 years ago
cool work
aniles jr3 years ago
were do i get the 5volts from
XenonJohn (author)  aniles jr3 years ago
The terminal on the arduino labelled 5V

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

John



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

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

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

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

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

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

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

Hope this helps

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

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

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

John
aniles jr3 years ago
how can i use a potentiometer to adjust the how tight the turns are and i want to do this on the handcontroller
aniles jr3 years ago
is this battary good?

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


thanks

adrian
XenonJohn (author)  aniles jr3 years ago
Should be OK. You would need 2 of them.
Best wishes
John
XenonJohn (author) 3 years ago
By momentarily flicking switch forward or back you can make small adjustments to the angle of the board at which it self-balances. It is just for the comfort of the rider. If one foot feels a bit higher than the other when you are riding it, you can make a small correction while you are riding board.

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

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

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

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

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

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

Best wishes
John

thanks

but were do i get the 5 volts from the board so i could bring it to the hand controller
kriogenic3 years ago
Hey there, I am going to experiment but I was wondering if you knew if this IMU unit would be applicable.

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

I have no idea really but think it will be fine without the capabilty of resisting sudden turns?
Hey there,

I got a few things for this project underway now,

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

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

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

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

Thanks,
Kriogenic.
XenonJohn (author)  kriogenic3 years ago
When both motors running at 100% then current draw on batteries may be pretty high.

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

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

John
what if you put it up to 80% because i want mines to go fast

thanks

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

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

John
XenonJohn (author)  kriogenic3 years ago
This should work OK

Minimum needed to balance is one accel and one gyro

ursine1003 years ago
(removed by author or community request)
Hi, where did you buy the wheels please ?

Regards,
Val'
XenonJohn (author)  Montspy3 years ago
If you cannot get hold of E100 wheels which are the smallest ones with solid tyres you could maybe try the E200 wheels (200mm diameter) with chain drive which would be bigger but perhaps better over rough surfaces as have a pneumatic tyre.

Example:
http://www.monsterscooterparts.com/e200rearwheel.html
I've got 2 pneumatic tires on order. I plan on rebuilding when they get here.

Dave
XenonJohn (author)  ursine1003 years ago
I have just built yet another version of the machine with Razor E200 wheels (i.e. pneumatic tyres) with drum brake mechanism cut off each wheel and axle rods shortened.

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

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

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

Regards,
Val'
XenonJohn (author)  Montspy3 years ago
You have to bring it to the balance point very gently. Takes practice. Harder to do if your board is high off ground. Try it while leaning with both hands on a desk and you will get the idea.

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

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

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

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

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

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

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

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

Best wishes

John
XenonJohn (author)  Montspy3 years ago
Here is one:

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

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

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

John
www.razorama.com
Thank you ! I thought they don't ship outside US but their is an hidden "international checkout" button ;)
Waiting for arrival !

Thanks again ursine100 !

Regards,
Val'
No problem. I'm hoping to get mine next week.

Dave
Got them ! Building th thing :)
Can't wait to ride it int he campus !

Regards,
Val'
BuildWiz3 years ago
Hi,

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

Thanks,
Nick
XenonJohn (author)  BuildWiz3 years ago
Reading all these Q and A posts it does seem some people have faulty Sabertooths that don't read the serial communication from the arduino. This is one reason I wrote the motor tester sketch.

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

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

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

Best wishes
John



mickydee3 years ago
Hi John!
Update
I found part of the problem. It appears that my arduino DC input is bad. When I powered it up using my laptops USB port it came to life. I was using a 9 volt battery for power. The arduino lit up but would not function in the system. I have ordered a new UNO . The excess voltage 6.8 volts coming from the arduino is causing the project to be jittery. I think I will continue testing using the USB port for power.
Thanks mickydee
mickydee3 years ago
Hi John!
Everything was going well, until I soldered all the wires from my hand controller to the arduino. I am not sure if I accidentally put 24 volts to the arduino or not. Now the tipstart is not working. I checked all the wires and voltages and all seems well.
The arduino is putting out 6.3 volts instead of 5 volts. The 3.3 tap is working .
I tried the motor test sketch and it works perfectly so I think I am communicating with the Sabertooth O.K. Do you think I have blown the arduino? I tested the arduino with the blink sketch and it works fine. Any suggestions?
mickydee
XenonJohn (author) 3 years ago
Just to clarify so no confusion at all:

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

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

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

If you can position IMU so this is what you see, then you are nearly there!
John