Example of using Xbus library to communicate with an MTi-1 series device using a full-duplex UART connection.

Dependencies:   mbed-rtos mbed Xbus

Fork of MTi-1_example by Alex Young

Important Information

This example is deprecated and no longer maintained. There are new embedded examples available in the MT SDK folder of the MT Software Suite. For more information please visit: https://xsenstechnologies.force.com/knowledgebase/s/article/Introduction-to-the-MT-SDK-programming-examples-for-MTi-devices


The example program demonstrates connecting to an MTi-1 series device, restoring communications settings to default if necessary, and configuring the MTi to send data. For an MTi-1 the device is configured to send inertial sensor data, while MTi-2 and MTi-3 devices are configured to output orientation data using the onboard XKF3i filter.

Communication with the MTi-1 series device is implemented using a either a full-duplex UART, I2C or SPI bus. A reset line is used to reset the MTi during initialization. Data is output to a host PC terminal using a second UART.

For more information on the MTi-1 series communication protocol please refer to the datasheet: https://www.xsens.com/download/pdf/documentation/mti-1/mti-1-series_datasheet.pdf

Supported Platforms

The program has been tested on the following mbed platforms:

Using the Example

  1. To use the example program connect one of the supported mbed boards to the host PC and download the application from the mbed online compiler to the target device.
  2. With the mbed board unpowered (USB disconnected) wire the mbed board to the MTi-1 development board. The following connections are required:
    • In all cases:
      • 5V (or 3V3) main supply to VDD (P300-1)
      • MCU IO voltage (IORef) to VDDIO (P300-2)
      • GND to GND (P300-3)
      • MT_NRESET to nRST (P300-5)
    • For I2C communication:
      • MT_SCL to I2C_SCL (P300-9)
      • MT_SDA to I2C_SDA (P300-11)
      • MT_DRDY to DRDY (P300-15)
      • MT_ADD0 to ADD0 (P300-17)
      • MT_ADD1 to ADD1 (P300-19)
      • MT_ADD2 to ADD2 (P300-21)
    • For SPI communication:
      • MT_DRDY to DRDY (P300-15)
      • MT_SCLK to SPI_SCK (P300-17)
      • MT_MISO to SPI_MISO (P300-19)
      • MT_MOSI to SPI_MOSI (P300-21)
      • MT_nCS to SPI_nCS (P300-23)
    • For UART communication:
      • MT_RX to UART_TX (P300-9)
      • MT_TX to UART_RX (P300-11)

For more information on the MTi-1 development board please refer to the MTi-1 series user manual: https://www.xsens.com/download/pdf/documentation/mti-1/mti-1-series_dk_user_manual.pdf


Check the defines at the top of main.cpp to determine which IO pins are used for the MT_xxx connections on each mbed platform.


The active peripheral (I2C, SPI or UART) is selected on the MTi-1 development board through the PSEL0 and PSEL1 switches. Look on the bottom of the development board for the correct settings.

  1. Connect to the target using a serial terminal. The application is configured for:
    • Baudrate = 921600
    • Stop bits = 1
    • No parity bits
    • No flow control
  2. Reset the mbed board.
  3. You should be presented with a simple user interface as shown below:
MTi-1 series embedded example firmware.
Device ready for operation.
Found device with ID: 03880011.
Device is an MTi-3: Attitude Heading Reference System.
Output configuration set to:
        Packet counter: 65535 Hz
        Sample time fine: 65535 Hz
        Quaternion: 100 Hz
        Status word: 65535 Hz

Press 'm' to start measuring and 'c' to return to config mode.


