PID algorithm

I am new to the robotics world and am learning the PID algorithm for a project. I was referred to this article: PID Controller For Lego Mindstorms Robots
I am attempting to write the 'P' algorithm for the project and I understand the Proportional.....

Researching

A few things to think about:

  1. What will happen if one or the other potentiometers (or both) give false readings? Will the motor stop? Or will it break something?
  2. What happens if the motor moves in the wrong direction (for whatever reason), or moves in such a manner -not- commanded by the system? How will you correct for this?
  3. What happens if the linkage between the motor and the steering breaks? Can you detect this?

Something you might want to do is add limit switches (hard wired with diodes to shut the motor off and only allow it to turn in the opposite direction) or some other method to detect far-left/far-right steering angles (and maybe even "straight ahead"); you can then have the system run a calibration procedure where the motor drives the steering "to the stops" and records the values from the potentiometer; this way, if the potentiometer shifts or changes in some manner from run-to-run, the system can compensate (to a point).

You might also hook the potentiometer up so that the wiper is feeding an analog input (as normal), while the other two leads go to digital pins. Both should be held low on startup, then bring one high, measure the value, then drop it low and bring the other high, and measure the value. Then store the sum. As the system is used, perform this test on occasion - if the values don't match the stored value (to a certain small window of percentage) - the system should come to a halt, as the steering feedback has been compromised in some manner.

There are numerous other fail-safe methods out there - think about them now, before your cart runs away, and you wish you had (and if you have, then good job - I just always point this out when people make larger robots like this, because you would be surprised at the number who don't - if they are lucky, only property damage occurs).

:slight_smile: