LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using I/O Assistant with Serial

Tommy,

Here's another spy log as you requested. I clicked "Open a VISA Session", then went to the read tab, executed an async read, unchecked the 'Async' checkbox, executed a sync read, then closed the session.

Neville
0 Kudos
Message 11 of 16
(929 Views)
OK Neville - I think I know what the problem may be. With serial communication, VISA will read until the read buffer is full or a termination character is reached. Looking at your successful Spy log, I can see that the output data is in the format . You have three numbers that are delimited by spaces and then terminated by a carriage return (aka '/r' or 0x0D). Then the set of three values start over again. You need to set the termination character in Instrument I/O Assistant to be /r so that the Read will know to stop. Unfortunately, in the first version of the I/O Assistant, you can only set the term character in the Writ
e and Query Steps.

So, we can try a couple of things here. First, you could simply add a Write step in front of the Read step in I/O Assistant, and send a dummy command with '\r' as the termination character. Then the Read should work if the instrument ignores the Write command. If the instrument returns an error when you write to it intead of ignoring it, then this approach will probably not work.

If this doesn't work, let me know and I will write a small VI that has the parsing in it that you need. Since I know the format of the return value, it would be easy to write it and post it here.

Thanks for this - this bug in the I/O Assistant should be fixed in the next version.
0 Kudos
Message 12 of 16
(929 Views)
Tommy,

Thanks for all your help. Instead of adding a Write step, I added a "Query and Parse" step, which seemed to work. Unfortunately, it kept only getting part of the line of data because it would stop reading as soon as it saw the terminator, but it would start reading at random places in the line.

So I changed my setup to be in a polling mode (rather than streaming) and then used "Query and Parse", which seems to work well. I'm not sure if there is a way to capture multiple lines on a "Query and Parse" and then select items out of a full line (rather than getting parts of a line), but what I have is working for now.

Unfortunately, the resolution isn't g
reat, so I may have to go with my analog output from my device anyway. I really appreciate your help though! Thanks!

Neville
0 Kudos
Message 13 of 16
(927 Views)
Tommy,

Also, in the I/O Assistant, where you select the termination character, it says '\r' instead of '/r'. It has the incorrect slash for the '/n' and '/t' as well. I think that's probably just a GUI problem, as when I selected '\r', it worked properly on the true character, which is a '/r' I was told and which you mentioned in a previous post.

Neville
0 Kudos
Message 14 of 16
(927 Views)
Neville,

Traditionally, the backslash character ('\') is used to indicate that the character following the backslash is "escaped" and has special meaning. Though people sometimes read "\n" as "slash-n", it technically is "backslash-n".

Thus, if the characters you're seeing in the I/O Assistant are "\r" and "\n" then I would say that everything is as expected. If you see "/r" and "/n", however, those would be incorrect.

Glad you were able to get your code up and running, and I hope this helps.

Scott B.
Applications Engineer
National Instruments
0 Kudos
Message 15 of 16
(927 Views)
Sorry - I inadvertently typed '/r' when I meant '\r'. So everything worked for you? were you able to parse your data as you wanted in the Read and Parse step?

Once you are satisfied with the Express VI, you probably should convert the Express VI to a normal subVI so you can edit the code within it. This way you can copy the parsing code that is there and reuse it in your application, or remove the Write step that sends the dummy command and use the VI. If you have any other problems or need more help, please let us know.

-Tommy
0 Kudos
Message 16 of 16
(927 Views)