# Which controller is more suitable in this scenario? P, I or PI controller?

Scenario: A robot has a ultrasonic sensor which measures the distance to the nearest object in centimetres. The robot has two motors, a motor for the left wheels and a motor for the right wheels. The robot should hold 50 centimetres distance to the nearest found object. Therefore the motors have to change the speed of the wheels. The minimum speed is -100 which means that the wheels move backward with maximum speed. The maximum speed is 100 which means the wheels move forward with maximum speed. It can be that the object changes position abruptly for example if the object is a hand.

Which controller would you choose? P,I or PI? I would say P because if the position changes abruptly the robot can react instantly whereas using a PI or just I controller could lead to a collision if the integral is so big that if the object changes position abruptly the integral could still be big enough to move toward the object and may collide. The PI controller could reach the distance faster than the P controller but in this context the PI controller would not be suitable because of the disturbance (moving object) or? Which controller would you use here and why?

It all depends on what you want.

The easiest is a pure proportional (P) controller. It will give you an output that is proportional to the difference from the target value.

Pro: It's pretty stable (as long as you're not going too high with the gain)

Con: There will always be an difference left because the closer you get to your target the smaller the control signal gets. If your target is moving you'll have a difference which is proportional to the speed.

To get around this, you introduce an integral part (I). This integrates the error over time and makes sure that the error can get to zero.

Pro: It can get the error to zero

Con: It can be slow or lead to oscillations

To get around this, you introduce a differential part (D). This differentiates the error signal. So if the error suddenly changes, you get an immediate reaction. It makes the reaction fast so you can reduce the gain on the integral and with all three parts together nicely tuned you get a fast and stable control circuit.

So, start with a purely proportional system. If this does what you need -> great. If you need a more dynamic and precise control add I and D.

• What would be the disturbance in this context? Could I say that the disturbance which has an effect on the ideal behavior is that the target is moving? Jun 14, 2022 at 11:59
• Every change is a disturbance. Be it selecting another target or a target moving to another position. If you don't have disturbances you don't need a controler to react to it. Jun 14, 2022 at 13:46
• Another issue with PI control, which may or may not be a problem in this application, is the case of step changes to the set point. In this case, a PI regulator may cause an overshoot. To overcome this, you can add a filter to the set point signal.
– Bill
Sep 4, 2022 at 18:23