Use timestamped records to examine multiple signals from a single button press, and define input handling rules.
Before practice
01 Does one button press mean one signal?
Description
Contact bounce can produce several recorded changes in a short time.
02 Do polling intervals and debounce times serve the same role?
Description
Polling is the observation interval; debounce is a rule for grouping closely spaced changes into one.
Execution conditions
Use the recorded waveform for the baseline exercise. For the hardware extension, compare the BCM numbers and input/output settings in the original RPi.GPIO code with the board you use.
(t_ms,level)=[(0,0),(10,1),(12,0),(14,1),(50,0),(80,1)]. Between records, the preceding level is maintained.
Procedure
Reconstruct 0~100 ms at 1 ms intervals and draw a step plot.
Find the times of the rising and falling edges in the original record.
Record the cumulative count with only rising edges counted by the counter.
Results to retain
An input step plot and a transition time table.
Items to record and points to check
t [ms]
level
Edge type
Cumulative rising count
Points to check
Did you avoid counting the initial level as a transition?
Do repeated readings of the same level avoid being counted as new edges?
2. Effects of polling intervals
Starting conditions
Read the same waveform at ms intervals. Keep the original edge record unchanged.
Procedure
At each polling time, read the level of the preceding event.
Recount rising edges in the sampled data and compare with the original record.
Identify the actual intervals of the short pulses that disappeared.
Results to retain
Three sampling plots and a comparison table.
Items to record and points to check
Polling interval [ms]
Number of samples
Detected rising count
Missed intervals
Points to check
Did you change only the sampling interval while keeping the original waveform fixed?
Did you distinguish event times from the times they were detected by polling?
3. Filter contact bounce
Starting conditions
Set the minimum accepted interval between rising edges to 20 ms. Evaluate each edge relative to the last accepted edge.
Procedure
From the raw rising list, ignore subsequent edges less than 20 ms apart.
Change the limit to 5,20,50 ms and compare the number of accepted edges.
Read the GPIO.setmode and time.sleep arguments in Week6-1_GPIO_LED_Test.ipynb, and explain how its pin numbering scheme and time units relate to this activity's records. Complete this by reading the code only.
Results to retain
A table for the three conditions and 3 sentences describing the handling rules.
Items to record and points to check
Minimum interval [ms]
raw count
Accepted count
Accepted times [ms]
Points to check
Do discarded edges leave the last accepted time unchanged?
Did you distinguish BCM numbers from the board's physical pin numbers?