Configure a ti board
REQUIREMENTS
Follow the setup guide to prepare your TDA4VM for running viam-server
before configuring 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.
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:
Name | Type | Inclusion | Description |
---|---|---|---|
digital_interrupts | object | Optional | Any digital interrupts’s pin number and name. See configuration info. |
spis | object | Optional | Any Serial Peripheral Interface (SPI) chip select bus pins’ index and name. See configuration info. |
i2cs | object | Optional | Any 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
:
Name | Type | Inclusion | Description |
---|---|---|---|
name | string | Required | Your name for the digital interrupt. |
pin | string | Required | The pin number of the board’s GPIO pin that you wish to configure the digital interrupt for. |
type | string | Optional | Only applies to pi model boards.
|
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.
Important
You must also enable SPI on your board if it is not enabled by default. See your board model’s configuration instructions if applicable.
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
:
Name | Type | Inclusion | Description |
---|---|---|---|
name | string | Required | The name of the SPI bus. |
bus_select | string | Required | The index of the SPI bus. |
WIRING WITH SPI
Refer to your board’s pinout diagram or data sheet for SPI bus indexes and corresponding CS/MOSI/MISO/SCLK pin numbers.
Refer to your peripheral device’s data sheet for CS/MOSI/MISO/SLCK pin layouts.
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.
Important
You must also enable I2C on your board if it is not enabled by default. See your board model’s configuration instructions if applicable.
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
:
Name | Type | Inclusion | Description |
---|---|---|---|
name | string | Required | name of the I2C bus. |
bus | string | Required | The index of the I2C bus. |
WIRING WITH I2C
Refer to your board’s pinout diagram or data sheet for I2C bus indexes and corresponding SDA/SCL pin numbers.
Refer to your peripheral device’s data sheet for SDA/SCL pin layouts.
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.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!