06-26-2016 01:30 PM
Hello!
I try to receive serial data from X-imu sensor, but i get messy print.
X-imu baud rate: 9600
myRio baud rete: 9600
Gps module gave me correct print with same settings
// mise
06-29-2016 03:26 AM
Hello mise,
Not too familiar with the X-imu device but I took a look at the user manual.
I believe as the baud rates match there should not be an issue.
But, are you attempting to acquire raw sensor data from it? This probably can't be done through the serial port.
This might causing the issue. From the user manual (http://www.x-io.co.uk/downloads/x-IMU-User-Manual-v5.2.pdf) on page 26 I saw that the data output rate maximum is 2^9 so 512 Hz. So by Nyquist theorem you should set the acquisition rate to 2 times as high on the analog input pin. To make sure you get a nice and clear signal you should set it to 10 times the output rate.
Since the X-imu has it's own API for C++ I think the serial traffic should be read by using this API.
You can download it from their website or try this ready made example through GitHub https://github.com/xioTechnologies/x-IMU-Arduino-Example/tree/master/x_IMU_Arduino_Example. Then you should build a .dll from these files. Then you could call the .dll it from LabVIEW that MyRIO is essentially using to read the serial data from your X-imu device. The X-imu GUI zip file also includes an X-imu API.dll file that you can try calling from LabVIEW.
Hope this helped!
Regards,
Jarmo Levo
Application engineer
National Instruments
06-29-2016 02:00 PM
Than you for reply
I've done a couple of days of research work. And I found that file.
code are a few points which I do not know how to do in labview
ErrorCode XimuReceiver::processNewChar(unsigned char c) { // Add new byte to buffer buf[bufIndex++] = c; // Process receive buffer if framing char received if(c & 0x80) { // Calculate packet size int packetSize = bufIndex - 1 - ((bufIndex - 1) >> 3); bufIndex = 0; //reset index // Extract packet (truncate to discard all msb) unsigned char packet[256]; packet[0] = (buf[0 ] << 1) | (buf[1 ] >> 6); packet[1] = (buf[1 ] << 2) | (buf[2 ] >> 5); packet[2] = (buf[2 ] << 3) | (buf[3 ] >> 4); packet[3] = (buf[3 ] << 4) | (buf[4 ] >> 3); packet[4] = (buf[4 ] << 5) | (buf[5 ] >> 2); packet[5] = (buf[5 ] << 6) | (buf[6 ] >> 1); packet[6] = (buf[6 ] << 7) | (buf[7 ] >> 0); packet[7] = (buf[8 ] << 1) | (buf[9 ] >> 6); packet[8] = (buf[9 ] << 2) | (buf[10] >> 5); packet[9] = (buf[10] << 3) | (buf[11] >> 4); packet[10] = (buf[11] << 4) | (buf[12] >> 3); packet[11] = (buf[12] << 5) | (buf[13] >> 2); packet[12] = (buf[13] << 6) | (buf[14] >> 1); packet[13] = (buf[14] << 7) | (buf[15] >> 0); packet[14] = (buf[16] << 1) | (buf[17] >> 6); packet[15] = (buf[17] << 2) | (buf[18] >> 5); packet[16] = (buf[18] << 3) | (buf[19] >> 4); packet[17] = (buf[19] << 4) | (buf[20] >> 3); packet[18] = (buf[20] << 5) | (buf[21] >> 2); packet[19] = (buf[21] << 6) | (buf[22] >> 1); packet[20] = (buf[22] << 7) | (buf[23] >> 0); packet[21] = (buf[24] << 1) | (buf[25] >> 6); packet[22] = (buf[25] << 2) | (buf[26] >> 5); packet[23] = (buf[26] << 3) | (buf[27] >> 4); packet[24] = (buf[27] << 4) | (buf[28] >> 3); packet[25] = (buf[28] << 5) | (buf[29] >> 2); packet[26] = (buf[29] << 6) | (buf[30] >> 1); packet[27] = (buf[30] << 7) | (buf[31] >> 0);
How do I convert from string to char? Because myrio serial port to give me a string. and how i do bitshifting that shows above.?
// Mise