May be it is like a balancing robot
Sounds to me like it is EXACTLY like a self-balancing robot. Where do you see differences?
Am i need PID controller for this system?
Maybe. Maybe not. Depends on how fast you need the system to react, and how fast the system CAN react.
Is there any reference that i can learn?
No. Google will be down until you finish your project. So, hurry it up. Millions of people are waiting.
Did you have a programming question?
Well, so far i make close loop system like this:
Error = CenterVal - rollmap; //finds error between the wanted value and what it currently is
rollServo += Error;
CenterVal= 90 (90 degree), this is the value that i want to maintain
rollmap= angle that detected by IMU (current position), i have use Kalman Filter for rollmap.
Error = difference between CenterVal and rollmap
rollServo = how far servo move
So, servo will move if error detected, servo will continue to move until Error value back to 0, which mean stable position has been reached. I have done it, servo will move until stable position reached, but servo move very slow. And the system not start smoothly. Firstly, servo will move back and forth continuously until rollServo value reach around 1500, not always 1500 but around 1500 (i print it on the serial monitor, i know servo move between 0-180, but i don't know why rollServo value has been reached around 1500 and still can make servo works), then system will works like i explain before.
I can't find out where the problem is. Can you help me?