Configure a ti board

Configure a ti board to integrate a Texas Instruments TDA4VM into your robot:

Navigate to the Config tab of your robot’s page in the Viam app. Click on the Components subtab and click Create component. Select the board type, then select the ti model. Enter a name for your board and click Create.

An example configuration for a ti board in the Viam app Config Builder.

Copy and paste the following attribute template into your board’s Attributes box. Then remove and fill in the attributes as applicable to your board, according to the table below.

{
  "digital_interrupts": [
    {
      "name": "<your-digital-interrupt-name>",
      "pin": "<pin-number>"
    }
  ],
  "spis": [
    {
      "name": "<your-bus-name>",
      "bus_select": "<your-bus-index>"
    }
  ],
  "i2cs": [
    {
      "name": "<your-bus-name>",
      "bus": "<your-bus-index>"
    }
  ]
}
{
  "digital_interrupts": [
    {
      "name": "your-interrupt-1",
      "pin": "15"
    },
    {
      "name": "your-interrupt-2",
      "pin": "16"
    }
  ]
}
{
  "components": [
    {
      "name": "<your-ti-board>",
      "model": "ti",
      "type": "board",
      "namespace": "rdk",
      "attributes": {
        "digital_interrupts": [
          <...See table below...>
        ],
        "spis": [
          <...See table below...>
        ],
        "i2cs": [
          <...See table below...>
        ]
      },
      "depends_on": []
    }
  ]
}

The following attributes are available for ti boards:

NameTypeInclusionDescription
digital_interruptsobjectOptionalAny digital interrupts’s pin number and name. See configuration info.
spisobjectOptionalAny Serial Peripheral Interface (SPI) chip select bus pins’ index and name. See configuration info.
i2csobjectOptionalAny Inter-Integrated Circuit (I2C) bus pins’ index and name. See configuration info.

Attribute Configuration

Configuring these attributes on your board allows you to integrate digital interrupts, and components that must communicate through the SPI and I2C protocols into your robot.

digital_interrupts

Interrupts are a method of signaling precise state changes. Configuring digital interrupts to monitor GPIO pins on your board is useful when your application needs to know precisely when there is a change in GPIO value between high and low.

  • When an interrupt configured on your board processes a change in the state of the GPIO pin it is configured to monitor, it calls Tick() to record the state change and notify any interested callbacks to “interrupt” the program.
  • Calling Get() on a GPIO pin, which you can do without configuring interrupts, is useful when you want to know a pin’s value at specific points in your program, but is less precise and convenient than using an interrupt.

Integrate digital_interrupts into your robot in the attributes of your board by adding the following to your board’s JSON configuration:

// "attributes": { ... ,
"digital_interrupts": [
  {
    "name": "<your-digital-interrupt-name>",
    "pin": "<pin-number>",
  }
]
{
  "components": [
    {
      "model": "pi",
      "name": "your-board",
      "type": "board",
      "attributes": {
        "digital_interrupts": [
          {
            "name": "your-interrupt-1",
            "pin": "15"
          },
          {
            "name": "your-interrupt-2",
            "pin": "16"
          }
        ]
      }
    }
  ]
}

The following properties are available for digital_interrupts:

NameTypeInclusionDescription
namestringRequiredYour name for the digital interrupt.
pinstringRequiredThe pin number of the board’s GPIO pin that you wish to configure the digital interrupt for.
typestringOptionalOnly applies to pi model boards.
  • basic: Recommended. Tracks interrupt count.
  • servo: For interrupts configured for a pin controlling a servo. Tracks pulse width value.

spis

Serial Peripheral Interface (SPI) is a serial communication protocol that uses four signal wires to exchange information between a controller and peripheral devices:

  • Main Out/Secondary In: MOSI
  • Main In/Secondary Out: MISO
  • Clock, an oscillating signal line: SCLK
  • Chip Select, with 1 line for each peripheral connected to controller: CS*

To connect your board (controller) and a component that requires SPI communication (peripheral device), wire a connection between CS and MOSI/MISO/SLCK pins on the board and component.

As supported boards have CS pins internally configured to correspond with SPI bus indices, you can enable this connection in your board’s configuration by specifying the index of the bus at your CS pin’s location and giving it a name.

Integrate spis into your robot in the attributes of your board by adding the following to your board’s JSON configuration:

// "attributes": { ... ,
"spis": [
  {
    "name": "<your-bus-name>",
    "bus_select": "<your-bus-index>"
  }
]
"spis": [
  {
    "name": "main",
    "bus_select": "0"
  }
]

The following properties are available for spis:

NameTypeInclusionDescription
namestringRequiredThe name of the SPI bus.
bus_selectstringRequiredThe index of the SPI bus.

i2cs

The Inter-Integrated circuit (I2C) serial communication protocol is similar to SPI, but requires two signal wires to exchange information between a controller and a peripheral device:

  • Serial Data: SDA
  • Serial Clock: SCL

To connect your board (controller) and a component that requires I2C communication (peripheral device), wire a connection between SDA and SCL pins on the board and component.

As supported boards have SDA and SCL pins internally configured to correspond with I2C bus indices, you can enable this connection in your board’s configuration by specifying the index of the bus and giving it a name.

Integrate i2cs into your robot in the attributes of your board as follows:

// "attributes": { ... ,
{
  "i2cs": [
    {
      "name": "<your-bus-name>",
      "bus": "<your-bus-index>"
    }
  ]
}
// "attributes": { ... ,
{
  "i2cs": [
    {
      "name": "bus1",
      "bus": "1"
    }
  ]
}

The following properties are available for i2cs:

NameTypeInclusionDescription
namestringRequiredname of the I2C bus.
busstringRequiredThe index of the I2C bus.


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.