Hello. I am trying to set up a system of Servomotor and a combo board (gyro + accelerometers). I am using PID and the setups is such: setpoint is zero degrees, input is angle from the combo board and output is Amplitude of rotation of servo arm on my servo. I made it work, but it only works when incline the combo board in one direction and gives positive angles. however, when incline the other way and it gives negative angles PID does not do anything. Is there any solution to that?

I am working on a project, which involves PID controller, Arduino, IMU combo board (gyro + accelerometer) and a servomotor. The aim is to keep IMU horizontal at zero degrees, when it inclines amplitude of oscillation of a servo arm on my servomotor increases and when IMU is back in horizontal position amplitude is zero. I set my PID as such: Input = angles from IMU, Output = Amplitude, Setpoint = 0 degrees. It works fine in one direction when angles from IMU are positive, however, in the other direction when angles are negative PID does not respond. Could anyone help me to find a solution for that problem?

I managed to solve this problem by introducing two PIDs in the code and multiplying input for one of them by (-1), however, it is not an elegant solution and I am still looking for a solution using single PID?

I did not want getting any negative amplitudes. I was expecting it to increase amplitude when angle is not zero.

It can't 'increase amplitude when angle is not zero' when the angle is negative, because you've prevented it from outputting a negative value. The PID has run into the end stops that you have defined, and it can't go any further.

Please show a real example of where it has produced the wrong behaviour and explain what you wanted it to do.

I only provide help via the forum - please do not contact me for private consultancy.