After I get asked a question a certain number of times, a buffer overflows and I have to write something up...
When you're writing PID code, and you have something in your code like:
drive = updatePID(feedback, command);
you do _not_* have to follow this with:
real_drive = real_drive + drive;
What that line implements is an integrator, and you should already have one in your PID controller (see, for example, the treatment of iState in Listing 1 of
-- whew. Now I have something I can link to in replies --
- Or at least almost never. There are times when it's sensible to follow a PID loop with an integrator -- but you should only do it when you know what you're doing: if you need to be told, you don't know what you're doing yet.