sim_encoder9
Simulated quadrature encoder
Usage
loadrt sim_encoder [num_chan=num | names=name1[,name2...]]
Overview
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.
Functions
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
speedcommand and other parameters and converts the data into a form that can be used bymake-pulses. Changes take effect only whenupdate-speedruns. Can (and should) be called less frequently thanmake-pulses. Operates on all channels at once.
Naming
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.
Pins
sim-encoder.N.phase-Abit out-
One of the quadrature outputs.
sim-encoder.N.phase-Bbit out-
The other quadrature output.
sim-encoder.N.phase-Zbit out-
The index pulse.
sim-encoder.N.speedfloat 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.
Parameters
sim-encoder.N.ppru32 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.scalefloat rw-
Scale factor for the
speedinput. Thespeedvalue is divided byscaleto get the actual encoder speed in revolutions per second. For example, ifscaleis set to 60, thenspeedis in revolutions per minute (RPM) instead of revolutions per second. The default value is 1.00.
Releases
Unchanged in 2 releases since Debian 12 (Bookworm).