Timer Manager

Timers are useful in situations where you start an operation, wait a certain amount of time, and then stop the operation. Usually the process looks like this:

1. Start an operation (turn on or turn off an output device).

2. Start the timer.

3. When the timer expires, stop the operation (turn OFF or turn ON the output device).

You can also use timers to detect timeout conditions. For example, you turn on a motor and then start a timer. Here, you are expecting the speed of the motor (i.e., RPM) to increase. If the speed of the motor doesn't exceed a threshold before the timer times out, then you might turn the motor off and notify an operator. In these cases, you start an operation then monitor the process to see if conditions are met before the timer expires:

1. Start an operation.

2. Start the timer.

3. Monitor for desired conditions. If conditions are met, stop the timer.

4. If timer times out, stop the operation and notify operator.

In this chapter, I will describe how I implemented a countdown timer module. The countdown timer module provides your application with as many countdown timers as your application requires (up to 250). Each countdown timer has a resolution of 0.1 second and can be programmed to expire after 99 minutes, 59 seconds and 0.9 seconds. Each countdown timer can be individually started, stopped, set, reset, and checked. Also a user-defined function can be executed when a countdown timer expires (one for each timer).

Was this article helpful?

0 0

Post a comment