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.

To can configure the encoder, you must change some other configuration details:

  1. You must configure an I2C bus on your board:

    {
          "name": "<board_name>",
          "type": "board",
          "model": "<model_name>"
          "attributes": {
            "i2cs": [
              {
                "bus": "<bus>",
                "name": "<bus_name>"
              }
            ]
          },
          "depends_on": [],
    }
    
  2. Any motors using the AMS-AS5048 encoder must set ticks_per_rotation to 1. This is because the AS5048 encoder is an absolute encoder which provides angular measurements directly.

Now you can configure the encoder:

On the COMPONENTS subtab, navigate to the Create Component menu. Enter a name for your encoder, select the type encoder, and select the AMS-AS5048 model.

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

Fill in the attributes for your encoder:

Configuration of an AS5048 encoder in the Viam app config builder.
{
    "name": "<encoder_name>",
    "type": "encoder",
    "model" : "AMS-AS5048",
    "attributes": {
      "board": "<board_name>",
      "connection_type": "i2c",
      "i2c_attributes": {
        "i2c_bus": <string>,
        "i2c_addr": <integer>
      }
    }
}

The following attributes are available for AMS-AS5048 encoders:

NameInclusionDescription
boardRequiredThe name of the board to which the encoder is connected.
connection_typeRequiredUse "i2c".
i2c_attributesRequiredThe attributes to configure i2c connection:
  • i2c_bus: The name of the bus that was added to the board. Example: "main".
  • i2c_addr: The address of the bus. Example: 64.