Configure a single encoder
A single
encoder sends a signal from the rotating encoder over a single wire to one pin on the board.
Software calculates the relative position that the motor has rotated.
Configuring a single
encoder requires configuring one pin (i
) on the board to which the encoder is wired.
The direction of spin is dictated by the motor that has this encoder’s name in its encoder
attribute field.
On the COMPONENTS subtab, navigate to the Create Component menu.
Enter a name for your encoder, select the type encoder
, and select the single
model.

Fill in the attributes for your encoder:

{
"name": "<encoder_name>",
"type": "encoder",
"model" : "single",
"attributes": {
"board": "<board_name>",
"pins": {
"i": <string>
}
}
}
The following attributes are available for single
encoders:
Name | Inclusion | Description |
---|---|---|
board | Required | The name of the board to which the encoder is wired. |
pins | Required | A struct holding the name of the pin wired to the encoder:
|
Viam also supports a model of encoder called "incremental"
which uses two pins.