Main Content

I2C Register Read

Controller device reads data from the I2C peripheral device or I2C peripheral 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 controller device reads data from the I2C peripheral device or the I2C peripheral device register. The EV3 brick acts as the controller device. Any I2C device, such as a color sensor, can act as the peripheral device. Both the controller and the peripheral 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 controller from the peripheral device or peripheral 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 controller read operation on the peripheral device or the peripheral 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 peripheral device is connected. There are four ports on the hardware and you can select any one of the ports. If connecting multiple peripheral devices, specify a unique port for each peripheral device.

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

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

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

Enter the size of data that the controller reads from the peripheral device or peripheral device register.

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

Note

The controller can perform a group read operation only on contiguous peripheral device registers.

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

Version History

Introduced in R2020b