LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

adding to the basic serial write and read VI- easiest way to parse data?

Forgive me if this was already answered elsewhere- I've searched and not found what I was looking for.  Here's my problem:  I have a pump with a serial interface.  I send it a code, and it returns data to me.  I can use the basic serial write and read VI to accomplish this quite nicely- see the attached JPG.  Now what I want to do is parse this into units that I can graph and save to disk.  Example:  I want to have a variable in my code named "pump" that either is true or false.  I want another variable called "MotorPower" that is a number.  And another called "MotorCurrent".  Maybe variable isn't the right word-  I've worked with LV for some time, but never have grasped all the terminology.  But you see where I'm going with this- I want to seperate the data from the serial port into discrete units so I can play with them. 
I've seen and downloaded several examples of how to do this on this forum, but have never been able to make any of them work right, so I'm guessing that I need something different than has been answered here. 
Or, alternately, I'm legally retarded, which is in fact the dominant theory among my coworkers...Smiley Sad
If anyone can help with this, or even direct me to a previous post that has this information, I'd be most grateful. 
Thanks.
serial data
0 Kudos
Message 1 of 6
(2,995 Views)
Hello Geek,
I have a suggestion to your problem: create an array with the keywords the pump is able to send, then search the string for every keyword and extract everything after the keyword to the next linefeed. Then you can play with the values and convert them into the datatype you need. See the attached image and VI.



Greets, Dave

Message Edited by daveTW on 02-20-2007 01:23 PM

Greets, Dave
Download All
0 Kudos
Message 2 of 6
(2,983 Views)
OK, that makes sense to me.  Thanks for the graphic- when I downloaded the .vi file, there is nothing there.  As in 0 kb nothing.  So I'm attempting to build the code from scratch.  Couldn't do that without the picture! 
Thanks for the response!  I'll try it and see what develops.  It may take me a day or so- I have to do this project as time allows between repairing production tools when they fail catastrophically, so I never know if I will have any free time at all.
0 Kudos
Message 3 of 6
(2,963 Views)
Maybe if I had a diagram of the case structure when it is not at default?...
0 Kudos
Message 4 of 6
(2,960 Views)
I'm sorry, something was wrong with the VI uploading. Anyway, here it is again.
As a sidenote, the values all begin with a space character, so you have to handle this with split string or string subset.
Greets, Dave
Greets, Dave
0 Kudos
Message 5 of 6
(2,955 Views)
Well, thanks to your help, I'm getting closer...  The code you sent was version 8.2, I have version 8.0, so I couldn't open it.  But I was able to recreate it pretty closely from the picture, and ended up sending the output to a "decimate to 1D array", which worked OK, I guess.  And I wrapped the whole thing in a 5 second timed loop.  But I'm struggling at this point to get the data into a graph and to save it to the disk (I know how to do both of these things, but the data isn't wanting to pass through the case structure very well.  ONE piece of data will work, but not 2.  I wanted to get a screenshot before I finished up today, but something broke and I had to leave quickly and didn't get back to it.  Oh well.  Maybe next week I'll have more time to finish this- I'm so close!  Any other thoughts or ideas, please send them on.
0 Kudos
Message 6 of 6
(2,942 Views)