LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

difficulties with VISA write

I have attached my program. Could you look at my writes and see if I missed anything? The problem is that when I execute my program with certain written commands to the serial port- the device (Polhemus Fastrak) doesn't always read them. Thanks for helping!
0 Kudos
Message 1 of 8
(3,115 Views)
For a quick test, how about putting another Wait + (ms).vi function between the VISA read and VISA write inside your while loop? I would use a 1000ms delay and also delete the other wait function inside your while loop.

Robert
Message 2 of 8
(3,115 Views)
I would suggest running a utility like NI-SPY or PortMon so that you can get a better idea of what is going on from a lower level.

I hope this helps out.

JoshuaP
0 Kudos
Message 3 of 8
(3,115 Views)
do you mean something like Hyperterminal? If i have problems with that, so I contact the manufactureres?
Thanks
0 Kudos
Message 4 of 8
(3,115 Views)
Hello,

Hyperterminal is certainly a good way to test out general communication to your device and make sure that it is operating properly. Josh was referring to NI-Spy, however, which is a low-level utility to observe what is going on with all of the calls that LabVIEW is making to the serial port through VISA, a layer of software designed to interface with the serial port. If you are familiar with VISA, NI-Spy would be helpful in determining what is going on in your program and confirm whether or not the commands you think you are sending are actually getting written out to VISA by LabVIEW. You can access it from the start menu under National Instruments Software.

If the instrument behaves incorrectly from Hyperterminal, however, you nee
d to clarify its operation with the manufacturer before proceeding.

Additionally, one thing I noted in your LabVIEW VI that you posted was that you got the number of bytes at the port just before entering your loop, and then always read that same number of bytes each time the loop iterates. Note that this will ignore any changes in the number of bytes available at the port, and if x bytes are available at the start of your loop but y bytes are available later in iteration 2, then you will read x bytes. This may or may not be what you intend. To alleviate this problem, move your Bytes at Port property node inside the While loop.

Hope this helps.

Scott B.
Applications Engineer
National Instruments
0 Kudos
Message 5 of 8
(3,115 Views)
Hi thanks for the advice.
Unfortunately NI-Spy didn't help. From what I saw, the program wrote the command to the port/device. The command works in Hyperterminal, but not in LV and NI-SPY shows that it should work. Do you thinkn this could be something to do with the data collection rate?
Thanks,
Ivanka
0 Kudos
Message 6 of 8
(3,115 Views)
When you are using hyperterminal do you have to press enter. If so, then you are sending a \n and (possibly a \r) character. If this is a case I would suggest adding a \n to your VISA writes. It sounds like your issue is related to character termination.

JoshuaP
0 Kudos
Message 7 of 8
(3,115 Views)
It is likely that your device requires or expects a termination character. That is, you should include a linefeed (0x0a ascii) at the end of your write string. You can use the string concatenation function in the string palette to do this programmatically, or manually hit the return key after typing in the text you would like to send in your write string. Also, if you can remove the VISA open function since you are using the VISA Configure Serial Port VI. Finally, your instrument also likely uses a termination character when sending data back to you. In this case, you can remove the property node which determines the number of bytes at port and simply specify a read of, say 100 bytes (which is presumably larger than the number you expect) and the read will autom
atically stop when it sees a termination character. In general, your read function will complete when it receives the number of bytes specified or a termination character (if termination is enabled) or after the timeout time has expired (which ever of these 3 conditions occurs first; you should get an error indicating a timeout if a timeout occurs).

Hopefully this helps!

Best Regards,

Jassem
Applications Engineer
National Instruments
Best,
JLS
Sixclear
0 Kudos
Message 8 of 8
(3,115 Views)