Firmware-820 Message-010

From I-CubeX Wiki
Jump to: navigation, search

I2C DATA (10, 0Ah)

In host mode the WiDig sends digital (I2C) sensor values, after being activated through a FUNCTION command, in the I2C DATA message.

The [BODY] of the I2C DATA message contains a list of sensor values as specified in the function’s method. 8-bit values are sent as two nibbles inside a byte each:

00000yyy: yyy = [0..7]; sensor input number, where the first input number = 0 and the last (8th) input number = 7
0ddddddd: ddddddd = [0-127]; I2C device address
0nnnnnnn: nnnnnnn = [0-127]; function number
0ppppppp: ppppppp = [0-127]; function method or parameter
0000dddd:
0000eeee: ddddeeee = [0..255]; data (number of bytes as per function specification)

Example:

The WiDig has function Orient3D, method 1, enabled an Orient3D sensor with device address 96 connected to I2C port 1. The WiDig acquires the value 90 (heading east), 45 (pitch down), and -45 (roll to the right). The WiDig sends the following message in host mode:

240, 125, 0 {DEV}, 10 {I2C DATA}, 0 {I2C port}, 96 (address of device}, 125 {Orient3D}, 1 {heading/pitch/roll}, 0 {dddd of heading 1st byte }, 10 {eeee of heading 1st byte}, 8 {dddd of heading 2nd byte}, 12 {eeee of heading 2nd byte}, 2 {dddd of pitch}, 0 {eeee of pitch}, 13 {dddd of roll}, 15 {eeee of roll}, 247 (F0h, 7Dh, 00h, 0Ah, 00h, 64h, 7Dh, 01h, 00h, 0Ah, 08h, 0Ch, 02h, 00h, 0Dh, 0Fh, F7h)

The heading value from the Orient3D is ( 0 * 16 (ie. 4-bit shift) + 10 ) * 256 (ie. 8-bit shift) + 8 * 16 (i.e. 4-bit shift) + 12 = 2700, corresponding to 270.0 degrees.

The pitch value from the Orient3D is 2 * 16 (i.e. 4-bit shift) + 0 = 32 unsigned, so that the two’s complement signed value is also 32, corresponding to 32 * 359 / 255 = 45 degrees.

The roll value from the Orient3D is 13 * 16 (i.e. 4-bit shift) + 15 = 223 unsigned, so that the two’s complement signed value is 223 – 256 = -32. Corresponding to -32 * 359 / 255 = -45 degrees.