I'm trying to build a two-wheeled balancing robot for fun. I have all of the hardware built and put together, and I think I have it coded as well. I'm using an IMU with gyro and accelerometers to find my tilt angle with a complimentary filter for smoothing the signal. The input signal from the IMU seems pretty smooth, as in less than 0.7 variance + or - the actual tilt angle.
My IMU sampling rate is 50 Hz and I do a PID calculation at 50 Hz too, which I think should be fast enough.
Basically, I'm using the PID library found at PID Library .
When I set the P value to something low then the wheels go in the right direction.
When I set the P value to something large then I get an output like the graph.