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):
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.