Configure an AMS-AS5048 Encoder

The AMS-AS5048 encoder model supports AMS’s AS5048 encoder. This is an absolute encoder that uses an I2C or SPI interface to connect.

Navigate to the CONFIGURE tab of your machine’s page in the Viam app. Click the + icon next to your machine part in the left-hand menu and select Component. Select the encoder type, then select the AMS-AS5048 model. Enter a name or use the suggested name for your encoder and click Create.

Configuration of an AS5048 encoder in the Viam app config builder.

Edit and fill in the attributes as applicable.

  "name": "<your-encoder-name>",
  "model": "AMS-AS5048",
  "type": "encoder",
  "namespace": "rdk",
  "attributes": {
    "connection_type": "i2c",
    "i2c_attributes": {
      "i2c_bus": "<your-i2c-bus-index-on-board>",
      "i2c_addr": <int>

The following attributes are available for AMS-AS5048 encoders:

connection_typestringRequiredUse "i2c".
i2c_attributesobjectRequiredThe attributes to configure the I2C connection:
  • i2c_bus: The index of the I2C bus on the board wired to this encoder.
    Example: "1"
  • i2c_addr: The address of the bus.
    Example: 64

Test the encoder

Once your encoder is configured and connected, go to the CONTROL tab and click on the encoder’s dropdown panel. The ticks count is displayed. Try moving the encoder (for example, by turning a motor it is attached to) and check whether the count increases as expected.

Encoder control panel.

If the encoder does not appear on the CONTROL tab, or if you notice unexpected behavior, check your machine’s LOGS tab for errors, and review the configuration.

Have questions, or want to meet other people working on robots? Join our Community Discord.

If you notice any issues with the documentation, feel free to file an issue or edit this file.