Hi all,
I need to count pulses coming from a sensor when a switch is pressed (please refer to the attached diagram). The 8051 internal counter will be used.
When the switch is released, the counter must stop immediately and the counts has to be displayed on an LCD. An LED is also turned on for 3 seconds on switch release (using 8051 internal timer).
At the same time the counter must be refreshed to be ready for the next switch press.
Now my problem is that I am not sure which timers are best to use for this application (timer 0, timer 1 or timer 2). I am also confused on which mode to use.
Below is how I am planning to do it:
1*Use timer 0 as timer in mode 1
2*Use timer 1 as counter in mode 1
3*Wait for the switch to be pressed
4*When switch is pressed, start the counter
5*When switch is released, immediately stop the counter, display counts on the LCD, refresh counter and start the LED 3 seconds timer
6*Wait for the 3 seconds until LED is off (most probably a loop must be used for creating a 3 seconds timer delay)
7*repeat process
Now my concern is mostly on steps 5 and 6. Since these steps take time to execute, how can I make it in a way that a switch press is not ignored while executing these two steps?
Any kind of help wound be appreciated and sorry for my poor English.
I need to count pulses coming from a sensor when a switch is pressed (please refer to the attached diagram). The 8051 internal counter will be used.
When the switch is released, the counter must stop immediately and the counts has to be displayed on an LCD. An LED is also turned on for 3 seconds on switch release (using 8051 internal timer).
At the same time the counter must be refreshed to be ready for the next switch press.
Now my problem is that I am not sure which timers are best to use for this application (timer 0, timer 1 or timer 2). I am also confused on which mode to use.
Below is how I am planning to do it:
1*Use timer 0 as timer in mode 1
2*Use timer 1 as counter in mode 1
3*Wait for the switch to be pressed
4*When switch is pressed, start the counter
5*When switch is released, immediately stop the counter, display counts on the LCD, refresh counter and start the LED 3 seconds timer
6*Wait for the 3 seconds until LED is off (most probably a loop must be used for creating a 3 seconds timer delay)
7*repeat process
Now my concern is mostly on steps 5 and 6. Since these steps take time to execute, how can I make it in a way that a switch press is not ignored while executing these two steps?
Any kind of help wound be appreciated and sorry for my poor English.
Attachments
Last edited: