0
$\begingroup$

I'm at the stage where I assembled a balancing robot and it's not maintaining a stable position. This is not a surprise I just started testing last night.

My code is here, views of the device are here.

Briefly, it's based on a teensy 3.2, a brushless motor controller that receives I2C commands that drives brushless gimbal motors. It uses an MPU9250 for angle measurement. I'm using PID control, and I made a tkinter-based interface that allows me to send it P/I/D values for realtime testing. I plan on implementing a bluetooth based serial to reduce wires going to the device.

At this stage I'm not asking people for specific help on debugging what's going wrong, I'm asking about a general strategy for testing. I have used the RAM on the teensy before to record PID response time and then send that data to pyplot, which was very informative before. I was wondering if it would be a good idea to detach my wheels and mount the motors to a rigid pedestal - and to do some PID tuning using that system to tweak the wobbliness/stability. My reasoning being "hey if I can't get this thing to stay upright when it's rigidly mounted to the bench, why would it work when it's got wheels on it?"

Are there any comments on this strategy, and would anyone want to offer other ways to go at the problem at this point? Yes, I've read the many posts on PID tuning, I'll follow them as best I can.

I can post pictures and other code examples but newbies only get to put two links into the OP.

$\endgroup$
1
  • $\begingroup$ I once developed a three-axle gimbal system for a camera from skratch and I know this motors and control techniques very well. If you don't use some feedback of your motor postion and so a torque based technique, you will never achieve good results, especially at very slow speeds. I recommend to use in addition to the IMU two rotary encoders and a torque based approach and you will achieve a controller in minutes. Another way would be to use brushed DC motors, since you then have already torque control integrated. $\endgroup$ Aug 23, 2017 at 7:15

1 Answer 1

1
$\begingroup$

Well assuming you are using a filter(Kalman or Complementary) for the IMU, the PID tuning can be quite a cumbersome task. There is not a fixed end approach on tuning your PID. It took my Self-Balancing Robot three days to tune. But here is a general tuning strategy you could use:

  1. Set your Ki and Kd to zero and tune your Kp such that it is just able to balance itself with large oscillations.
  2. Start with your Kd and see to that the oscillations are going away.
  3. Now comes the optimisations and the hard part. You have to now fine tune both Kp and Kd so that oscillations go away and robot is able to balance.
  4. Using the Ki is quite tricky as it slows down your system as you are continuously adding a term. I haven't played much with the Ki term, though people now and then have used it.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.