Handy Board Simple Encoder Routines

Routines are now available to use up to seven shaft encoders, one on each Handy Board analog input. These routines work with simple break-beam or reflective encoders, and provide a count of encoder clicks as well as velocity. They count upward regardless of which direction the encoder is turning.

Download the Macintosh drivers or the MS-DOS drivers. When unarchived, a set of fourteen driver routines is created, named sencdr?.icb and fencdr?.icb, where the ``?'' is replaced by a numeral from 0 to 6 (corresponding to a driver for analog inputs 0 to 6).

The ``s'' versions stand for ``slow''; the ``f'' versions stand for ``fast.'' The S versions update at 250 Hz; the F versions, at 1000 Hz. Use the S versions unless you are losing counts, since they take up less CPU time.

For example, to install the driver for a shaft encoder in analog port 0, load either sencdr0.icb or fencdr0.icb.

For any given routine, four globals are defined within IC. The following example assumes sencdr0.icb or fencdr0.icb has been loaded (there is no difference in the global definitions for the S and F versions):

A running count of the encoder clicks. To reset to zero, simply use an assignment statement; e.g., encoder0_counts= 0;

A successive differences velocity measure, calculated every 64 milliseconds.

The lower limit at which point the count is increased. The default value is 50.

The higher limit at which point the count is increased. The default value is 200.

Depending on the performance of your shaft encoder sensor, the encoder thresholds may need to be changed. To change them, simply assign them a new value; e.g. encoder0_low_threshold= 75; The default value is restored on system reset, so this assignment statement needs to run each time the board is restarted.

Back to Handy Board Home
Fred Martin / MIT Media Laboratory
Last updated: Fri Feb 7 13:38:10 1997