LPMS Communication Protocol
LP-BUS Protocol
LP-BUS is a communication protocol based on the industry standard MODBUS protocol. It is the default communication format used by LPMS devices.
An LP-BUS communication packet has two basic command types, GET and SET, that are sent from a host (PC, mobile data logging unit etc.) to a client (LPMS device). Later in this manual we will show a description of all supported commands to the sensor, their type and transported data.
GET Commands
Data from the client is read using GET requests. A GET request usually contains no data. The answer from the client to a GET request contains the requested data.
SET Commands
Data registers of the client are written using SET requests. A SET command from the host contains the data to be set. The answer from the client is either ACK (acknowledged) for a successful write, or NACK (not acknowledged) for a failure to set the register occurred.
Packet Format
Each packet sent during the communication is based on the following structure:
Byte # | Name | Description |
0 | Packet start (3Ah) | Data packet start |
1 | OpenMATID byte 1 | Contains the low byte of the OpenMAT ID of the sensor to be communicated with. The default value of this ID is 1. The host sends out a GET / SET request to a specific LPMS sensor by using this ID, and the client answers to request also with the same ID. This ID can be adjusted by sending a SET command to the sensor firmware. |
2 | OpenMAT ID byte 2 | High byte of the OpenMAT ID of the sensor. |
3 | Command # byte 1 | Contains the low byte of the command to be performed by the data transmission. |
4 | Command # byte 2 | High byte of the command number. |
5 | Packet data length byte 1 | Contains the low byte of the packet data length to be transmitted in the packet data field. |
6 | Packet data length byte 2 | High byte of the data length to be transmitted. |
x
| Packet data(n bytes)
| If data length n not equal to zero, x = 6+1, 6+2…6+n. Otherwise x = none. This data field contains the packet data to be transferred with the transmission if the data length not equals to zero, otherwise the data field is empty. |
7+n | LRC byte 1 | The low byte of LRC checksum. To ensure the integrity of the transmitted data the LRC checksum is used. It is calculated in the following way: LRC = sum(OpenMAT ID, Command, Package data length, and packet data byte no. 1 to no. x) The calculated LRC is usually compared with the LRC transmitted from the remote device. If the two LRCs are not equal, and error is reported. |
8+n | LRC byte 2 | High byte of LRC check-sum. |
9+n | Termination byte 1 | 0Dh |
10+n | Termination byte 2 | 0Ah |
Data Format in a Packet Data Field
Generally, data is sent in little-endian format, low order byte first, high order byte last. Data in the data fields of a packet can be encoded in several ways, depending on the type of information to be transmitted. In the following we list the most common data types. Other command-specific data types are explained in the command reference.
Identifier | Description |
Int32 | 32-bit signed integer value |
Int16 | 16-bit signed integer value |
Float32 | 32-bit float value |
Vector3f | 3 element 32-bit float vector |
Vector3i16 | 3 element 16-bit signed integer vector |
Vector4f | 4 element 32-bit float vector |
Vector4i16 | 4 element 16-bit signed integer vector |
Matrix3x3f | 3x3 element float value matrix |
Sensor Measurement Data in Streaming Mode
In streaming mode, LP-BUS transports measurement data in the following form, wrapped into the standard LP-BUS protocol. See the following chapter for examples of transmission packets. The order of the sensor data chunks depends on which sensor data is switched on
The following is the data types in 32-bit float transmission mode.
In 32-bit float transmission mode:
Chunk # | Data type | Sensor data |
1 | Float32 | Timestamp (ms) |
2 | Vector3f | Raw (uncalibrated) gyroscope data (deg/s) |
3 | Vector3f | Raw (uncalibrated) accelerometer data (g) |
4 | Vector3f | Raw (uncalibrated) magnetometer data (T) |
5 | Vector3f | Angular velocity (rad/s) |
6 | Vector4f | Orientation quaternion (normalized) |
7 | Vector3f | Euler angle data (rad) |
8 | Vector3f | Linear acceleration data (m/s2) |
9 | Float32 | Barometric pressure (mPa) |
10 | Float32 | Altitude (m) |
11 | Float32 | Temperature (°C) |
12 | Float32 | Heave motion (m) (optional) |
In 16-bit transmission mode values are transmitted to the host with a multiplication factor applied to increase precision:
Order # | Data type | Sensor data | Factor |
1 | uint32 | Timestamp (s) | 400 |
2 | Vector3i16 | Raw (uncalibrated) gyroscope data (rad/s) | 1000 |
3 | Vector3i16 | Raw (uncalibrated) accelerometer data (g) | 1000 |
4 | Vector3i16 | Raw (uncalibrated) magnetometer data (uT) | 100 |
5 | Vector3i16 | Angular velocity (rad/s) | 1000 |
6 | Vector4i16 | Orientation quaternion (normalized) | 10000 |
7 | Vector3i16 | Euler angle data (rad) | 10000 |
8 | Vector3i16 | Linear acceleration data (g) | 1000 |
9 | Int16 | Barometric pressure (kPa) | 100 |
10 | Int16 | Altitude (m) | 10 |
11 | Int16 | Temperature (°C) | 100 |
12 | Int16 | Heave motion (m) (optional) | 1000 |
NOTE: Raw accelerometer data is transmitted with misalignment correction and scaling to g units applied. Raw gyroscope data is transmitted with misalignment correction, bias correction and scaling to rad/s applied. Raw magnetometer data is transmitted with misalignment correction and scaling to uT applied, hard and soft iron calibration is not applied to raw magnetometer data transmitted directly from sensor.
Example Communication
In this section we will show a few practical examples of communication using the LP-BUS protocol. For further practical implementation ideas check the open source code of LpmsControl and LpSensor.
RequestSensor Configuration
GET request (HOST -> SENSOR)
Packet byte no. | Content | Meaning |
0 | 3Ah | Packet start |
1 | 01h | OpenMAT ID LSB (ID = 1) |
2 | 00h | OpenMAT ID MSB |
3 | 04h | Command no. LSB (4d = GET_CONFIG) |
4 | 00h | Command no. MSB |
5 | 00h | Data length LSB (GET command = no data) |
6 | 00h | Data length MSB |
7 | 05h | Check sum LSB |
8 | 00h | Check sum MSB |
9 | 0Dh | Packet end 1 |
10 | 0Ah | Packet end 2 |
Reply data (SENSOR -> HOST)
Packet byte no. | Content | Meaning |
0 | 3Ah | Packet start |
1 | 01h | OpenMAT LSB (ID = 1) |
2 | 00h | OpenMAT MSB |
3 | 04h | Command no. LSB (4d = GET_CONFIG) |
4 | 00h | Command no. MSB |
5 | 04h | Data length LSB (32-bit integer = 4 bytes) |
6 | 00h | Data length MSB |
7 | xxh | Configuration data byte 1 (LSB) |
8 | xxh | Configuration data byte 2 |
9 | xxh | Configuration data byte 3 |
10 | xxh | Configuration data byte 4 (MSB) |
11 | xxh | Check sum LSB |
12 | xxh | Check sum MSB |
13 | 0Dh | Packet end 1 |
14 | 0Ah | Packet end 2 |
xx = Value depends on the current sensor configuration.
Request Gyroscope Range
GET request (HOST -> SENSOR)
Packet byte no. | Content | Meaning |
0 | 3Ah | Packet start |
1 | 01h | OpenMAT ID LSB (ID = 1) |
2 | 00h | OpenMAT ID MSB |
3 | 1Ah | Command no. LSB (26d = GET_GYR_RANGE) |
4 | 00h | Command no. MSB |
5 | 00h | Data length LSB (GET command = no data) |
6 | 00h | Data length MSB |
7 | 1Bh | Check sum LSB |
8 | 00h | Check sum MSB |
9 | 0Dh | Packet end 1 |
10 | 0Ah | Packet end 2 |
Reply data (SENSOR -> HOST)
Packet byte no. | Content | Meaning |
0 | 3Ah |