Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

Incremental Encoder (encoder)

Gives quadrature signals, an index pulse and a position count from the shaft angle.

encoder

Component reference · 繁體中文

Group: Mechanical · Kind: {"element":"encoder","kind":"mechanical"}

When to use it

Use it to study position feedback in counts and speed estimates from them. Use Position Sensor for a smooth angle and Resolver for sin and cos.

Pins

Pin Domain Meaning
shaft mechanical Shaft terminal, it reads speed and loads nothing
a signal Channel A, 0 or 1, leads b going forward
b signal Channel B, a quarter cycle behind a
z signal Index, high for one count each turn
count signal Position count, 4 times lines per turn

Common parameters

  • lines: Number of lines per turn (Default: 1024)
  • theta0: Shaft angle at the start (Default: 0)

Parameters

Key Unit Default Typical range Description
lines — 1024 Number of lines per turn
theta0 rad 0 Shaft angle at the start

Parameter descriptions are in English in both languages.

Model

The angle is the integral of the shaft speed from theta0 and is not wrapped. The output a is a 0 and 1 square wave with lines cycles per turn, and b is a quarter cycle behind it. The count is floor(4·lines·angle/(2π)), so it goes up 4·lines per turn and counts down when the shaft reverses. The z pulse is high for one count at angle 0. The signals are written once per solver step.

Common mistakes

  • lines is the number of lines per turn (PPR), and the count is four times that. A 1024 PPR encoder has lines of 1024 and 4096 counts per turn, so do not enter 4096, and lines must be a whole number up to 1 000 000 or the run is refused.
  • The channels are sampled at the solver step. Keep maxStep well below a quarter of a line period at the highest speed, or the edges of a and b are missed.
  • z does not reset the count, so it keeps growing across turns. Its angle starts at the encoder theta0 in mechanical radians and does not follow the machine, so align it with the machine start angle.

Problems rules: compile.error

Datasheet and sources

lines comes from the part number or the PPR entry of the datasheet, in lines per turn before the 4x decoding. theta0 is the shaft angle at the start of the run, in mechanical radians.

Example

Open the example with the command file.openExample and the name demo:encoder.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.