When to use PID for motor control

embeddedpid controllerrobot

I have a project involving a small robot and I need to write the firmware to control the wheels. Its not something I have done before, so I did some research.
In my research I saw that some people use optical encoders and PID to allow the motors to have consistent power.

My question is, is this always needed? I can understand how PID works and what the optical encoder is for, but its not clear to me exactly why its needed.

The robot does not need to track distance, direction of its motors or anything like that. It will move according to time e.g. move forward 2s

Thanks

EDIT:
To clarify on the spec:

  • The robot will be given instructions before it starts

  • instructions will always be pretty simple such as go straight for 5 seconds, turn left, turn right

  • The robot is never controlled by a person in real time, it just executes its instructions and stops.

  • It could execute instructions depending on sensor inputs for example if it detects an object using ultrasonic sensor, it may move backwards for 2 seconds.

  • The speed that the robot moves is not that important. For moving straight, one speed can be set (using pwm)

Best Answer

As always, what is your specification?

If the robot only has to move, and you are not too bothered about exactly how far, or whether in exactly a straight line, then a DC motor on each wheel simply switched on and off, or maybe speed controlled open loop with PWM, will do the job in the cheapest, easiest way. The assumption here is that the driver (human or some imaging computer program) is looking at the robot and correcting the next move command. With good DC motors, speed is well controlled by the terminal voltage, especially at low and balanced loads.

If you want a straight line, or exact distance, or profiled speed control, then you have a choice of DC motors with optical encoders PID closed loop, or stepper motors. Be aware that these only control the amount the wheels turn. If you want accurate wheel position to actually give you to accurate ground position, then your wheels must be perfect, equal diameter, running without slipping on a surface with no contamination.

It may be therefore that PID control of the motors is not sufficient to give a good ground position spec, and some form of geographic position sensing is needed. Once you have that, the need for closed loop on the wheel motors becomes less, unless you are trying to hit a very tight position/speed/time profile specification.

I'm not sure I understand what the phrase 'consistent power' means in this context, or why it should be desirable?