1. Introduction
This document describes the communication protocol designed in the framework of the Multipurpose InerTial CHamaleon (MITCH) project. This protocol can be used with the wireless (Bluetooth Low Energy, BLE) interface to retrieve parameters from the system or to apply changes to the system, as well as to control the data acquisition and device calibration.
To control the device using the wired interface (i.e., USB), each message must be wrapped with a unique header and trailer, as described in Section 2.2.
2. Communication protocol
2.1 Overview
The system designed in the framework of this project complies with a bidirectional communication protocol based on the Type-Length-Value (TLV) format. As summarized in Table 1, each packet contains one byte indicating the type (e.g., command), one byte indicating the number of bytes in the value (e.g., the length of the payload), and the value (e.g., the payload itself).
Type | Length | Value (payload) | ||
---|---|---|---|---|
8-bit unsigned int | 8-bit unsigned int | Byte-0 | .... | Byte-N |
TABLE 1: TLV FORMAT.
Each TLV packet shall be acknowledge by the receiver with an ACK response, either positive (success) or negative (error), carrying information about the outcome using the same TLV format. As summarized in Table 2, the ACK response contains the ACK_CODE which identifies that the message is actually an ACK, the length of the value, and the value. The length of the value is at least equal to 2, for it carries information about which message the ACK refers to and the error code. In case the command sent previously needs some information back, the bytes following the error code byte contain the actual information.
Type | Length | Value (payload) | ||
---|---|---|---|---|
ACKNOWLEDGE CODE | 8-bit unsigned int | COMMAND CODE | ERROR CODE | ... |
TABLE 2: STRUCTURE OF THE ACKNOWLEDGE MESSAGE.
Each command byte has a SET/GET bit, which can be used either to change the parameter / behavior related to the command or to retrieve it, respectively. The bit used for such purpose is the Most Significant bit (MSb), as summarized in Table 3.
Command type | |||
---|---|---|---|
b7 – R/W Read (R) = 1 Write (W) = 0 |
b6 | ... | b0 |
TABLE 3: COMMAND TYPE ARRANGEMENT.
The Mitch Generic ATTribute Profile (GATT) defines how data are transferred back and forth with respect to an external device (i.e., typically mobile or desktop applications), using Services and Characteristics. Standard services and characteristics of the BLE profile are highlighted in light grey. A custom service, named Mitch Custom Service, allows to control and access data. By means of the two characteristics provided by the latter service, Command and Data, it is possible to send and receive a command to the system and to retrieve data, respectively. All information is exchanged by means of a bidirectional protocol.
FIGURE 1: GATT PROFILE OF MITCH.
2.2 USB: Header and Trailer
All commands and messages described in this document are available through both wireless (i.e., Bluetooth Low Energy) and wired (i.e., serial / USB) interfaces. It is sufficient to wrap the default messages, provided in this document for BLE interface, with a custom header (“?!”) and trailer (“!?”) ASCII patterns to be used with wired interface.
Header | Message Body | Trailer | |||
---|---|---|---|---|---|
Index | 0 | 1 | Byte array variable length | N-1 | N |
ASCII | '?' | '!' | Byte array representing the command to be sent to the device or the message received from the device itself. | '!' | '?' |
HEX | 0x3f | 0x21 | 0x21 | 0x3f |
3. Device Information Service
The Mitch Custom Service exposes the commands and functionalities necessary to control the device and access data. It is declared as a Primary Service. It is not dependent upon any other services. The service UUID is c8c0a708-e361-4b5e-a365-98fa6b0a836f. The Mitch Custom Service exposes 2 characteristics: Command and Data.
3.1 Command Characteristic
UUID: | d5913036-2d8a-41ee-85b9-4e361aa5c8a7 |
Byte: | 20 |
Property: | READ, WRITE, NOTIFY |
Description: | It allows to control the device behaviors. |
3.2 Data Characteristic
UUID: | 09bf2c52-d1d9-c0b7-4145-475964544307 |
Byte: | 20 |
Property: | READ, NOTIFY, WRITE_NO_RESPONSE |
Description: | It allows to manage streaming of data from device. |
4. Commands
Table 4 provides a list of commands supported by the Muse v3 device.
Name | R/W | Code (hex) | Code (dec) | Description |
---|---|---|---|---|
CMD_ACK | W | 0x00 | 0 | Acknowledge |
CMD_STATE | W | 0x02 | 2 | Set system state |
R | 0x82 | 130 | Get system state | |
CMD_RESTART | W | 0x03 | 3 | Restart device |
CMD_APP_CRC | R | 0x84 | 132 | Get application firmware information (i.e., CRC) |
CMD_BATTERY_CHARGE | R | 0x87 | 135 | Get battery charge level |
CMD_BATTERY_VOLTAGE | R | 0x88 | 136 | Get battery voltage |
CMD_CHECK_UP | R | 0x89 | 137 | Read value of check-up register |
CMD_FW_VERSION | R | 0x8A | 138 | Get application firmware versions |
CMD_TIME | R | 0x8B | 139 | Getdate / time |
CMD_BLE_NAME | W | 0x0C | 12 | Set BLE device name |
R | 0x8C | 140 | Get BLE device name | |
CMD_HW_VERSION | R | 0x8D | 141 | Get harddware version |
CMD_DEVICE_ID | R | 0x8E | 142 | Get device unique identifier |
CMD_MEM_CONTROL | W | 0x20 | 32 | Erase memory |
R | 0xA0 | 160 | Get memory status | |
CMD_MEM_FILE_INFO | R | 0xA1 | 161 | Get file information |
CMD_MEM_FILE_DOWNLOAD | W | 0x22 | 34 | Manage file download |
CMD_CLK_OFFSET | W | 0x31 | 49 | Set a new clock offset |
R | 0xB1 | 177 | Retrieve current clock offset | |
CMD_TIME_SYNC | W | 0x32 | 50 | Enter time sync procedure |
R | 0xB2 | 178 | Update time sync variables | |
CMD_EXIT_TIME_SYNC | W | 0x33 | 51 | Exit time sync procedure |
CMD_SENSORS_FS | W | 0x40 | 64 | Set device full scales (i.e., gyroscope and accelerometer) |
R | 0xC0 | 192 | Get device full scales (i.e., gyroscope and accelerometer) | |
CMD_AXL_FS | W | 0x41 | 65 | Set accelerometer full scale |
CMD_GYR_FS | W | 0x42 | 66 | Set gyroscope full scale |
CMD_DS1_FS | W | 0x44 | 68 | Set distance sensor #1 full scale |
W | 0xC4 | 196 | Get distance sensor #1 full scale | |
CMD_DS2_FS | W | 0x45 | 69 | Set distance sensor #2 full scale |
W | 0xC5 | 197 | Get distance sensor #2 full scale | |
CMD_OFFSET_DS1 | W | 0x46 | 70 | Set distance sensor #1 offset |
W | 0xC6 | 198 | Get distance sensor #1 offset | |
CMD_OFFSET_DS2 | W | 0x47 | 71 | Set distance sensor #2 offset |
W | 0xC7 | 199 | Get distance sensor #2 offset | |
CMD_MATRIX_CALIBRATION | W | 0x48 | 72 | Set calibration matrix |
R | 0xC8 | 200 | Get calibration matrix | |
CMD_BTN_LOG | W | 0x50 | 80 | Set button log configuration |
R | 0xD0 | 208 | Get button log configuration |
TABLE 4: COMMAND SUPPORTED BY MITCH DEVICE.
4.1 General
4.1.1 Restart Device
The restart command can be executed in write mode only. The HEX code is: 0x03. To perform a restart operation, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 03 | 01 | RESTART MODE | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 03 | ERROR CODE | 0 … 0 |
RESTART MODE
It must be one of the following:
- 0x00 APPLICATION Restart device in application mode
- 0x01 BOOT Restart device in boot loader mode
4.1.2 Application Firmware Information
The application information command can be executed in read mode only. The HEX code is: 0x84. To access the application information, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 84 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 06 | 84 | ERROR CODE | APP CRC | 0 … 0 |
-
APP CRC
It represents the Circular Redundancy Check (CRC) as 32-bit unsigned integer.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
APP CRC | ||||||||||||||||||||
Value | 00 | 06 | 84 | 00 | 73 | E4 | FC | FC | 0 … 0 |
- APP CRC: “73 E4 FC FC” which corresponds to 4244431987.
4.1.3 Device Check-up
The device check-up command can be executed in read mode only. The HEX code is: 0x89. To get the current check-up register value, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 89 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 06 | 89 | ERROR CODE | CHECK-UP REGISTER | 0 … 0 |
-
CHECK-UP REGISTER
It represents the health status of the device in relation to its peripheral configuration. The 32-bit unsigned integer must be decoded performing a bitwise operation using the following mask:
Byte Order | 0 (index 4 in RESPONSE) | 1 (index 5 in RESPONSE) | 2 BYTES | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Bit Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 ... 31 |
Field | BLE | BATT | MEM | PRX1 | PRX2 | MAG | AXL | GAS | 0xFF | 0 |
TABLE 5: BIT-MASK FOR CHECK-UP REGISTER DECODING.
Each bit-field can be 0 (normal condition) or 1 (error condition).
The meaning of the fields is as follows:
- BLE, consistency of Bluetooth module firmware,
- BATT, battery charger,
- MEM, memory,
- PRX1, proximity sensor #1 (i.e., also called distance sensor in this document),
- PRX2, proximity sensor #2 (i.e., also called distance sensor in this document),
- MAG, magnetometer,
- AXL, accelerometer,
- GAS, gas gauge status.
4.1.4 Firmware Version
The firmware version command can be executed in read mode only. The HEX code is: 0x8A. To access the device firmware version, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 8A | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 07 | 8A | ERROR CODE | APPLICATION FW VERSION | 0 ... 0 |
-
APPLICATION FW VERSION
It is provided in HEX format and must be converted into the corresponding ASCII Text String. If no application firmware is installed, the APPLICATION FW VERSION field is “0.0.0”.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
APPLICATION FW VERSION | ||||||||||||||||||||
Value | 00 | 07 | 8A | 00 | 31 | 2E | 33 | 2E | 30 | 0 ... 0 |
- APPLICATION FW VERSION: “31 2E 33 2E 30” which corresponds to “1.3.0”.
4.1.5 Hardware Version
The hardware version command can be executed in read mode only. The HEX code is: 0x8D. To access the hardware version, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 8D | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 07 | 8D | ERROR CODE | HW VERSION | 0 ... 0 |
-
HW VERSION
It is provided in HEX format and must be converted into the corresponding ASCII Text String.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
HW VERSION | ||||||||||||||||||||
Value | 00 | 07 | 8D | 00 | 33 | 2E | 31 | 2E | 30 | 0 ... 0 |
- HW VERSION: “33 2E 31 2E 30” which corresponds to “3.1.0”.
4.1.6 Date/Time
The date/time command can be executed in read mode only. The HEX code is 0x8B (read).
To GET the current date/time, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 8B | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 06 | 8B | ERROR CODE | TIMESTAMP | 0 … 0 |
-
TIMESTAMP
It is the 32-bit unsigned integer value that represents the current date/time as retrieved from the device, in Unix epoch format.
Example:
Using this tool https://www.epochconverter.com the user can convert the time in a specific number, and vice versa.
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
TIMESTAMP | ||||||||||||||||||||
Value | 00 | 06 | 8B | 00 | 00 | FA | BF | 63 | 0 … 0 |
- TIMESTAMP: “00 FA BF 63” which corresponds to “1/12/2023 12:16:00”.
4.2 Device
A set of dedicated commands allow to access the Bluetooth Low Energy (BLE) device name, the unique identifier (ID) alphanumeric code and the hardware and software features exposed by the system itself.
4.2.1 Device Name
The BLE name command can be executed in both write and read mode. The HEX code is 0x0C (write), and 0x8C (read).
To SET a custom name, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 0C | PAYLOAD LENGTH | DEVICE NAME TO BE SET | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 0C | ERROR CODE | 0 … 0 |
-
PAYLOAD LENGTH
The overall payload length, as 8-bit unsigned integer. It corresponds to the length (i.e., number of characters, including the end-of-string character) of the device name to be set. -
DEVICE NAME TO BE SET
The HEX representation of the device name to be set, converted from the corresponding ASCII Text String. It must also include the end-of-string character “\0”.
To GET the current device name, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 8C | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | PAYLOAD LENGTH | 8C | ERROR CODE | DEVICE NAME |
-
PAYLOAD LENGTH
It is equal to the length of the current device name plus 2 (i.e., due to the command and error code fields, in the response buffer). -
DEVICE NAME
The HEX representation of the current device name. It must be converted into the corresponding ASCII Text String. It also includes the end-of-string character “\0”.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
DEVICE NAME | ||||||||||||||||||||
Value | 00 | 0E | 8C | 00 | 6D | 75 | 73 | 65 | 5F | 72 | 6F | 62 | 65 | 72 | 74 | 6F | 0 ... 0 |
- DEVICE NAME: “6D 75 73 65 5F 72 6F 62 65 72 74 6F” which corresponds to “muse_roberto”.
4.2.2 Device ID
The Device ID command can be executed in read mode only. The HEX code is 0x8E. The perform a get device ID operation, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 8E | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 06 | 8E | ERROR CODE | DEVICE ID | 0 … 0 |
-
DEVICE ID
It represents the unique identifier of the device, as a 32-bit unsigned integer that can be converted into the corresponding hex string representation.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
DEVICE ID | ||||||||||||||||||||
Value | 00 | 06 | 8E | 00 | 03 | 46 | B5 | 83 | 0 … 0 |
- DEVICE ID: “03 46 B5 83” which corresponds to “83B54603”. Bytes in reverse order to keep endianness w.r.t. the corresponding 32-bit unsigned integer numeric value.
4.2.3 Battery Charge and Voltage
The Battery Charge and Battery Voltage commands can be executed in read mode only. The HEX codes are: 0x87 (charge level), and 0x88 (voltage).
The access the current battery charge level, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 87 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 03 | 87 | ERROR CODE | BATTERY CHARGE | 0 … 0 |
-
BATTERY CHARGE
It represents the battery charge level in percentage format, as an 8-bit unsigned integer.
The access the current battery voltage level, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 88 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 04 | 88 | ERROR CODE | BATTERY VOLTAGE | 0 … 0 |
-
BATTERY VOLTAGE
It represents the battery voltage as a 16-bit unsigned integer value.
4.2.4 System State
The Mitch device behavior is controlled through a state machine (Figure 2) implemented at a firmware level. It depends on a set of pre-defined user scenarios or operating modes, as well as the functions supported by the device itself. The available states, that can be (directly and indirectly) controlled by the end-user are summarized in Table 6.
FIGURE 2: STATE MACHINE REPRESENTATION.
Name | Coding | Description |
---|---|---|
IDLE | 0x02 | System in IDLE state |
STANDBY | 0x03 | System in STANDY state |
LOG | 0x04 | System in LOG state |
READOUT | 0x05 | System in the READOUT state |
TX | 0xF8 | System in TX state |
ERROR | 0xFF | System in ERROR state |
TABLE 6: SYSTEM STATES.
The system state command can be executed in both write and read mode. The HEX code is 0x02 (write), and 0x82 (read).
To SET a new system state, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 02 | 01 | STATE TO BE SET | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 02 | ERROR CODE | 0 … 0 |
-
STATE TO BE SET
It must be filled with the HEX code of the state to be set.
To GET the current system state, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 82 | 02 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 03 | 82 | ERROR CODE | SYSTEM STATE | 0 … 0 |
-
SYSTEM STATE
It provides the HEX code corresponding to the current state of the system.
4.3 Settings
4.3.1 Full Scales
The full scales command can be executed in both write and read mode. The HEX code is 0x40 (write), and 0xC0 (read).
To SET a new full scales configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 40 | 02 | SENSORS FULL SCALE (axl, gyr) | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 40 | ERROR CODE | 0 … 0 |
-
SENSORS FULL SCALE
The first byte represents the accelerometer full scale code (byte index: 2), while the second is the gyroscope full scale code (byte index: 3). It must be encoded in HEX format as summarized in Table 7
Sensor | GYROSCOPE [dps] |
ACCELEROMETER [g] |
MAGNETOMETER [Gauss] |
||||||
---|---|---|---|---|---|---|---|---|---|
FS value | 245 | 500 | 1000 | 2000 | 2 | 4 | 8 | 16 | 50 |
Sensitivity¹ | 0.00875 | 0.0175 | 0.035 | 0.070 | 0.061 | 0.122 | 0.244 | 0.488 | 1.5 |
HEX code | 0x00 | 0x04 | 0x08 | 0x0C | 0x00 | 0x08 | 0x0C | 0x04 | N.A. |
TABLE 7: FULL SCALE CONFIGURATIONS.
*1 The sensitivity coefficients have the following unit of measure, in order: dps/LSB (Gyroscope), mg/LSB (Accelerometer), mGauss/LSB (Magnetometer).
To GET the current full scales configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | C0 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 04 | C0 | ERROR CODE | SENSORS FULL SCALE (axl, gyr) | 0 … 0 |
-
SENSORS FULL SCALE
The first byte represents the accelerometer full-scale code (byte index: 4), while the second is the gyroscope full scale code (byte index: 5). It must be encoded in HEX format as summarized in Table 7.
Example:
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
SENSORS FULL SCALE | ||||||||||||||||||||
Value | 00 | 04 | C0 | 00 | 08 | 08 | 0 … 0 |
- SENSORS FULL SCALE: the first byte is the code corresponding to the accelerometer full-scale (i.e., 4 g), while the second byte refers to the gyroscope sensor (i.e., 1000 dps).
4.3.2 Distance Sensors Full Scale and Offset
The distance sensors full-scale command can be executed in both write and read mode. The HEX code is 0x44 (write), and 0xC4 (read) for sensor number 1, and 0x45 (write), 0xC5 (read) for sensor number 2.
To SET a new full-scale configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 44/45 | 01 | DS FULL SCALE | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 44/45 | ERROR CODE | 0 … 0 |
-
DS FULL SCALE
It represents the code to be set to select the desired full-scale for distance sensor. The available codes and correspondig full scales are shown in Table 8.
Sensor | DISTANCE SENSOR [mm] | ||
---|---|---|---|
FS value | 200 | 400 | 600 |
Sensitivity | 1 | 2 | 3 |
HEX code | 0x01 | 0x02 | 0x03 |
TABLE 8: FULL SCALE CONFIGURATIONS FOR DISTANCE SENSORS.
To GET current full-scale configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | C4/C5 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 03 | C0 | ERROR CODE | DS FULL SCALE | 0 … 0 |
-
DS FULL SCALE
It represents the code to be set to select the desired full-scale for distance sensor. The available codes and correspondig full scales are shown in Table 8.
4.3.3 Calibration
Calibration of IMU must be performed offline and then uploaded into the device as described in this section.
To SET a new calibration matrix, the following command must be composed.
TRANSMISSION (REQUIRES ONE ITERATION FOR EACH LINE OF THE MATRIX THAT MUST BE UPLOADED)
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 48 | 12 | TYPE | LINE | VALUE #1 | VALUE #2 | VALUE #3 | VALUE #4 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 40 | ERROR CODE | 0 … 0 |
-
TYPE
Describes the sensor to which the matrix is referred:- Accelerometer 0x00
- Gyroscope 0x01
- Magnetometer 0x02
-
LINE
Defines the line to which the current values are referred.
-
VALUE #1, VALUE #2, VALUE #3, VALUE #4
Values to be uploaded into the selected line.
To GET a specific calibration matrix, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 48 | 12 | TYPE | LINE | 0 ... 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 12 | C8 | ERROR CODE | VALUE #1 | VALUE #2 | VALUE #3 | VALUE #4 |
-
TYPE
Describes the sensor to which the matrix is referred:- Accelerometer 0x00
- Gyroscope 0x01
- Magnetometer 0x02
-
LINE
Defines the line to which the current values are referred.
LINE | X | Y | Z | OFFSET |
---|---|---|---|---|
1 | ... | ... | ... | ... |
2 | ... | ... | ... | ... |
3 | ... | ... | ... | ... |
TABLE 9: DEFAULT STRUCTURE OF A CALIBRATION MATRIX.
MAGNETOMETER
The magnetometer calibration entails performing as many different system rotations as possible during the procedure.
4.4 Data Acquisition
Data acquisition is controlled by using the set state command performed on Command Characteristic. Based on the selected acquisition channel (i.e., STREAM or LOG), the device starts to stream the data through notification on Data Characteristic or save the data on the flash memory, respectively. The general format of the command is as follows, independently from the sensor configuration, state, and selected acquisition mode or frequency.
To START data acquisition, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||
Value | 02 | 03 | STATE | MODE | ACQUISITION FREQUENCY | 0 … 0 |
RESPONSE (LOG ACQUISITION)
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 02 | ERROR CODE | 0 … 0 |
RESPONSE (STREAM ACQUISITION)
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 00 | 05 | 02 | ERROR CODE | SYS TX | GYR FS | AXL FS | 0 … 0 |
LOG Mode | Description | Code (hex) | Size [bytes] | Timestamp |
---|---|---|---|---|
6DOF | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) | 0x01 | 18 | WITHOUT TIMESTAMP |
6DOF / PRESSURE | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Pressure (FSR, Force Sensitive Resistor) | 0x02 | 42 | |
ALL | Gyroscope, Accelerometer, Magnetometer, Pressure | 0x03 | 44 | |
MAGN | Magnetometer | 0x07 | 6 | |
6DOF | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) | 0x04 | 26 | WITH TIMESTAMP |
6DOF / PRESSURE | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Pressure (FSR, Force Sensitive Resistor) | 0x05 | 50 | |
ALL | Gyroscope, Accelerometer, Magnetometer, Pressure | 0x06 | 52 | |
6DOF / QUAT | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Orientation (Quaternion) | 0x08 | 15 | |
QUAT | Orientation (Quaternion) | 0x09 | 3 | |
6DOF / TEMP | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Temperature | 0x10 | 28 |
TABLE 10: ACQUISITION MODES DEFINITION (LOG).
Frequency [Hz] | Code (hex) |
---|---|
25 | 0x01 |
50 | 0x02 |
100 | 0x04 |
200 | 0x08 |
500 | 0x20 |
1000 | 0x40 |
TABLE 11: ACQUISITION FREQUENCIES (LOG).
STREAM Mode | Description | Code (hex) | Size [bytes] |
---|---|---|---|
PRESSURE | FSR Pressure | 0x01 | 18 |
6DOF / TOF | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Time Of Flight (TOF) | 0x02 | 16 |
TOF | Time Of Flight (TOF) | 0x03 | 4 |
6DOF | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) | 0x04 | 14 |
9DOF | 9 Degrees Of Freedom (DOFs, Gyroscope + Accelerometer + Magnetometer) | 0x05 | 18 |
6DOF / QUAT | Inertial Measurement Unit (IMU, Gyroscope + Accelerometer) + Orientation (Quaternion) | 0x06 | 17 |
QUAT | Orientation (Quaternion) | 0x07 | 5 |
TEMP | Temperature | 0x08 | 2 |
TABLE 12: ACQUISITION MODES DEFINITION (STREAM).
Frequency [Hz] | Code (hex) |
---|---|
5 | 0x01 |
10 | 0x02 |
25 | 0x03 |
50 | 0x04 |
TABLE 13: ACQUISITION FREQUENCIES (STREAM).
To STOP data acquisition, the following command must be composed to put the system in IDLE (0x02) state.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 02 | 01 | 02 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 02 | ERROR CODE | 0 … 0 |
4.4.1 Button Log Configuration
The button log configuration command can be executed in both write and read mode. The HEX code is 0x50 (write), and 0xD0 (read).
To SET a new button log configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | ... | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | ||||||||||||||
Value | 50 | 02 | ACQUISITION MODE | ACQUISITION FREQUENCY | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 50 | ERROR CODE | 0 … 0 |
To GET the current button log configuration, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | |||||||||||||||||
Value | D0 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGHT | VALUE (Payload) | ||||||||||||||
Value | 00 | 04 | D0 | ERROR CODE | ACQUISITION MODE | ACQUISITION FREQUENCY | 0 … 0 |
-
ACQUISITION MODE
It is the 8-bit unsigned integer representing the acquisition mode currently set. -
ACQUISITION FREQUENCY
It is the 8-bit enumerative representing the desired acquisition frequency to be set (write) or currently set (read) for log operations.
4.5 Data Decoding
4.5.1 Pressure
The pressures measured by the Force Sensitive Resistor (FSR) insole must be decoded considering the resolution due to numeric representation as described in the following code snippet.
byte[] buffer = new byte[packetDimension + 8]; int k = 0; for (int j = 0; j < 16; j += 2) { //First pressure temp_pressure = buffer[i * packet_dimension + 26 + k]; temp_pressure = (UInt16)(temp_pressure << 4); temp_pressure |= (UInt16)(buffer[i * packet_dimension + 26 + k + 1] >> 4); tempData.Pressure[j] = temp_pressure; tempData.Pressure[j] *= 255; tempData.Pressure[j] /= 4096; //Second pressure temp_pressure = (UInt16)(buffer[i * packet_dimension + 26 + k + 1]); temp_pressure &= 0x0F; temp_pressure = (UInt16)(temp_pressure << 8); temp_pressure |= (UInt16)(buffer[i * packet_dimension + 26 + k + 2]); tempData.Pressure[j + 1] = temp_pressure; tempData.Pressure[j + 1] *= 255; tempData.Pressure[j + 1] /= 4096; k += 3; }
4.5.2 Gyroscope: 3D Angular Rate
The 3D angular rate is provided as a raw value read out from the sensor registers, represented as a two’s complement, Little Endian encoded, 16-bit signed integer value. The conversion from raw value to actual measurement must be performed on the master side considering the actual full-scale set and the corresponding sensitivity coefficient (see Table 7).
3D Gyroscope [LSB] | |||||
---|---|---|---|---|---|
x | y | z | |||
LSB | MSB | LSB | MSB | LSB | MSB |
The output measure is provided in Degrees Per Second, dps.
Each channel (i.e., x, y, z) must be converted from raw 2-bytes array to the corresponding 16-bit signed integer representation (i.e., Int16) and then scaled to the actual metric representation multiplying it by the appropriate sensitivity coefficient.
4.5.3 Accelerometer: 3D Linear Acceleration
The 3D acceleration is provided as a raw value read out from the sensor registers, represented as a two’s complement, Little Endian encoded, 16-bit signed integer value. The conversion from raw value to actual measurement must be performed on the master side considering the actual full-scale set and the corresponding sensitivity coefficient (see Table 7).
3D Accelerometer [LSB] | |||||
---|---|---|---|---|---|
x | y | z | |||
LSB | MSB | LSB | MSB | LSB | MSB |
The output measure is provided in millig, mg.
Each channel (i.e., x, y, z) must be converted from raw 2-bytes array to the corresponding 16-bit signed integer representation (i.e., Int16) and then scaled to the actual metric representation multiplying it by the appropriate sensitivity coefficient.
4.5.4 Magnetometer: 3D Magnetic Field Intensity
The 3D magnetic field intensity provided as a raw value read out from the sensor registers, represented as a two’s complement, Little Endian encoded, 16-bit signed integer value. The conversion from raw value to actual measurement must be performed on the master side considering the actual full-scale set and the corresponding sensitivity coefficient (see Table 7). Magnetometer full scale cannot be changed by the user.
3D Magnetometer [LSB] | |||||
---|---|---|---|---|---|
x | y | z | |||
LSB | MSB | LSB | MSB | LSB | MSB |
The output measure is provided in milli-Gauss, mGauss.
Each channel (i.e., x, y, z) must be converted from raw 2-bytes array to the corresponding 16-bit signed integer representation (i.e., Int16) and then scaled to the actual metric representation multiplying it by the appropriate sensitivity coefficient. It is worth noting that the sensitivity of the magnetometer is fixed to 1.5 mGauss/LSB.
4.5.5 Orientation Quaternion (MPE required)
The orientation is presented as a normalized quaternion, but only the three imaginary components are reported in the data, 2 bytes each. Each reported component is transmitted as a signed integer, mapped inside the range [-1,1], meaning that the LSB value is
From this, the user should read the 2 bytes corresponding to the quaternion component as a signed 16-bit integer, then divide it by 32767 to obtain the float equivalent (with the approximations intrinsic to the method). The user can then use the knowledge that the quaternion is normalized, and recalculate the real component as
Since this method drops the real part of the quaternion, given a quaternion q:
Imaginary components of quaternion q are transmitted as −𝑞1, −𝑞2 and −𝑞3, so that the reconstructed quaternion is
Orientation Quaternion (AHRS) | |||||
---|---|---|---|---|---|
i | j | k | |||
LSB | MSB | LSB | MSB | LSB | MSB |
Example of decoding implementation:
private static float[] DataTypeOrientation(byte[] currentPayload) { // Define 4-elements array of float (i.e., qw, qi, qj, qk channels) float[] currentData = new float[4]; // Define temporary internal variable used for data conversion byte[] tmp = new byte[2]; // Orientation Quaternion (i.e., UNIT QUATERNION) float[] tempFloat = new float[3]; for (int i = 0; i < 3; i++) { // Extract channel raw value (i.e., 2-bytes each) and convert to Int16 tempFloat[i] = BitConverter.ToInt16(currentPayload, 2*i); // Keep into account the data resolution tempFloat[i] /= 32767; // Assign imaginary parts of quaternion currentData[i + 1] = tempFloat[i]; } // Compute real component of quaternion given immaginary parts currentData[0] = (float)Math.Sqrt(1 - (currentData[1] * currentData[1] + currentData[2] * currentData[2] + currentData[3] * currentData[3])); // Return decoded Unit Quaternion return currentData; }
4.5.6 Temperature
The temperature is sampled at a fixed rate of 25 Hz. The user can reconstruct the values by converting the provided byte array into a 16-bit signed integer and using the following equations:
𝑇=𝐷𝑎𝑡𝑎_𝑎𝑟𝑟𝑎𝑦𝑇 ⋅ 0.004
Finally, the reference ambient temperature must be added to the estimated variation to obtain the current temperature value.
4.6 Memory
4.6.1 Control
The memory control command can be executed in both write and read mode. The HEX code is 0x20 (write), and 0xA0 (read).
To perform an ERASE MEMORY operation, the command must be executed in WRITE mode. The following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 20 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 20 | ERROR CODE | 0 … 0 |
To GET the current memory status in terms of available space (i.e., in percentage format) and number of files currently saved in memory, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | A0 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 05 | A0 | ERROR CODE | AVAILABLE SPACE | NUMBER OF FILES | 0 ... 0 |
-
AVAILABLE SPACE
Available space, provided in percentage format (i.e., 8-bit unsigned integer value). -
NUMBER OF FILES
It is the 16-bit unsigned integer representing the number of files saved in memory.
4.6.2 File Information
The file information command can be executed in read-only mode. The HEX code is 0xA1.
To GET the file info about a specific file identifier, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | A1 | 02 | FILE ID | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | ... | 7 | 8 | 9 | 10 | 11 | 12 | ... | 15 | 16 | ... | 19 | |||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 0E | A1 | ERROR CODE | TIMESTAMP | DATA ACQUISITION MODE | DATA ACQUISITION FREQUENCY | AXL FS | GYR FS | FILE DIMENSION | 0 … 0 |
-
FILE ID
The files are retrieved passing an index (i.e., between 0 and N-1, where N is the number of files currently stored in the system) as the command argument. If the requested file is present, the command will respond with the following information, in order:-
TIMESTAMP (bytes index 4 to 7)
Start timestamp of the file (i.e., 4 bytes).
It must be decoded by converting the raw values into a 64-bit unsigned integer, and adding the REFERENCE_EPOCH = 1554105600², multiplied by 1000 to keep into account the milliseconds resolution. -
SENSORS FULL SCALES (bytes 10 and 11, respectively)
The sensors full scale code (i.e., 1 byte each). The first is the accelerometer full scale, the second is the gyroscope full scale. -
DATA ACQUISITION MODE
The data mode (i.e., 1 bytes).
It must be decoded based on Table 10. -
DATA ACQUISITION FREQUENCY
The log frequency for the file (i.e., 1 byte, the hex code representing the selected frequency). -
FILE DIMENSION (bytes 12 to 15)
The dimension of the file in bytes.
-
TIMESTAMP (bytes index 4 to 7)
Otherwise, an acknowledge message with ERROR CODE = 0x01 is returned.
² It corresponds to Sunday 1 April 2019 08:00:00 GMT.
4.6.3 File Download
The file download command can be executed in write-only mode. The HEX code is 0x22.
To start the file download procedure given a specific file identifier, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 22 | 02 | FILE ID | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 06 | 22 | ERROR CODE | FILE SIZE | 0 … 0 |
-
FILE ID
The files are retrieved passing an index (i.e., between 0 and N-1, where N is the number of files currently stored in the system) as the command argument. -
FILE SIZE
It is a 32-bit unsigned integer value that represents the file size in bytes.
The user must send an ack message, at the end of each page, with the same ack format of every other command: the first byte of the payload is used to indicate the command that triggered the ack (0x22 in this case), and the second byte is used to signify an ACK (0x00) or NACK (any other number).
4.7 Time Synchronization
One or more Mitch can be synchronized with respect to a master device that controls the data acquisition. Such a procedure allows us to estimate the clock offset between each client (i.e., Mitch) and the master to synchronize the acquired data in time. The following commands allow us to manage the time synchronization (i.e., time sync) procedure.
4.7.1 Clock Offset
The clock offset command can be executed in both write and read mode. The HEX code is 0x31 (write), and 0xB1 (read).
To SET a new clock offset, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 31 | 08 | CLOCK OFFSET | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 31 | ERROR CODE | 0 … 0 |
-
CLOCK OFFSET
The 64-bit unsigned integer value representing the clock offset value to be set.
To GET the current clock offset, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | B1 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 0A | B1 | ERROR CODE | CLOCK OFFSET | 0 … 0 |
-
CLOCK OFFSET
The 64-bit unsigned integer value representing the clock offset currently set.
4.7.2 Time Sync
The time sync command can be executed in both write and read mode. The HEX code is 0x32 (write), and 0xB2 (read).
To ENABLE time sync procedure, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 32 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 32 | ERROR CODE | 0 … 0 |
To GET the current drift value necessary for clock offset computation, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | B2 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 0A | B2 | ERROR CODE | TIME DRIFT | 0 … 0 |
-
TIME DRIFT
The 64-bit unsigned integer value represents the clock drift, necessary for clock offset computation.
4.7.3 Exit Time Sync
The exit time sync command can be executed in write-only mode. The HEX code is 0x33 (write).
To DISABLE time sync mode, the following command must be composed.
TRANSMISSION
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 33 | 00 | 0 … 0 |
RESPONSE
Index | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Field | TYPE | LENGTH | VALUE (Payload) | |||||||||||||||||
Value | 00 | 02 | 33 | ERROR CODE | 0 … 0 |