Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

collecting reading from the port

I want to get 20 reading from the port and store each reading in an array of string. Is there anyway of doing that?
0 Kudos
Message 1 of 6
(3,426 Views)
Is this in LabVIEW? If so, the VISA read returns a string, so the work is already done!
0 Kudos
Message 2 of 6
(3,426 Views)
VISA read returns a string which consists of about 100 readings or more, but what I wanted is just 20 reading or one reading so that I can use those values to manipulate.
for example
(1) A=28 B=81 c=93
(2) A=27 B=83 c=93
(3) A=28 B=83 c=93
(4) A=28 B=84 c=93
(5) A=25 B=83 c=93
(6) A=28 B=87 c=93
(7) A=29 B=83 c=93
(8) A=28 B=83 c=93
(9) A=25 B=89 c=93
(10)A=28 B=83 c=93
(11)A=28 B=83 c=93
(12)A=28 B=89 c=93
(13)A=28 B=83 c=93
(14)A=28 B=83 c=93
(15)A=28 B=83 c=93

They are all in one string buffer reading out off the port. How would I go in getting the first reading (1) or the first five readings (from (1) to (5)?
0 Kudos
Message 3 of 6
(3,426 Views)
I'm assuming you're using VISA under LabVIEW. It sounds like you need to work with the string manipulation vi's. For example, you can use the match pattern vi to search for 'A=' then take the result and search for ' B='. The string remaining would be the number, which you could save in another array.

Check out the string vi's in the string function palette for other functions, including string to number conversion.
0 Kudos
Message 4 of 6
(3,426 Views)
Is there any way to get the reading from the port to take only 2 or three readings at a specific amount of time? If I'm going to search for e.g. A or B it's gonna be forever and the average of A or B will not be found.
0 Kudos
Message 5 of 6
(3,426 Views)
That depends on the nature of the instrument. If the instrument is always sending data and you just want to sample the last 3 points, you can issue a clear read buffer and then read the next 20 bytes or so and parse that for your data.
0 Kudos
Message 6 of 6
(3,426 Views)