6. I²C interface

To control the Motoron M1T550, M2T550, M3S550, M3H550, M1T256, M2T256, M3S256, M3H256, M2S, or M2H, you will need to use the Motoron’s I²C interface.

I²C is a specification for a bus that can be used to connect multiple devices. The bus uses two signal lines: SDA is the data line and is used to transmit and receive data, while SCL is the clock line is used to coordinate the flow of data. There are two types of devices that can connect to an I²C bus: a controller is a device that initiates transfers of data, generates clock signals, and terminates transfers, while a target is a device that is addressed by a controller. The Motoron acts only as a target.

I²C voltage levels

The voltages on the Motoron’s SDA and SCL lines must not exceed 6.5 V (they are 5 V tolerant). Each of these lines is pulled up with an on-board 10 kΩ pull-up resistor. On the Motoron shields for Arduino, the pull-ups connect to IOREF. On Motoron controllers for Raspberry Pi, the pull-ups connect to the 3V3 pin. On other Motorons the pull-ups connect to the VDD pin. For the signals on SDA and SCL to be read properly by the Motoron, the low level must be less than 30% of the Motoron’s logic voltage, and the high level must be more than 70% of the Motoron’s logic voltage.

I²C clock speed

The Motoron’s I²C interface supports clock speeds up to 400 kHz. It uses clock stretching to slow down the transfer of data when bytes are written faster than it can handle, or if a read transfer is started before data is available.

If your I²C controller does not support clock stretching properly, you can avoid clock stretching by limiting your write transfers to be at most 31 bytes long and delaying for 1 millisecond after each write transfer to give the Motoron time to process it.

I²C address

By default, the Motoron uses the 7-bit I²C address 16. This address is stored in the Motoron’s non-volatile EEPROM memory, and you can change it by sending a “Write EEPROM” command. If the JMP1 pin is shorted to GND at startup, the Motoron will ignore the address in EEPROM and use 15 as its I²C address instead. The Motoron determines what I²C address to use when it starts up, so any changes to the JMP1 pin or the EEPROM will not take effect until the next reset.

The Motoron also responds to the I²C general call address (0) in addition to its normal address by default. This allows you to send the same command to multiple Motoron targets simultaneously. The general call address is write-only; reading bytes from it is not supported. (However, if you send a command to the general call address that results in a response, you can read the response from an individual Motoron using its regular address.) You can use the “Set protocol options” command to disable the general call address, but it will become re-enabled the next time the Motoron is reset.

I²C protocol

There are two types of data transfers that can be initiated by an I²C controller: a write transfer writes some number of bytes to a target, and a read transfer reads some number of bytes from the target.

When you write bytes to the Motoron using write transfers, those bytes are interpreted as commands as described in Section 9. The Motoron does not care how the bytes are grouped into write transfers: you can send each command in its own transfer for simplicity, or send multiple commands together in a single transfer for extra efficiency. The Motoron acknowledges every byte written to it using I²C’s built-in acknowledgment mechanism, regardless of whether those bytes actually form valid commands.

Some Motoron commands generate responses. To read the response to a command, you can start a read transfer after writing the last byte of a command, before you have written any other bytes. (To ensure that responses do not get mixed up, the Motoron clears its stored response every time a new byte is written.) It is OK to skip reading a response if you do not need it, or to just read part of it. It is also OK to read the response using multiple read transfers.

If you read bytes via I²C at a time when there is no response data available, the Motoron will provide a value of 0xAA for each byte you read. This can happen if you read at the wrong time, or if you read too many bytes. Enabling CRC for responses (as described in Section 9) and checking the value of the CRC byte is a good way to detect if this is happening.

Related Products

Motoron M3S256 Triple Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M1T550 Single I²C Motor Controller (Header Pins Soldered)
Motoron M3H550 Triple Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M3S550 Triple Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M1T256 Single I²C Motor Controller (Header Pins Soldered)
Motoron M2T256 Dual I²C Motor Controller (Header Pins Soldered)
Motoron M2H18v18 Dual High-Power Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M2S18v18 Dual High-Power Motor Controller Shield for Arduino (Connectors Soldered)
Motoron M3H256 Triple Motor Controller for Raspberry Pi (Connectors Soldered)
Motoron M2T550 Dual I²C Motor Controller (Header Pins Soldered)

Related Categories

Motoron Motor Controllers
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors