---
name: "sim_encoder"
section: "9"
platform: "linux"
package: "linuxcnc-uspace"
version: "1:2.9.4-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/sim_encoder"
---

# sim\_encoder(9)

simulated quadrature encoder

## NAME

sim\_encoder - simulated quadrature encoder

## SYNOPSIS

**loadrt sim\_encoder \[num\_chan=***num* **\| names=***name1***\[,***name2...***\]\]**

## DESCRIPTION

**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 **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.

## 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-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.

## PARAMETERS

- **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.
