5DOF + Inverted Pendulum = Problems

To be honest I have been putting off showing my monstrosity of control theory but I am in dire need for direction and suggestions.

Project: 2DOF inverted pendulum.
Hardware: 2 x 29:1 12V Gearmotors, SN754410NE H-Bridge, Arduino Nano 3.0, Sparkfun 5DOF IMU.

What works thus far: The system can respond to positive and negative roll, data acquired from y_acc and z_acc data, with a complementary-ish filter combining the roll values at with sensitivity of 9.1mV/degree/s. Currently is can reach overshoot at a very small tilt, once this has adjusted once or twice it begins to dramatically overshoot, which leads me to my next point.

What doesn't :frowning: ... : I am not completely sure my complementary filter is working that brilliantly, I have done some minor tests, and my output angle only varies slightly with translation in the z and x axes, this is due to the contribution from the accelerometer. I don't seem to get drift.
I have had a lot of issue with the motors and wheels, not enough torque, not enough speed, wrong shaft sizes, etc... Basically, I am fairly certain the 350rpm no load is fast enough to response in my system, I CANNOT get any more motors due to budget restrictions. So the issue here is the PID values currently I have,

void pid() {
err = setpoint - alpha;
if ((err > -.01) && (err < 0.01))
{
err = 0;
}
PID = kperr + ki(err - prev_err) + kd*(err - prev_err)/dt;
PID_comp = PID*a;
PID = abs(PID);
PID_comp = abs(PID_comp);
if (PID > 255)
{
PID = 255;
}
if (PID_comp > 255)
{
PID_comp = 255;
}
prev_err = err;
}

What I'd love: Obviously it balancing, but I would love to implement a good filter, complementary or kalman. Accurate PID control of motors.

Any help or direction happily accepeted!

Some pics... Sorry about the bad quality of the picture and physical system....



Sorry they are so large, no time to scale them...

Gibby623

Is there any reason why the gyro is placed at the bottom? Intuitively I would think it was better to place it near the 'top'.
Now a little read will translate to quite the shift at the top of the pendulum.
:-?

Looks cool by the way!

Feel free to correct me, I read somewhere it eliminates uncertainty with the readings. No matter the position, the angle and angle rate shouldn't change. The distance it physically rotates will, but will have no effect of the angle values.

Thanks for the compliment, trust me I have not been complimenting it at all! Rather stating a few words that should not be repeated lol

i want see more pictures , the whole work.

i want see more pictures , the whole work.

Can you specify which aspects of the system in particular?

Like this :smiley: