How to use this on a job
The input can turn on and off without the program ever seeing it. A cyclic task samples at specific instants. Moving the same short pulse between those instants changes what the software sees without changing the sensor.
- 01
Set a fixed task interval. Samples occur at 0, one interval, two intervals and so on. Set the physical pulse’s start and duration on that same timeline.
- 02
Read the first high sample and the count of high samples. The visual scope displays a bounded portion of the timeline; the numeric calculation covers the whole pulse without iterating through every scan.
- 03
Set the TON preset. This model starts elapsed time at the first sampled high and checks the timer at each task call. It resets when a low input is sampled. A preset of zero makes Q true at the first high sample.
Work through one example
first sample = ceil(pulse start ÷ scan interval) × scan interval
With a 10 ms task, a pulse from 3 ms to 7 ms is missed. Extend it to end at 15 ms and it appears at the 10 ms sample. For a pulse from 3 ms to 43 ms and a 15 ms TON preset, the timer first sees high at 10 ms and Q becomes true at the 30 ms task call.
Before you trust the answer
This is an ideal fixed-period sampling model, not a simulation of a particular input module or runtime. It excludes input filtering, I/O update delays, jitter and asynchronous tasks. At an exact falling-edge boundary the input is low. Short pulses may need a hardware latch, interrupt or high-speed counter; check the actual hardware.