04-03-2015 12:45 PM
Hi,
I have a basic serial read and write for a scale measurement. The read string gives me a whole set of data (Name, date, weight, etc.) but I only want to record the final few bytes which are the weight. The other data is extraneous and I am reporting to an excel sheet where only the weight is significant. How would I set up the VISA to only record the final number?
Any help is appreciated!
04-03-2015 12:54 PM
VISA is going to read the number of bytes you tell it to read, or until it sees a termination character, or times out.
If you can not tell your instrument to only send the data you want you will have to parse the data out of string it sends.
04-03-2015 12:56 PM
Thanks for the quick response!
How would I parse out the data? I'm farily new to Labview and programming in general...
04-03-2015 12:59 PM
Is the data seperated by a seperator like a comma or space and is the data you want always in the same position on the string?
If so it should be fairly easy to parse it out.
Please post a sample data string
04-03-2015 01:06 PM
I have attached a screenshot of the read string from the basic serial read and write vi.
In this example, I would just want to capture the -29.5 which I believe is bytes 120-128. Is this possible?
04-03-2015 01:07 PM
Sorry! Here is the screenshot
04-03-2015 01:13 PM
Um... yeah.
Right click on the string indicator and select '\' codes display so we can see any hidden characters then copy and paste the entire string into a post.
04-03-2015 01:20 PM
oops sorry!
02/20/05\s\s\s07:37:12\sPM\s\r\nBal\sID:\s\sB423683836\s\r\nUSER\sID:\s\s\s\s\s\s\s\s\s\s\s\s\r\nPROJ\sID:\s\s\s\s\s\s\s\s\s\s\s\s\r\nName___________________\s\r\n\s\s\s-35.3\sg\s\r
04-03-2015 01:32 PM
I would turn on the termination character for your VISA session and leave it as the default, which is a line feed. Then, as you recieve the data, you figure out what line it is putting out. You can specifically look for the number with spaces to start the line and that will key you into the line you care about. The Trim White Sapce and the Fract/Exp String To Number will help a lot here.
04-03-2015 01:38 PM
Are you sure there is not another \n at the very end of teh string?
Because it looks like \r\n is between each value so I would either set \r\n (end of line chr) as teh VISA term char and jusr read 6 times keeping only the last read
or
read it all at at once lke you are doing and parse the string by EOL char and get the data you need out of the string