Pages: [1]   Go Down
Author Topic: Serial Comm with XSens Motion Tracker  (Read 3044 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an XSens MTi-G motion tracker and an Arduino Uno. The message structure over serial is defined as follows:

PRE = 0xFA
BID = 0xFF
MID = varies
LEN = varies
DATA = LEN bytes
CS = checksum

The baud rate is 115200 on the device and it's programmed to send a data message (MID=0x32) at a 10 Hz update rate. Using the Serial monitor sample code, I never receive the 0xFA-0xFF byte sequence. Attached to a PC, the XSens sends this sequence, but reading the serial output with the Arduino only randomly (coincidentally) receives it. Previously, a PIC-based uC was used to read the serial output and it worked fine - is there any reason the Arduino is having trouble? Here's the code I'm using:

void setup() {
  Serial.begin(115200);
}

int incomingByte = 0;
void loop() {
   if (Serial.available() > 0) {
      incomingByte = Serial.read();
      Serial.print("S: ");
      Serial.println(incomingByte, HEX);
   }
}

If you're interested in the raw output it can be downloaded at http://cl.ly/3Q0z33353w0s0z1w0J0G for analysis.
Logged

Centurion RSA
Offline Offline
Full Member
***
Karma: 0
Posts: 166
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Two questions, what clock source are you using and have you tried to lower the baud rate to see if it makes a difference?
Logged

Rather people think you to be a fool than you open your mouth and confirm it.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I tried lowering the baud rate to 9600 in the XSens software but Windows crashed in the middle of the update, and upon restart Windows no longer sees the XSens as a serial device, but as a mouse. Plugging it in causes the mouse pointer to start flying all over the place and jumping around. I tried uninstalling and reinstalling the drivers, rebooting after every step, and now Windows can't install the drivers at all.

Anyhow, back on the Mac, I set the baud to 9600 in the Arduino monitor and in the Arduino sketch. I receive precisely the same output, just marginally slower… so it's not the baud rate.

I'm using the clock on board the Arduino, what would you suggest otherwise?

EDIT: Just to confirm, I've tried the other XSens supported bauds with no success...
« Last Edit: July 26, 2011, 06:23:22 pm by jfm429 » Logged

Centurion RSA
Offline Offline
Full Member
***
Karma: 0
Posts: 166
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The next thing I would do is to put a monitor on the comms line. I use the BusPirate from Sparkfun to sniff what is being sent and received. I use a terminal called Tera Term to see the raw data. This way you will at least know that the data comes from the Adruino in the form that you expect.
Logged

Rather people think you to be a fool than you open your mouth and confirm it.

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is an old topic but I need this again and the same issue has come up.

The baud rate everywhere is 57600. Using a raw serial monitor the bytes come back with the repeating 0xFA 0xFF sequence that I need. However, using the Arduino code listed below I get completely different results than the serial monitor (set to 8-N-1, the same as the Arduino) gives. Very frustrating. I've even tried inverting the bit order on the input and actually inverting the bits themselves (and both) to no avail.

WHY is the serial input on the Arduino different than the serial input on a serial monitor???

Also, I've used multiple Arduinos (two Unos and a Mega) with identical results, so it's not the board itself.



Code used, verbatim:

void setup() {
  Serial.begin(57600);
  Serial.flush();
}

void loop() {
   while (Serial.available() > 0) {
      incomingByte = Serial.read();
                if (incomingByte == 0xFA) {
                  Serial.println(""); // line break on that key byte
                }

      Serial.print(incomingByte, HEX);
                Serial.print(" ");
   }
}
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi jfm429, and hi everybody. I've the same sensor and exaclty the same problem described in this topic. Have you found a solution? Has anyone else the solution to fix this problem?

Thank you fo helping me.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have had these problems, too, but found the reasons of this behaviour: the xsens communicates over uart with the standard rs232 voltage level. this means the input from arduino to MTi-G has to be
1) 2.0V to 25.0V ('1')
2) -25.0V to 0.6V ('0')
the voltage between 0.6V and to 2V is not defined. and this is because the mti-g never received his GoToMeasurement or other messages from the arduino to start. the other direction is not as critical as this. i used a level shifter (Maxim Max232AEPE) between and it works.

another thing is the order of data. in the "mt low-level communication protocol documentation", page 27... the order of data (MTData frame) is described with 1. GPS PVT data (44byte) 2. Temp (4bytes float) 3. ...
but this is not correct. the order has to be 1. Temp 2. GPS PVT data ...

hope i could be of help,
susan
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 52
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot!

For precision I've the MTi ; not the MTi-G.

I've to say that i dont' need to decode the input message because I do it with Matlab/Simulink. It's not a problem for me.

Actually my problem is just that when I connect the sensor to the board i receive wrong  values compared to what I'm expecting. Could it be linked to the electrical connection?

The voltage I provide to the sensor is 5 V and also the TX pin in output has a level of 5 V. So, is it necessary a MAX232 even in this case? I've no voltage to bring down!

Have anyone the solution?


Thank you!!!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i have the same sensor and the same problem...  is there anybody success to get MTi Xsens Data????!!
Logged

Pages: [1]   Go Up
Jump to: