0
$\begingroup$

I'm trying to understand what the ideal sampling time for an input change represented in the form of a timing diagram should look like, for a PLC.

I understand the relationship between the sampling rate and input change to an extent. The sampling rate must be faster (at a higher frequency) than the rate of the input changes.

If I consider an example of an input that stays on for 25ms then switches off (when the input changes to a high), what is the ideal sampling rate to always measure this change and why?

$\endgroup$
1
$\begingroup$

The short answer to your question is 13 ms.

You should review the Nyquist-Shannon theorem here. For a bandlimited signal the sampling frequency needs to be >2f. If your input signal is digital then (technically) it is not bandlimited but practically there will be some limit.

The first step is to understand the signal you are sampling. I'd start with a 13ms sampling rate & run some tests to ensure you are catching all the transitions. If some are missed you can then ramp up the sampling rate until you are satisfied.

$\endgroup$
1
  • $\begingroup$ ..and damm, doubled the timing instead of halving it. Have edited to fix. $\endgroup$
    – pHred
    Apr 4 '17 at 13:44
0
$\begingroup$

My short answer is 24 ms.

Your pulse has a width of 25 ms. Therefore if you poll at 42 Hz (1 over 24 ms) you will always be certain of catching the pulse. Now it's possible that you'll only overlap the input pulse by 1 ms, leading to a maximum delay of 24 ms from the falling edge.

The sampling theorem does not apply in this situation. Shannon only applies if you are trying to exactly replicate the input signal, say a sine wave of frequency f. That would require a minimum sample rate > 2f. In this case all you want is to catch the pulse passing, not replicate it.

PLCs have hardware interrupts. If you create one of those on the appropriate I/O pin, you'll catch the pulse within the PLCs minimum specified propagation delay.

$\endgroup$
4
  • $\begingroup$ I see where you are going Paul but disagree. When sampling any signal Shannon always applies. I agree that OP is just trying to catch transitions but note that this is effectively a square wave with an infinite number of frequencies. You will note that 13ms will not efectively replicate this (even for a pure sine wave at 25ms 13ms would do a poor job). The problem is that transitions will not be perfect. Thus my comment about understanding the signal characteristics. How long does the transition take? How long is the off state? If switching time > 1ms 24ms may miss a pulse. 13ms will work. $\endgroup$
    – pHred
    Apr 4 '17 at 14:02
  • $\begingroup$ Okay, it's simple to prove. Would sampling every 24 ms detect that a 25 ms pulse had occurred or not? You're reading things into the question that aren't there. $\endgroup$
    – Paul Uszak
    Apr 4 '17 at 14:03
  • $\begingroup$ I suggest the OP experiment. Start low & increase rate until pulses start being dropped. I'd be interested to hear the results. $\endgroup$
    – pHred
    Apr 4 '17 at 14:04
  • $\begingroup$ With a 1ms ramp up and a 1ms ramp down, maybe. $\endgroup$
    – pHred
    Apr 4 '17 at 14:08

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.