LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

visa read and report certain bytes

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!

0 Kudos
Message 1 of 11
(3,595 Views)

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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 11
(3,586 Views)

Thanks for the quick response!

 

How would I parse out the data? I'm farily new to Labview and programming in general...

0 Kudos
Message 3 of 11
(3,582 Views)

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 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 11
(3,572 Views)

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?

0 Kudos
Message 5 of 11
(3,561 Views)

Sorry! Here is the screenshot

0 Kudos
Message 6 of 11
(3,560 Views)

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.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 7 of 11
(3,546 Views)

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

0 Kudos
Message 8 of 11
(3,537 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 9 of 11
(3,510 Views)

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

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 10 of 11
(3,500 Views)