2) the bot is much smoller than previous version (now 25 cm).
With our motors the bot has to be small and "not high" other wise you'll never correct a tilt with a K*velocity of motors, velocity of motors will only generate a translation of the bot that will compensate only partially the tilt.
With heavy wheel and a toll bot K*velocity will compensate the tilt.
1) I did find (making 10 tries and then evaluating an average) the "zero" values of the 2 Acc and the Gyro. Then You have to use always this 3 zero values..your tuning will not depend any more on the starting position.
2) I manually found the "real" setPoint (the one that makes the mass center cross the motor line).
3) I used a potentiometer to find the right set of PID values;
4)You'll find Kp working with the potentiometer as the values that make the bot oscillating (it will jitter because of backslash...)
5) Then I used a low Pi and found Kd using the potentiometer as the values that make the stop oscillating...be careful if you use a bigger Kd the bot will be "nervous"..
6) Kpwheel will be set as enough to make to bot turn back, but it will create again oscillation (non on the tilt but on the position);
7) Kdwheel will be set as the values that make the stop oscillating on the position.. be careful if you use a bigger value the bot will be "nervous"..
One simple question....does Your Bot balance even only with PID based on tilt angle (with no PD from encoders)?
In other words, if You put Kp_Wheel=0 and Kd_Wheel=0 and leave untouched Kp, Ki, Kd, dows Your bot still balance?
I am fighting with the first step of balancing (increase Kp till oscillation occours..), then increase Kd (starting from zero) till oscillation disappear..
We all are using the same motors but I cannot reach the "oscillation occours" status unless using a very high Kp, that means a huge jittering..I know motors are not exactly the same, my be mine have a bigger backslash than yours..
I am trying to use a quadratic formula like this: pTerm = 0.75*error*(1.0+1.4*abs(error)) in order to have smoller jitter (around zero) but an aggressive ramp good to make the Bot oscillating.
OK, I find out the problem...I was using Serial.begin(9600); instead of Serial.begin(115200)...4 simple Serial.print used to debug were taking 40ms...Kalman was KO (the Kas Kalman code is expeting to be used every 10ms...).
Now the Bot can stay up, but I think PID parameters need to be tuned...
the problem is the battery.. i get back to my old battery (a very simple pack of 10 1,2 nimh 2600mah) and the system does not switch off..anyway it still does not stay up..
Ok, the photo "1" is my first release..it could stay up for 45 min, it hat a sonar sensor to avoid obstacles and a turning infrared receiver to understand the direction of the ir emitter and to follow it....the main kode was based on Kas thread.
I think that some inverse current coming from the motors burned arduino, the sonar sensor and the Sparkfun 5DOF analog IMU....at that time I was using the simple pack of 10 1,2 nimh 2600mah.
The new release is based on Freeimu (from Fabio Varesano), a digital 9DOF that is working pretty fine (photo "2"). I inserted a diode on the +12v line that powers the motor driver.
The crappy battery that does not work is in the photo "3" ..I am now back on the simple pack of 10 1,2 nimh 2600mah, the system does not switch off but i cannot reach the "until oscillation occurs" (with Kd=0)..I believe that motors are not powered enough..
I'll try to build up another pack of 10 1,2 nimh 2600mah and put the 2 pack in parallel or try to order your same Lipo battery pack...
1. make the bot higher (from 30 cm to 50 cm)..4 floors instead of 3... 2. use 2 potentiometers to change Kp and Kd without compiling and uploading each time... 3. use a 4800mah li-ion instead of a 2600mah mi-nh battery...
We are using the same Pololu motors, do You think that the new battery could drive better the motors?
i am using the same code You are using (more or less Kas style)..
the theory for PID tuning says:
For manual tuning, set all three constants to zero, then turn up Kp until oscillation occurs. Then turn up Kd until oscillation disappears. Adjust Kd until the system is critically damped, i.e. there's no overshoot.
Did You follow this rule?
Could You post a video of your bot drived only from Kp (IMU) until oscillation occurs?
I would like to understand what means "oscillation occurs".
Driving my boot only with Kp this is what happens:
Kp low the bot falls; Increasing Kp around the " error zero" it vibrates a little bit then falls.
do I have to assume that " until oscillation occurs" means this vibration around " error zero" or an oscillation should be more "important", lets says -20 __0___+20 or -40 __0___+40 in pids?