Pcode 2.81 PDF Print E-mail
Written by Rizki Noor Hidayat Wijayaź   

For a shaft encoder in an analog port on the Handy Board (0 through 5), load *either* sencdr?.icb or fencdr?.icb. E.g., load either *sencdr0.icb* or *fencdr0.icb*. 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 any given routine, four globals are defined within IC. The following example assumes *sencdr0.icb* has been loaded (there is no difference in the global definitions for the S and F versions):

encoder0_counts

a running count of the encoder clicks

encoder0_velocity

a successive differences velocity measure, calculated every 64 milliseconds

encoder0_low_threshold

the lower limit at which point the count is increased; default is 50

encoder0_high_threshold

the higher limit at which point the count is increased; default 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.

[download: 1,35 MB]