sim_encoder - simulated quadrature encoder
loadrt sim_encoder [num_chan=num | names=name1[,name2...]]
sim_encoder can generate quadrature signals as if from an encoder. It also generates an index pulse once per revolution. It is mostly used for testing and simulation, to replace hardware that may not be available. It has a limited maximum frequency, as do all software based pulse generators.
sim_encoder supports a maximum of eight channels. The number of channels actually loaded is set by the num_chan= argument when the module is loaded. Alternatively, specify names= and unique names separated by commas.
The num_chan= and names= specifiers are mutually exclusive. If neither num_chan= nor names= are specified, the default value is one.
sim-encoder.make-pulses (no floating-point)
Generates the actual quadrature and index pulses. Must be called as frequently as possible, to maximize the count rate and minimize jitter. Operates on all channels at once.
sim-encoder.update-speed (uses floating-point)
Reads the speed command and other parameters and converts the data into a form that can be used by make-pulses. Changes take effect only when update-speed runs. Can (and should) be called less frequently than make-pulses. Operates on all channels at once.
The names for
pins and parameters are prefixed as:
sim-encoder.N. for N=0,1,...,num-1 when using
num_chan=num
nameN. for nameN=name1,name2,... when using
names=name1,name2,...
The sim-encoder.N. format is shown in the following descriptions.
sim-encoder.N.phase-A bit out
One of the quadrature outputs.
sim-encoder.N.phase-B bit out
The other quadrature output.
sim-encoder.N.phase-Z bit out
The index pulse.
sim-encoder.N.speed float in
The desired speed of the encoder, in user units per per second. This is divided by scale, and the result is used as the encoder speed in revolutions per second.
sim-encoder.N.ppr u32 rw
The pulses per revolution of the simulated encoder. Note that this is pulses, not counts, per revolution (ppr). Each pulse or cycle from the encoder results in four counts, because every edge is counted. Default value is 100 ppr, or 400 counts per revolution.
sim-encoder.N.scale float rw
Scale factor for the speed input. The speed value is divided by scale to get the actual encoder speed in revolutions per second. For example, if scale is set to 60, then speed is in revolutions per minute (RPM) instead of revolutions per second. The default value is 1.00.