Step 47Full code (potentiometer steering)
It is attached as a text file to copy and paste into a new arduino sketch, compile and save.
Open this sketch. We need to adjust the value of 338 to fine tune the balance point as before:
How to do this:
As when we tweaked the IMU tester: alter the value of 338 (if you need to) in this line of code in for the value you wrote down for accsum when running IMU tester and holding your board level: x_accdeg = (float)((accsum - 338) * 0.862);
Recompile the balance code with this new value in and you are now ready to try it out.
NOTE:
Updated February 25th 2012.
It works with Arduino V22. They have now released a newer version (V1.0) with a new softserial library with slightly different softserial commands so it might not work with very latest version of Arduino.
If you open up a proper Nintenso Wii Nunchuck (with special 3 lobed "Nintendo" screwdriver you have to buy on ebay) you will see that under thumb joystick is catually just 2 x 16 k potentiometers, one for side to side movement (steering) and another for forward/back (fine tune balance point). If you have a Chinese copy the potentiometer is about 3.5K, you can tell difference by the price as they look identical. You can actually solder wires onto the 3 pins of each potentiometer if you are careful and also 2 wires to one of the end buttons to use as a the deadman switch. Good thing about these potentiometers is that they self-centre at about 5-7 K Ohms.
Use multicore cable and run it back to your arduino board and you have a neat hand controller.
You may possibly have to alter values slightly in the code for the readings on analog ports on a scale from 0 - 1023
| « Previous Step | Download PDFView All Steps | Next Step » |



























































































dreniles
thank you
I have done all these things with my own projects. However, purpose of this instructable was to keep thiings fairly simple, more complexity means more things to go wrong.
You have to get it balancing first, then you add in clever features afterwards.
John
If you follow instructable sometimes people get the IMU back to front and things like that. Should be pretty quick so long as no faulty components or dry solder joints, misaligned drive chains and so on.
The IMU tester and motor tester software examples are there to help spot some of these basic problems before you get to the first self-balance test.
Thank you very much
In main code for balancing machine, it can go up to 100%.
I know its been awhile since the last comment but I was just wondering if I can use a motor with built in motor controller? thanks
Motor with a built in controller could be used if arduino can talk to the controller OK.
Remember it has to be able to go from forward to reverse with no delays or problems. Also need high torque ideally.
However the motor web page you gave me the link to shows brushless servo motors with integrated encoders (position encoders). These tell an external brushless motor controller how to turn the motor.
I could not see one there with a built in motor controller.
I have stuck to brushed motors with robot H-bridge controllers for now as brushless controllers seem more complex to get control of with an Arduino board.
If anyone knows how to reliably control an affordable hubless motor controller with an Arduino I would like to know as then I will get a 1000Watt Chinese e-bike wheel with brushless pancake hub motor and build a self-balancing unicycle!
John
BTW, Thanks to all for all the support so far. It's funny that the more DIY stuff I do the more I feel the support comes from so many others. I a very big way, none of us do anything entirely on their own :)