Math Bridge: Polling interval and missed events

← Back to Microcontroller Programming Essentials
Math BridgePrototypingStruggle-friendly runway

When does delay(250) make a real event disappear?

Turn one polling interval into a sample rate. Then compare a slow LM35 signal with a short button event.

Voltage Vera, the prototyping guideVoltage Vera guides
The one targetTurn a polling delay into the fastest event it can preserve.
The chapter caseA 250 ms loop, 100 ms event, and 12-bit LM35 reading.
What it buys youA timing choice that separates slow sensing from missed events.

A field team faces an unresolved physical question: When does delay(250) make a real event disappear? They must answer it before changing sample rate on the real device. Predict the direction first.

See the relationship before changing it

The figure reads from left to right. The blue card is sample rate. The middle card applies this page's relationship. The green card is nyquist ceiling. Walk the arrows once: set the input, apply the rule, then read the result with its unit.

The retained audit below checks several chapter fixtures. This added model holds every other chapter fixture fixed, so the numeric fixture does not switch without explanation.

Sample rate changes nyquist ceiling An input card leads through the page relationship to the nyquist ceiling result. SET INPUT ONE CONTROL APPLY RULE predict calculate check units READ RESULT
Walk the arrows. Scheduling controls whether the input is observed; converter resolution controls how finely an observed voltage is represented.

Derive the baseline in four named moves

  1. 1

    Name the input. The chapter baseline for sample rate is 250.

  2. 2

    Name the relationship. f s =1000/250=4.0 Hz f max =4/2=2.0 Hz button requirement=2/0.100=20 Hz required interval=1000/20=50 ms ADC step=3.3/4096=0.806 mV LM35 step=0.806/10=0.0806 °C

  3. 3

    Substitute the chapter fixture. Set sample rate to 250. The page ledger gives nyquist ceiling as 2.00 Hz.

  4. 4

    Read the result. Keep Hz beside the value. Use it only inside the technical boundary on this page.

Predict, then change sample rate

Try Predict the direction of nyquist ceiling. Move one control, calculate, then check your prediction.

250
Chapter baseline
Nyquist ceiling

Observe Scheduling controls whether the input is observed; converter resolution controls how finely an observed voltage is represented. Reset the control to 250 and compare nyquist ceiling.

Explain Only sample rate moves here. The other chapter fixtures remain fixed.

Check yourself

What should you do before trusting a moved-control result?
Answer: Predict its direction, apply the shown relationship, keep the units, and reset to the worked baseline.
What does this small model leave out?
Answer: Only sample rate moves. Field effects named in the page's technical boundary stay fixed.

1. Start with time between observations

A polling loop can see the input only when it checks. A 250 ms delay means four checks each second. Slow room temperature changes easily fit inside that schedule. A 100 ms button press can begin and end between checks, so the same loop can miss it completely.

Voltage Vera: A delay is also a sampling decision. Name the shortest event before choosing the interval.

2. Name every algebra move

1

Convert milliseconds to ratefs=1000/Tms.

2

Find the Nyquist ceilingfmax=fs/2.

3

Set the event requirementA duration τ starts at fs≥2/τ in this teaching rule.

4

Invert rate to intervalT=1/fs.

5

Convert ADC volts to temperatureDivide voltage step by the LM35 slope.

3. Reproduce the chapter case

fs=1000/250=4.0 Hz
fmax=4/2=2.0 Hz
button requirement=2/0.100=20 Hz
required interval=1000/20=50 ms
ADC step=3.3/4096=0.806 mV
LM35 step=0.806/10=0.0806 °C

The 250 ms loop is five times slower than the 50 ms teaching requirement for the short event. Its ADC resolution is already fine for the LM35 example; timing, not voltage resolution, is the risk being exposed.

4. Try the polling interval

TryMove the loop interval while the 100 ms event and ADC stay fixed.

Sample rate
Nyquist ceiling
Event requirement
Required interval
Speed-up required
ADC voltage step
LM35 temperature step

ObserveAt 50 ms the simple event requirement reaches 20 Hz. Changing the loop interval does not change the ADC voltage or temperature step.

ExplainScheduling controls whether the input is observed; converter resolution controls how finely an observed voltage is represented.

Technical boundaries.

This is a regular-sampling teaching comparison, not a guarantee that polling catches every asynchronous pulse.

Event capture
Pulse phase, jitter, bounce, execution time, interrupts, and hardware latching affect guarantees
Nyquist use
A one-off button pulse is not a band-limited sinusoid; the 2/τ rule is a conservative runway here
ADC result
Reference error, noise, calibration, and LM35 accuracy exceed a simple code step

Measure worst-case loop time and use interrupt or latch hardware when missing an event is unsafe.

5. Choose the timing mechanism

Use elapsed-time scheduling when several slow tasks need turns without blocking each other. Use an interrupt or hardware capture path for short, important events. Keep the interrupt handler small and move slow work back into the main loop.

6. Record the evidence state

Store the event width, polling interval, maximum loop time, interrupt setup, debounce rule, ADC reference, bit depth, sensor slope, raw codes, firmware version, and a trace showing both caught and deliberately stressed events.

7. Check yourself

Why does 250 ms mean 4 Hz?
Answer: One second has 1,000 ms, so 1,000/250=4 checks per second.
Why is the teaching interval 50 ms for a 100 ms event?
Answer: The runway uses 2/0.100=20 Hz, then 1/20=0.050 s=50 ms.
Does a 0.0806 °C code step prove that temperature readings are that accurate?
Answer: No. It is resolution from the ideal ADC step and sensor slope, not total sensor-system accuracy.
Honesty boundary.

The arithmetic reproduces the chapter's 250 ms, 100 ms, 3.3 V, 12-bit, and LM35 values.

4.0 Hz
The nominal loop rate before other work and jitter
50 ms
A teaching interval, not a universal pulse-capture guarantee
0.0806 °C
An ideal code step, not temperature accuracy

Correct, not complete: this ledger does not replace measured worst-case timing or a proper event-capture design.