Balancing robot for dummies

@niebing1987

You can definitly aquire angle with only one ACC
The angle is small and some folks assume sin(x) = x (in radians)
Now... the ADXL202 is a dual ACC, why don't you use the 2 axis for a more linear mesurement ?? :slight_smile:

      Acc = MeasureAcc() + ACC_OFFSET;
      MeaAngle = asin((FP32)Acc/GRAVITY_G);      //Measure angle by the accelerometer

Can I assume ACC_OFFSET is sensorZero[] ?
Is GRAVITY_G the gravity offset ? ( (ADC value "upward" - ADC value "downward")/2 )
Why is this value divided rather than substracted ?
Are MeaAngle and MeaAngleDot refering the same units for angle (deg, rad, quids...) ?

      ADData = ReadTLC4541();  //measure the anglespeed by the gyro 5000.0*(ADData-RefAD)/65536.0/0.67/K;
      MeaAngleDot = 0.001995*(RefAD-ADData) / K;

You use a 16 bit serial ADC to access the Murata gyro
Try changing the sign of MeaAngleDot

With so few information, those are only shots in the dark
What microcontroler are you using ? is it fast enough ?

Looking at the diagrams, ACC and Gyro are in phase
(gyro is zero when movement is inverted)
Your Kalman graph is just dead and may need different parameters
see danielaaroe post #157

Good luck in your quest ;), keep us aware