Go to Post ...if two good things are good by themselves let's do them both together to make a better thing. So who's up for an apple pie burrito? - Katy [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 27-01-2014, 10:34
wre136 wre136 is offline
Registered User
FRC #2461
 
Join Date: Jan 2012
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
Getting Input from Serial Interface

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.
Attached Files
File Type: pdf UM6_datasheet.pdf (1.39 MB, 7 views)
Reply With Quote
  #2   Spotlight this post!  
Unread 27-01-2014, 10:35
wre136 wre136 is offline
Registered User
FRC #2461
 
Join Date: Jan 2012
Location: Oklahoma City
Posts: 30
wre136 is an unknown quantity at this point
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.
Reply With Quote
  #3   Spotlight this post!  
Unread 27-01-2014, 21:19
sanelss sanelss is offline
Registered User
FRC #1658
 
Join Date: Dec 2012
Location: saint louis
Posts: 258
sanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to behold
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
Reply With Quote
  #4   Spotlight this post!  
Unread 27-01-2014, 21:24
sanelss sanelss is offline
Registered User
FRC #1658
 
Join Date: Dec 2012
Location: saint louis
Posts: 258
sanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to beholdsanelss is a splendid one to behold
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 08:20.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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