Pond Electronics - Home of the µFlash876 & µFlash876B embedded controllers, µStack & µConnect Bus.

16 Channel serial controlled timer

A µFlash876/876B Turnkey application


A popular application of the µFlash is as a serial controlled I/O device for the PC. A major advantage of the µFlash in this application its ability to be programmed to give a best match for the project requirements. This application note describes a 16 channel serial controlled timer for PC applications. The µFlash code is provided in precompiled hex format so that you may download the application the a µFlash and use it even if you do not have a C compiler.

Depending on your browser, you may need to right click (Mac click and hold) and select "save file as"


Basic Operation

Each of the 16 µStack I/O lines on the µFlash is controlled by a 16 bit count down timer (called X0 to X15) maintained in software. Each timer can be loaded with a value 0-65535 via the serial port from the PC. The timers are decremented every second, while a timer is non-zero the corresponding output is turned on. Once the timer reaches zero it is no longer decremented and the corresponding output is turned off. In order to allow activating an output indefinitely, a timer set to the value 65535 is also not decremented and will remain on until the timer is set to zero (turning the output off immediately) or some other value (turning the output off after the specified delay).

At any time you may reset a timer to a new value, or read it to determine its current status.


Installing the Timer Application on your µFlash

The timer application is loaded onto the µFlash using the standard µFlash programming method, you must have installed the µFlash Driver program on you PC before continuing. For detailed operation of the programming method, please see the µFlash Driver user manual.

  1. Download the application HEX file uTimer.hex to your PC
  2. Connect the µFlash to the PC serial port using appropriate serial cable.
  3. Ensure that the PGRM jumper is installed
  4. Power up the µFlash
  5. Drag and drop the uTimer file icon onto the µFlash Driver icon
  6. Once programming is finished, remove the PGRM jumper
  7. The timer application is now ready for use


Serial Protocol

Serial communications with the µFlash is at 57K6 Baud, 8 bits, no parity, one stop bit. Commands are sent as ASCII plain text and so a standard terminal emulator can be used to exercise the timer.

Each command starts with a # character and ends with a Carriage Return (CR) or Line Feed (LF).

For the purposes of the following text we will use <CR> to terminate each command or response. If you are using a terminal emulator <CR> can be generated by pressing the ENTER key. Also we will indicate commands in blue and responses in red.

Valid commands are:



Typical Response



Timer 1.0<CR>

Set Timer n to value y



Read Timer n



All numbers are in decimal format, only one command can be given at a time.

The timers are accessed as X registers, numbered X0 to X15. Therefore to set timer 0 to 10 seconds (ie turn on output 0 for ten seconds) use the command:


To allow easy ON/OFF control of an output, the system also recognizes the following constants:

ON = 65535
OFF = 0

Therefore to turn Output 0 on indefinitely and Output 1 off you can use:


If you have not correctly formatted a command (ie #something<CR>) the µFlash will give no response. A correctly formatted but erroneous command (eg #W<CR> or #X32?<CR>) will result in an error message.


Using the Outputs

The 16 outputs of the µFlash are logic level signals, with the addition of a series resistor they can be used to directly drive an LED or similar device. For most applications however some form of output interface will be required. You can build your own, or alternatively you can use µS-DD4 or µS-RL4 interface boards. The appropriate board will depend on your application, note that as each board provides an interface for 4 outputs, you will require 4 DD4/RL4 boards if you need to make use of all 16 timer channels.


Testing the timer

  1. Set up your terminal emulator for 57K6 Baud, 8bits,no parity, one stop.
  2. You may also wish to set it for : Append line feed to incoming lines.
  3. Connect to the µFlash with timer software installed
  4. Power up the µFlash

Initially all outputs should be off. Note that if local echo is turned off on your terminal emulator you will not see the characters that you type, only the responses from the µFlash.

Enter the following and ensure the correct response:

uTimer Rev 1.00<CR>
#X0=10<CR>          (output 0 turns on)
(output 0 should turn off after 10 sec)
#X1=ON<CR>          (output 1 turns on)
#X1?<CR>            (reading the value of X1)
#X1=OFF<CR>         (output 1 turns off)
#X1?<CR>            (reading the value of X1)
#X0=60<CR>          (output 0 comes on)
#X1=60<CR>          (output 1 comes on)
(after a minute output 0 goes off,
followed by output 1)

Note that if you make a mistake while typing the above commands, simply start again with the # character, the timer unit will ignore the erroneous text as it was not terminated with a <CR> or <LF>.


Using the timer with a PC program

While it is possible to use the timer module with a terminal emulator it is most likely that you will actually want to control it with a program running on your PC written in VB or some other language. Should you to this you should be aware of the following:

Command Terminator

As mentioned earlier the timer will accept either <CR> or <LF> as a command terminator. The timer will respond with the same terminator as was sent in the command.

Command Timing

While it is not an issue when using a terminal emulator, a fast PC program is capable of sending a second message while the timer unit is still processing the first. For this reason you should not send a new command until you have received the terminator at the end of the response to the previous message.


Copyright (c) Paul O Neill & Pond Electronics. 2003.

Home | Products | Technical Info | How to Order | Contact Us | Links