Skip to main content

Periodic Timers

Loading...

AppBlocks has another type of timer called a periodic timer. Unlike the plain (one-shot) timers discussed in the previous topics, periodic timers:

  • Are configured at design time and cannot be reloaded at run time
  • Are always running (cannot be stopped)
  • Cannot be restarted
  • Auto-reload and start counting down again as soon as they reach zero

Periodic timers are implemented as On Time Period event blocks. To configure the timer period, drag the On Time Period block onto the canvas, click on it, and set the desired period in the block's property sheet:

periodic_timers_1

Here is a simple project with two periodic timers, one programmed for a 5-second interval and another one -- for a 7-second interval.

The project also introduces two new useful blocks: LED Pattern and Buzzer Pattern. Every time a 5-second timer expires, an LED pattern will "play" on your TPS' red and green status LEDs. Every time a 7-second timer expires, your TPS will beep a buzzer pattern. Again, the patterns for the LED Pattern and Buzzer Pattern blocks are set on the blocks' property sheets:

periodic_timers_2

LED Pattern Format

The pattern used in this application -- "G-R-B" -- means:

  • Beat 1: Green status LED is on
  • Beat 2: No LEDs are on
  • Beat 3: Red status LED is on
  • Beat 4: No LEDs are on
  • Beat 5: Both green and red status LEDs are on

So, G, R, B, and - are like beats in a melody -- each beat is allocated the same standard time. Your pattern may include up to 16 beats.

There are also two modifiers:

  • Adding * anywhere in the pattern makes that pattern play twice as fast. You can add up to three * characters to achieve the x8 pattern speed.
  • Adding ~ anywhere in the pattern will make this pattern loop, i.e., play repeatedly, until another pattern is loaded (using another LED Pattern block).

Buzzer Pattern Format

Your beats may include the following:

  • B for "beep," and
  • - for "silence"

As with the LED patterns, you can add up to three * characters to increase the pattern speed and ~ to make it loop.