Society of Robots - Robot Forum

Software => Software => Topic started by: MarkyMark on February 21, 2015, 12:20:29 PM

Title: PID spurious figures
Post by: MarkyMark on February 21, 2015, 12:20:29 PM
I'm playing around with a line-follower and writing code for an Arduino using a PID and a pololu IR sensor array.

The sensor array gives figures of 0-5000 where 2,500 is dead centre.  The readings come thick and fast and are good, however, maybe 1 in 20 are spurious, eg 2000,2012,2002,19,2058

The spurious 19 reading is wildly out but just one reading every 20 or so.  Does the PID just ignore this as it's so rare so won't impact? Or should I code something to ignore readings that will be outside an expected range, ie within 500 of the last reading else ignore as it can't go that far out that quickly?

Thanks in advance.
Title: Re: PID spurious figures
Post by: bdeuell on February 21, 2015, 02:36:06 PM
I would filter the data (unless you can find the source of the error ... in which case i recommend you eliminate it at the source). PID will not ignore the false data but you may not see the effect depending on how you have it tuned. After eliminating the false data you may be able to tune the PID for a better response time than you were previously able to. i.e. you may have tuned the PID constants lower than would be necessary to smoothe out the glitches that this false data would cause.
Title: Re: PID spurious figures
Post by: MarkyMark on February 21, 2015, 02:56:35 PM
Awesome, thank you.
Title: Re: PID spurious figures
Post by: Billy on March 14, 2015, 12:15:44 PM
If what you were seeing was regular noise, I expect you would also see values very much higher than recent data. But since you mention it going lower, I'm guessing you have a fundamental issue.

How confident are you that the wiring is good and nothing is loose?
That "19" value seems low enough to look like an unconnected input pin.
Are you cycling through analog inputs? It may also be that your code has a bug and reads from the incorrect pin (that isn't connected) or otherwise there is some type of timing issue built into the code.