Encoderhttp://linuxcnc.org/docs/html/hal_rtcomps.html#sec:Encoder
This component provides software based counting of signals from quadrature encoders. It is a realtime component only, and depending on CPU speed, etc, is capable of maximum count rates of 10kHz to perhaps 50kHz. Figure [.] is a block diagram of one channel of encoder counter.
Installing emc2$ halcmd loadrt encoder [num_chan=<counters>]
<counters> is the number of encoder counters that you want to install. If numchan is not specified, three counters will be installed. The maximum number of counters is 8 (as defined by MAX_CHAN in encoder.c). Each counter is independent, but all are updated by the same function(s) at the same time. In the following descriptions, <chan> is the number of a specific counter. The first counter is number 0.
Removing emc2$ halcmd unloadrt encoder
Pins (bit) encoder.<chan>.phase-A -- Phase A of the quadrature encoder signal.
(bit) encoder.<chan>.phase-B -- Phase B of the quadrature encoder signal.
(bit) encoder.<chan>.phase-Z -- Phase Z (index pulse) of the quadrature encoder signal.
(bit) encoder.<chan>.reset -- See canonical encoder interface, section [->].
(bit) encoder.<chan>.velocity -- Estimated speed of the quadrature signal.
(bit) encoder.<chan>.index-enable -- See canonical encoder interface.
(s32) encoder.<chan>.count -- See canonical encoder interface.
(float) encoder.<chan>.position -- See canonical encoder interface.
Parameters (s32) encoder.<chan>.raw-count -- The raw count value, updated by update-counters().
(bit) encoder.<chan>.x4-mode -- Sets encoder to 4x or 1x mode. The 1x mode is usefull for some jogwheels.
(float) encoder.<chan>.position-scale -- See canonical encoder interface, section [->].
Functions The component exports two functions. Each function acts on all of the encoder counters - running different counters in different threads is not supported.
(funct) encoder.update-counters -- High speed function to count pulses (no floating point).
(funct) encoder.capture-position -- Low speed function to update latches and scale position.