Main Content

I2C Register Read

Master device reads data from the I2C slave device or I2C slave device register(s)

Since R2020b

Add-On Required: This feature requires the Simulink Support Package for LEGO MINDSTORMS EV3 Hardware add-on.

  • EV3 I2C Register Read block

Libraries:
Simulink Support Package for LEGO MINDSTORMS EV3 Hardware

Description

In the I2C Register Read block, the master device reads data from the I2C slave device or the I2C slave device register. The EV3 brick acts as the master device. Any I2C device, such as a color sensor, can act as the slave device. Both the master and the slave device must be connected over the same I2C network for successful communication.

Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware supports the I2C serial data communication protocol, where each device on the I2C network is referenced by a unique 8-bit address or identifier.

Ports

Output

expand all

The block outputs the data read by the master from the slave device or slave device register(s) as a N-by-1 vector, where N represents the data size.

Data Types: uint8 | uint16 | uint32

The block outputs the status of the master read operation on the slave device or the slave device register.

  • 0: Indicates a successful read operation, which means that the data received on the Data port is valid.

  • 1: Indicates an unsuccessful read operation, which means that the data received on the Data port is invalid.

Dependencies

To enable this port, select Output error status.

Data Types: uint8

Parameters

expand all

Select the input port on the EV3 brick to which the slave device is connected. There are four ports on the hardware and you can select any one of the ports. If connecting multiple slave devices, specify a unique port for each slave device.

Enter the I2C slave device address (decimal format) on which the master performs the read operation.

Enter the register address (decimal format) of the I2C slave device on which the master performs the read operation.

Select the type of data read by the master from the slave device or slave device register. The master can read only a maximum of 32 bytes of data in a single read operation.

Enter the size of data that the Master reads from the slave device or slave device register.

For example, when you specify a value of 5, the master reads data from five contiguous slave device registers starting from the register address specified in the Slave register address parameter.

Note

The master can perform a group read operation only on contiguous slave device registers.

Enter the time interval (in seconds) at which the master reads data from the slave device or slave device register.

Version History

Introduced in R2020b