Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Getting Input from Serial Interface (http://www.chiefdelphi.com/forums/showthread.php?t=125321)

wre136 27-01-2014 10:34

Getting Input from Serial Interface
 
1 Attachment(s)
I am looking to get data from the serial interface on the cRIO. However, I am having some issues.

I can use the open serial VI and the read serial VI (WPI Robotics Library-> Communications -> Serial Port). However, I'm not sure how to read data. The Read VI allows me to select the number of bytes I want to read. I'm not sure how much to read. We are connecting the CH Robotics UM6 Position sensor (Attached is its datasheet) to the serial and the packet lengths can be anywhere from 7 to 71 bytes in size depending on what length is given in the Packet type header of the packet.

I can say "always grab 7" but since not all packets are that length, I may not grab all the data I need and that will mess up the read of another packet. In addition to that, most of the packets I grab are not structured right. I might grab a data where the packet starts half way through the data, meaning I have an incomplete packet now. I'm not sure how to grab the bytes from the serial and have the code figure it out as I go.

To make things simple, I need to know a good strategy on how to grab the correct amount of data from a serial port and read it to decide how much more data I need to get, and then continue to get that amount.

Would a state machine do the trick or is there a better way to do this? I am a complete novice at data communications.

wre136 27-01-2014 10:35

Re: Getting Input from Serial Interface
 
By the way, the UM6 Sensor puts out TTL serial and we are using a TTL to RS232 serial converter so we can actually connect it to the cRIO in case you do see that.

sanelss 27-01-2014 21:19

Re: Getting Input from Serial Interface
 
We are attempting to use the um6 as well but we chose to utilize SPI instead of serial since we are using the serial port for CAN bus. If you would like I can provide the code we are using to pull data from it if you decide to also use the SPI bus. There are a few things you need to be aware of while working with this sensor. First off use shielded cable, if you don't you will get glitches in the data or may not work at all. Second, while maybe not required, we added a little logic level converter board as well, since the device operates off 3v3 we wanted to match signals for best signal integrity. Third, the compass will require calibration(if you got the um6-lt anyway, if you got the one with enclosure they factory calibrate it for you). Keep in mind that any magnetic materials(bolts, shafts, etc) will cause reading errors unless they are calibrated out which is not an easy process)

We want to very badly use this sensor, i put the work in to make it easy to work with in labview and the robot but our issue is there is a heading error due to miss-calibrated magnetometer and so far all attempts to calibrate it have failed. We continue to get improved results with better calibration attempts but best we are able to do was a 5 error. As mentioned the calibration procedure is not a simple or easy process.

Let me know if you want any more info from me

sanelss 27-01-2014 21:24

Re: Getting Input from Serial Interface
 
there are a few ways to deal with serial data. You can read how many bytes were received(there is a vi to tell you this) but that doesn't necessarily mean you are grabbing a complete packet and that it's starting with a packet start.

Another way you can do it is to read a single byte at a time, store it in a buffer, and parse it for the structure of a packet then extract the data you are looking for.


All times are GMT -5. The time now is 09:56.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi