Norm Posted May 16, 2009 Report Share Posted May 16, 2009 Hi all! Disclaimer: This is a hobby! I'm not an expert, nor do I pretend to be. Bearing that in mind, please use a judicious amount of rigor with explanations. All of what I've taught myself came from example code, tutorials or from forums. I've written code to gather data from the serial port and log it before. It was always a quick and dirty method based on reading a specified number of bytes from the serial buffer, parsing the resulting strings and logging the data. This time, I'd like to do it right. Somehow the code needs to select the correct parsing routine by header and verify the string using the checksum. My code will work like this: Write the setup string to the gps board to keep the overhead in the buffer down. Then read the buffer, select the proper routine, check, parse and log the data. I do understand that to calculate the checksum, I've got to go (input) string to byte array and loop with an XOR to get the number. Not sure how to implement that solution, though. Microwave Dave posted some code, unfortunately it's in LV 8.6 (I'm using LV 8.0), which I don't have. Pointers, guidance and ideas are much appreciated. BTW: This endgame for this code is logging visible satellites by time along with their c/no, az, el and satellite health. I'm thinking 32 individual .txt files would probably be the way to go. Each file can be imported into excel and sorted that way. Any ideas here? I'd like to log the data by day (0000-2400utc). Offer of dinner: If you are local to Binghamton, NY (within 100 miles) I'll spring for dinner in exchange for being able to pick your brain about LV and writing code.. Thanks for your time! Norm M. And Hey to the OTHER Norm! If you'd like to be Norm and can fix it with the admin, let me know.. Quote Link to comment
crelf Posted May 17, 2009 Report Share Posted May 17, 2009 QUOTE (Norm @ May 15 2009, 04:16 PM) Offer of dinner: If you are local to Binghamton, NY (within 100 miles) I'll spring for dinner in exchange for being able to pick your brain about LV... That's totally what LAVA needs more of - members offering to buy other members dinner! I would be more than happy to lend my mind to members for a free dinner and some stimulating conversation (not that there's anything wrong with that). Pity I'm outside the 100mile radius Quote Link to comment
LAVA 1.0 Content Posted May 17, 2009 Report Share Posted May 17, 2009 QUOTE (Norm @ May 15 2009, 10:16 PM) Hi all!This time, I'd like to do it right. Somehow the code needs to select the correct parsing routine by header and verify the string using the checksum. Does the data always start with the header? Is the header always the same size? If both answers are true your code is quite easy: Read the header and use that as the selector for a case structure, for every possible header you have a different case that reads the correct amount of bytes. QUOTE I do understand that to calculate the checksum, I've got to go (input) string to byte array and loop with an XOR to get the number. Not sure how to implement that solution, though. Microwave Dave posted some code, unfortunately it's in LV 8.6 (I'm using LV 8.0), which I don't have. I think there are several checksum VIs available, where is Microwave Dave's post? QUOTE BTW: This endgame for this code is logging visible satellites by time along with their c/no, az, el and satellite health. I'm thinking 32 individual .txt files would probably be the way to go. Each file can be imported into excel and sorted that way. Any ideas here? I'd like to log the data by day (0000-2400utc). I advise you to use TDMS or TDM data, this can be opened by excel with a plugin but makes sure that the data is correct, you will lose no significance data. QUOTE Offer of dinner: If you are local to Binghamton, NY (within 100 miles) I'll spring for dinner in exchange for being able to pick your brain about LV and writing code.. Maybe a donation to LAVA is a good idea to keep things running! Ton (or if you come to the Netherlands we could have dinner) Quote Link to comment
Norm Posted May 18, 2009 Author Report Share Posted May 18, 2009 QUOTE (Ton @ May 16 2009, 01:16 AM) Ton, Thanks for the response. >>Does the data always start with the header? Yes it does. >>Is the header always the same size? It is. This approach will work. >>If both answers are true your code is quite easy: Read the header and use that as the selector for a case structure, for every possible header you have a different case that reads the correct amount of bytes. The only rub here is that the messages are different sizes. Will need to read to the termination character. >>I think there are several checksum VIs available, where is Microwave Dave's post? http://decibel.ni.com/content/groups/rf-de...g-nmea-183-data Dave's post is a utility that does most of what I want to do. Would like to take a peek at it and see how he approached the problem. Unfortunately, it's written with LV 8.6 :-( . I've only got LV 8.0. Would you be so kind as to point me at the checksum vi's? I'd like to write my own but a look at someone else's approach is always good. >>I advise you to use TDMS or TDM data, this can be opened by excel with a plugin but makes sure that the data is correct, you will lose no significance data. Need to do some research here. One of my rules is to use the most general tools possible. Your solution sounds like it fits. >>Maybe a donation to LAVA is a good idea to keep things running! Did this. These forums has been a gold mine of information. Ton (or if you come to the Netherlands we could have dinner) I'd love to! Too bad it's so far. Love to geek out with other geeks. Quote Link to comment
LAVA 1.0 Content Posted May 18, 2009 Report Share Posted May 18, 2009 Here is an 8.0 version (haven't tested it). The code looks messy but should be OK. Ton Quote Link to comment
TobyD Posted May 19, 2009 Report Share Posted May 19, 2009 QUOTE (Ton @ May 15 2009, 10:16 PM) I advise you to use TDMS or TDM data, this can be opened by excel with a plugin but makes sure that the data is correct, you will lose no significance data. I would also recommend TMDS files. They will be much faster and more compact than text files, and the excel plugin seems to work pretty well if you want to use excel. You can individually configure multiple channels to handle the various satellites and only have to manage a single file. Quote Link to comment
Norm Posted May 20, 2009 Author Report Share Posted May 20, 2009 Toby and Ton: Thanks for your guidance. Ton, the NMEA routine is pretty much what I'm looking for. Do want to play with it a bit so that I understand what's going on. Where did you find it? Toby: You are suggesting that I create separate channels (string outputs) for each satellite? Planned on doing that, but how do you get only one spreadsheet? Need to find out more about the TDMS data. Sounds like I'll have a nice evening with a cup of coffee, google and the LV help file! Will have time to play on Thursday. Norm Quote Link to comment
LAVA 1.0 Content Posted May 20, 2009 Report Share Posted May 20, 2009 QUOTE (Norm @ May 19 2009, 08:31 AM) Toby and Ton:Thanks for your guidance. Ton, the NMEA routine is pretty much what I'm looking for. Do want to play with it a bit so that I understand what's going on. Where did you find it? At the link you provided. Ton Quote Link to comment
TobyD Posted May 20, 2009 Report Share Posted May 20, 2009 QUOTE (Norm @ May 18 2009, 11:31 PM) Toby: You are suggesting that I create separate channels (string outputs) for each satellite? Planned on doing that, but how do you get only one spreadsheet? Need to find out more about the TDMS data. Sounds like I'll have a nice evening with a cup of coffee, google and the LV help file!Will have time to play on Thursday. Norm With a tdms file, you can configure the properties of each channel individually. All of the data and configuration information is stored in a single file and an index file is created automatically so that you can read/write to any part of the file quickly. You can specify a particular channel name and/or location and only read that data. There is a plugin for excel that will pull a tdms file into an excel spreadsheet. There are a couple screenshots below of one of my tdms files converted to excel 2007. As you can see, the plugin creates a file with two tabs. The first tab is the channel configuration data, and the second tab is the captured data. You can get more complicated with your data structure, but I didn't need to in this case. Once the data is in excel, you can easily create charts or crunch numbers if you need to. We were using plain text files and after switching to tdms, we have never looked back. There is a bit of a learning curve, but making the switch has greatly simplified our lives. Quote Link to comment
Daklu Posted May 20, 2009 Report Share Posted May 20, 2009 <offtopic> QUOTE (crelf @ May 15 2009, 07:58 PM) That's totally what LAVA needs more of - members offering to buy other members dinner! I would be more than happy to lend my mind to members for a free dinner and some stimulating conversation Ring me up next time you're in the Seattle area. I know VI Engineering did some manufacturing test equipment for a project I was working on 1-2 years ago and had 2-3 developers here for several months. </offtopic> Quote Link to comment
crelf Posted May 20, 2009 Report Share Posted May 20, 2009 QUOTE (Daklu @ May 19 2009, 03:06 PM) Ring me up next time you're in the Seattle area. I know VI Engineering did some manufacturing test equipment for a project I was working on 1-2 years ago and had 2-3 developers here for several months. I shall do - I'm pretty sure I know the project you're talking about (I designed one of the test systems ) Quote Link to comment
Norm Posted May 21, 2009 Author Report Share Posted May 21, 2009 Once the data is in excel, you can easily create charts or crunch numbers if you need to. We were using plain text files and after switching to tdms, we have never looked back. There is a bit of a learning curve, but making the switch has greatly simplified our lives. Toby, I can see why it's much easier. Need to play with the LV help file so that I can learn more about setup of TDMS. It sounds like this will make the data collection end of my life MUCH easier. It's most of what I do, really. I've been using .txt files formatted csv. Parse the input strings, rearrange, time stamp and write! A little work to post process in Excel if it's needed, of course.. Drop me a note if you're ever in Binghamton, NY!! Thanks, Norm Quote Link to comment
TobyD Posted May 21, 2009 Report Share Posted May 21, 2009 QUOTE (Norm @ May 20 2009, 12:01 AM) Drop me a note if you're ever in Binghamton, NY!! Thanks, Norm Will do :thumbup: Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.