Quote:
Originally Posted by Ether
Hopefully the several ensuing responses from various posters have given you pause.
So if you're using PID for steering angle, and the process variable is 2 degrees, and you want the setpoint to be 359 degrees, then you would calculate an error of 359-2= 357 degrees and feed that error to your PID?
Think about it.
|
Well, it would still work regardless since I am checking and regulating the output to be a legit one that is not out of range. 359 - 2 = 357; 357/359; 0.994428969; 0.994428969 * 95 = 94.4707521; 0.994428969 *25 = 24.8607242; 0.994428969 *5 = 4.97214484
94.4707521 + 24.8607242 + 4.97214484 = 124.303621 (truncated = 124)
If that was the opposite and we were at 359 and wanted 2 it would be trouble.
-357/2 = -178.5 (that is -178.5 PERCENT, which is a big no no.)
We can deal with it this way: just regulate the error percent to be -1.0 to 1.0 or regulate the output at the end. It would both deal with that problem.
Yes my method does favor the going from a low to high than high to low.
You can say that it is an error on my part, but that is the beauty of engineering; you rarely get it right the first time.
Also I can just do higher # - lower # then divide by the higher # to always give -1 to 1. Then just put the desired input- current input as a variable and just mask out and & the number to get the + or -. I'll clarify in teh morning. I sound like gibberish at night.