RevisionDateWhoCommit message
70:ff3afeaa31be 2018-05-03 xsens_mheskamp Added some function documentation default tip
69:cb7fbf7821b5 2016-12-05 tjerkhofmeijer Adding support for the F401RE Nucleo board
68:6d6dbeefd196 2016-12-05 tjerkhofmeijer Adding support for the F401RE Nucleo board;
67:5c6676f25ffd 2015-10-14 tjerkhofmeijer Updating MTi-1 example's dependency on the Xbus library to the correct revision
66:f12dec1c0c3d 2015-10-06 tjerkhofmeijer Added support for I2C/SPI on EA-LP4088 platform.
65:38c908d1b515 2015-10-05 tjerkhofmeijer Added support for I2C/SPI on FRDM-KL46Z platform.
64:8a0f00a064bb 2015-10-02 tjerkhofmeijer MTi 1-series example is updated with support for I2C and SPI interfaces
63:138c196f0b88 2015-06-26 Xsens Update documentation for header pins to connect to on final development board.
62:ee6603d9d768 2015-06-16 alexandery Extract Xbus code into a library.
61:b9d3e7e5ba0c 2015-06-12 Alex Young Change to Apache license
60:ab9dad3560d3 2015-06-12 Alex Young Add support for EA LPC4088 QuickStart Board
59:f9166c19451f 2015-06-12 Alex Young Add support for Freescale FRDM-KL46Z development board
58:db60ef0a0d16 2015-06-12 Alex Young Use RawSerial port for communication with MTi.
57:c3c85ebb7375 2015-06-11 Alex Young Use platform defines to setup GPIO/UARTs
56:041d3d9c300a 2015-05-26 tjerkhofmeijer -fixed: typos in names of mti-2 and mti-3
55:9a2d6f947f0d 2015-05-26 Alex Young Only need to use 1 stop bit for UARTS.
54:2e9bb1390c9c 2015-05-22 Alex Young Add some introduction text to main.cpp
53:3891f4259901 2015-05-22 Alex Young Make PC serial baudrate a define
52:e2197b38c029 2015-05-22 Alex Young Replace \n with \r\n
51:cce9990f102a 2015-05-22 Alex Young Clarify documentation for user responsibility to deallocate message data
50:f581d5428ea6 2015-05-22 Alex Young Change definition for Xbus bus ID for consistency with LLCP documentation
49:38ecfbff5391 2015-05-22 Alex Young Fix typos in documentation comments.
48:69d35430fe8b 2015-05-21 Alex Young Add documentation for xbusmessage
47:c4610a65dade 2015-05-21 Alex Young Minor documentation cleanups
46:f652d199d27e 2015-05-21 Alex Young Add documentation for xbusparser
45:67203918bec9 2015-05-21 Alex Young Documentation of xbuf definitions and utility functions
44:b3980e8ac074 2015-05-21 Alex Young Add doxygen comments for main.cpp
43:470c019246e4 2015-05-21 Alex Young Move printing of message data to main thread.
42:e70756d2d8bc 2015-05-21 Alex Young Add support for printing acc/gyr/mag data
41:504b6821a96f 2015-05-21 Alex Young Add wait in main loop.
40:b77a8c10c76d 2015-05-21 Alex Young Add utility module for processing device ids
39:9014c5236864 2015-05-21 Alex Young Remove 'd' and 'o' PC commands.
38:d8d410d1662c 2015-05-21 Alex Young Add some friendly usage messages on startup.
37:3e87bf647c68 2015-05-21 Alex Young Implement support for restoring communication with the MTi
36:21198d933917 2015-05-21 Alex Young Add file header for main.cpp
35:7e519b88c610 2015-05-21 Alex Young Reset MT on startup.
34:3d7a6519a256 2015-05-21 Alex Young Split out sending message from a full transaction.
33:542e4b568631 2015-05-21 Alex Young Add Xbus wakeup message ids
32:fafe0f42d82b 2015-05-21 Alex Young Extract function for setting output configuration.
31:ce1ea9ae861e 2015-05-21 Alex Young Use a simple object to handle xbus memory cleanup
30:27ff4335edec 2015-05-20 Alex Young Add some more message ids
29:d9310e7b58b5 2015-05-20 Alex Young Set output config based on device type.
28:ae74baf7e5ab 2015-05-20 Alex Young Make XbusMessage_format be smart about payload formatting.
27:eebe5fc884e3 2015-05-20 Alex Young Add functions for writing stdints to xbus message
26:665d3624f9ab 2015-05-20 Alex Young Move PC command handling to a thread.
25:01356fb59467 2015-05-20 Alex Young Use rtos memory pool for message reception
24:2cc49dc854e3 2015-05-20 Alex Young Extract data handling from other xbus messages.
23:8171449f0dc3 2015-05-20 Alex Young Factor out specific message parsing functions.
22:3eab999c5076 2015-05-19 Alex Young Add support for reading back output configuration.
21:6015b8be3a00 2015-05-19 Alex Young Add function to convert XsDataIdentifier to string
20:38560fa3d2eb 2015-05-19 Alex Young Add simple command to read device Id
19:46e88d37ecef 2015-05-19 Alex Young Add support for parsing individual xbus messages.
18:2073072bad51 2015-05-19 Alex Young Extract functions for reading from xbus buffers to utility module
17:680f28e00d17 2015-05-19 Alex Young Better handling of zero length messages
16:4bdcdac223d8 2015-05-19 Alex Young Move MtData2 parsing to xbus message module
15:558d279addd9 2015-05-19 Alex Young Make the MtData2_getItem function use XbusMessage struct
14:155f9a55ec51 2015-05-19 Alex Young Use XbusMessage struct in parser.
13:dc2aa4678ec7 2015-05-19 Alex Young Ignore local mbed-rtos files
12:3426c966768a 2015-05-19 alexandery Import mbed-rtos library;
11:8593ba137917 2015-05-13 Alex Young Simple support for going to config/measurement