LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with VISA read/write

Hi there,

I'm quite new in LabView and atm I have a problem I somehow can't solve.
I tried to copy that "Basic Serial Write and Read.vi" manually to get a better understanding.

In the MAX I can access the resource (COM1). Even the preprogrammed example works in most cases. Just my little VI sometimes works, but mostly refuses to do its job.
Usually all I get as read-out is the command string I sent some seconds before. Sometimes it's cut off in the middle ("*IDN?\n" -> "*ID") and in very few cases I get the complete answer I'm expecting. I've been working with "*IDN?\n".

I would be very glad if someone could check the VI I attached.

Thank you,      David
0 Kudos
Message 1 of 7
(3,381 Views)

Hi DAVE

if you change the read part in that way that you only read if there are signs, then you get no error.

See the attachment. hope it helps.

Mike

0 Kudos
Message 2 of 7
(3,378 Views)
Hi Mike,

thanks for your fast answer.
I'm not sure if that "CASE" you built is nessesary. If the string length is "0" the read-command will finish after reading out "0" chars. This schould be the same as skipping the command.

Unfortunately my problem isn't solved, yet. And the most irritating thing is still that the VI sometimes works and sometimes doesn't...
0 Kudos
Message 3 of 7
(3,371 Views)

The amount of time you have wait after sending a query is instrument (and query) dependent. There are a couple of things you can do.

(1) If the instrument appends a termination character at the end of it's data, then you can enable this with the VISA Configure Serial Port. The VISA Read will automatically terminate when the term character is received so you don't need to specify much, if any wait and can specify some arbitrary number for the bytes to read. If you are using an instrument that responds to the *IDN? query, it probably sends a term character and you should be using it.

(2) You can put the VISA Bytes at Serial Port inside a while loop. Exit the while loop when byte count is greater than 0. Then, in another while loop, use VISA Bytes at Serial Port with a VISA Read. Exit this loop when the byte count is 0. You would use a shift register to build the string returned.

p.s. Your note in the VI about the code 1073676294 returned is not correct. This is not an error. It is a warning and you will get this warning whenever you disable the termination character and do a VISA Read. Because you have disabled the term character detection, it is just an alert that there may be more data available.

0 Kudos
Message 4 of 7
(3,364 Views)
Thanks for your answer Smiley Happy
Seems I have a bit to work on.

I'll be back on monday...

nice weekend to all of you, David Smiley Very Happy
0 Kudos
Message 5 of 7
(3,352 Views)
Hi there,

new week, old problems 😞 Hoped these difficulties would mysteriously disappear today, but they didn't.

I tried to copy the working example as exactly as possible to get a working VI but unless I do a copy&paste my VI doesn't work. Maybe someone of you would be so kind to check where I made the mistake. I've been searching for it for more than one hour and still can't find a difference.

thank you,      David
0 Kudos
Message 6 of 7
(3,319 Views)
OMFG Finally I found the mistake ^_^

At the "string to write" field the option (Properties-> Appearance -> Display Style -> Backslash (\) Codes) has to be activated.

Unbelievable how much time a single radiobutton can cost...

So thanks for all your help, I'll be back with another problem certainly 😉

0 Kudos
Message 7 of 7
(3,310 Views)