Firmware-72 Message-004

From I-CubeX Wiki
Jump to: navigation, search

SAMPLE DATA (4, 04h)

The SAMPLE DATA message contains a single snapshot of a sensor connected to a sensor input, whether the USB-microDig is in host or in stand-alone mode.

The [BODY] of the SAMPLE DATA message is composed of two or three bytes - the sensor input number, the first data byte, and, if the sensor input is set to 10-bit hi-res mode, the second data byte:

7-bit lo-res mode

00000xxx: xxx = [0..7]; sensor input number, where the first sensor input number = 0, and the last (8th) sensor input number = 7
0yyyyyyy: yyyyyyy = [0.127]; the most significant bits

10-bit hi-res mode

00000xxx: xxx = [0..7]; sensor input number, where the first sensor input number = 0, and the last (8th) sensor input number = 7
0yyyyyyy: yyyyyyy = [0.127]; the most significant bits
000zzz00: zzz = [0..7]; the 3 least significant bits

Example:

When sampling sensor input 8 (provided it is turned off) and the sensor input is set to lo-res mode, the following message is received:

240, 125, 0 {DEV}, 4 {SAMPLE DATA}, 7 {xxx}, 64 {yyyyyyy}, 247 (F0h, 7Dh, 00h, 04h, 07h, 40h, F7h)

The sampled value from sensor input 8 is 64.

When sampling sensor input 8 (provided it is turned off) and the sensor input is set to hi-res mode, the following message is received:

240, 125, 0 {DEV}, 4 {SAMPLE DATA}, 7 {xxx}, 10 {yyyyyyy}, 10 {zzz}, 247 (F0h, 7Dh, 00h, 04h, 07h, 0Ah, 0Ah, F7h)

The sampled value from sensor input 8 is 10 * 8 (i.e. 3 bit shift) + 10 = 90.