2
$\begingroup$

I have a robotic system I'm controlling with Arduino, is there an heuristic way to determine a proper sampling time for my PID controller? Considering I have some other things to compute on my sketch that require time, but of course a good sampling time is crucial.

Basically I have a distance sensor that needs to detect at a constant rate an object that is moving, sometimes slow, sometimes fast. I don't have a good model of my system so I can't actually tell the physical frequency of the system.

$\endgroup$
2
  • 2
    $\begingroup$ It really depends on what it is your PID is controlling and how fast that device responds to changes. For instance, controlling a heater you can get away with sampling periods in the order of seconds. $\endgroup$ – Majenko Nov 28 '15 at 13:07
  • $\begingroup$ Look up Nyquist frequency. Essentially you just need to worry about how the frequency of your system relates to the sampling frequency. If you want to control something to respond in 0.1 s and you are sampling at 1 Hz, then you won't get a good response (in fact, it will likely become unstable). As Majenko's comment mentions, figure out what response time you want for your controller, then choose an appropriate sampling frequency that is say 10 times the desired frequency (so if you want 0.1 s response time, then use 100 Hz). $\endgroup$ – Brian Lynch Dec 4 '15 at 1:30
2
$\begingroup$

In order to properly sample a system you need to be sampling at least as fast as the Nyquist rate, which is twice as fast as the response rate of the system, preferably faster. You can do a lot of math to find out how fast is fast enough (I suggest Ogata), or go with the rule of thumb, 5-10x the system frequency.

Since you are detecting the rate that an object is moving, you need to sample it fast enough to see it move no more than the minimum you care about.

As an example, lets say your maximum rate is 100mm/s, and you want an accuracy of 1mm.

In this case, to see the object move no more than 1mm, you would need to sample at 2 x (max speed / accuracy) = 2 x (100mm/s / 1mm) or 200Hz minimum, and preferably you would be sampling at 500-1000Hz per the rule of thumb.

$\endgroup$
2
  • 1
    $\begingroup$ Welcome to robotics carmiac. I presume that you mean Katsuhiko Ogata, but you might want to edit your answer to mention the specific book you are referring to. $\endgroup$ – Mark Booth Dec 4 '15 at 11:38
  • $\begingroup$ Thank you for your answer! I was familiar with the Nyquist rate, I was looking for a tecnique to sample a phisical system with no mathematical model and you gave me a good explanation. $\endgroup$ – Gian Mauro Musso Dec 4 '15 at 19:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.