Monday, September 6, 2021

Tilt! - A Self Balancing Robot (#9) - The Balancing Act

 

New Gearboxes are installed time to make the balancing happen. - with video!

Video




Ugh, I spent a whole session trying to figure out why the M6050 was not communicating with the I2C bus.  It was clearly visible but no connection.  It seems that the circuit would prefer to have 3.3V in the Vcc, I was sending 5V.  Switching to 3.3V solved the problem. On to the next stage.

here are the first results:

First Test default:

double Kp = 40; // First adjustment
double Kd = 1.1; // Second adjustment
double Ki = 0; // Third adjustment

This seemed to be working, but the reaction of the motors was a bit off.  Some quick searches of LMotorController motorController() didn't reveal too much.  But I do see a factor in the code for the left and right speed factor.  These were set to 0.6.  IF these are associated to tune down the PWM signal sent to the motors, then it could mean that it is under powering.  I moved these to .8 and got a much more robust effect on the motors. On to Tuning the PID

Second Set  Test  default:
double Kp = 50; // First adjustment
double Kd = 1.0; // Second adjustment
double Ki = 0; // Third adjustment

I am getting some oscillation now, the Kd starts to tune this down.  Clearly from the video the robot has a tendency to lean in one direction.  I adjust the frame by putting hot glue between the sections, just squeezing it in and letting it harden.  I also suspect that the battery (weight inside) may be shifting forward. Using some cork, have wedged it in to prevent momentive shifting.

Third Set  Test  default:

double Kp = 55; // First adjustment
double Kd = 1.0; // Second adjustment
double Ki = 0; // Third adjustment

This was the most aggressive on the Proportional control constant that I used in the First Session. Certainly a little more 'attack' on the balance change. Starting to get some stable oscillations. 

Forth Set  Test  default:

double Kp = 55; // First adjustment
double Kd = 1.0; // Second adjustment
double Ki = 10; // Third adjustment

With this change, I added the Ki - Integral constant in to the PID. The result of Integral is to help smooth out the oscillations. There is a negative effect of controller 'Wind-up' as the integral values do not dissipate quickly. However I do not think I experienced this in this session. 

Overall the new settings in this set were not as desirable as the previous settings. Stability, subjectively, was reduced. Also, it seemed that I had a 'short' or disconnect in the power - OR - the PID was overwhelmed and stopped for about 1/2 second. Tilt! just fell over, and then everything started back up. 

Weight Adjustment 

Finally, I added a moderately heavy weight to the top of the robot. I used a Transformer that I had salvaged out of speaker. The additional weight seemed to slow the 'jitter' of the oscillations. However, the motors were unable to overcome the falling weight when it was tilted.

It seems that the robot has a tilt that needs to be identified and removed.  This is also leading to instability.  perhaps it is associated with the 'level-ness' of the sensor.

And - after repeated testing the blue wheel started to fall off. This was a temporary solution to start with.  It seems the repeated jerking started to effect the friction connection that was holding it in place. 

Tilt! A Balancing Robot - 3D Printed, Recycled Motors

Next Steps

1) identify the source of the lean/tilt

2) attach some weight to the top

3) investigate using the 12V battery and 5V power source

4) investigate easy remote control solutions

No comments:

Post a Comment