Hi,I'm working for a two-wheel balancing robot using a PID control,but now I'm having a trouble with PID.It balances for like 3 seconds before oscillating back and forth and eventually falling.This is my code:

Kinda early to look at code, but try adjusting your Kp, Kd, and Ki values. I would also consider logging data so you can see what your system is actually doing. At a quick glance, the basic code looks fine, but I need coffee (mmmm coffee ~D| ) before my brain can get more coherent thoughts out.

Logged

"Never regret thy fall, O Icarus of the fearless flight For the greatest tragedy of them allIs never to feel the burning light."

Hi,KnossorFirst,thank you very much for considering my question.I tried to adjust Kp,Kd,Ki many many time,but it didn't work.I see someone add the encoders value to their PID code,but I really don't know how to do it.

Do you know how to output data to your computer for data logging? If you do that would be a great help in determining which gains (Kp, Ki, or Kp) need adjusting. Also, where are you getting your tilt_est value from? I still haven't taken a close look at your code yet though, but I'll try to get to that in a little bit.

Logged

"Never regret thy fall, O Icarus of the fearless flight For the greatest tragedy of them allIs never to feel the burning light."

I don't know what is data logging.You means,I get the data and simulate response of the system?can you tell me clearly about that?T get the tilt_est value form the Kalman fillter.I use acccelerometter ADXL202E and gyro ADXRS150E,and I use Kalman fillter to calculate the tilt value.

Data Logging is simply when you record information. Read this tutorial about data logging.

You would output data from your sensors, important formulas, and your gains. I would output the data in a comma separated value format. Each line would then end up looking something like this (values are made up):

P, 1.5, I, 1, D, 0.15, Accel, 113, Gyro, 28, Tilt est, 13

With this information you can see what your robot is actually doing. It should really help solving your problem. For example if you see the change in P continuously increasing, then it is likely the source of your oscillations.

« Last Edit: October 14, 2010, 07:18:49 PM by knossos »

Logged

"Never regret thy fall, O Icarus of the fearless flight For the greatest tragedy of them allIs never to feel the burning light."