From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
04-17-2007 09:08 AM
04-17-2007 09:21 AM
You're assuming that the device will respond instantly with some response. If there is no data immediately there when you run the VISA Bytes at Serial Port, you just go on and then send the next command. What highlight execution does is slow things down by quite a bit so you are giving the device time to respond. What you could do is put a fixed delay after the VISA Write. More elegant and robust is to put the VISA Bytes at Serial Port in a loop. When the byte count is greater than zero, exit the loop. Then in another loop, keep reading until a VISA Bytes at Serial Port says that available bytes is 0.
You also need to set the termination character enable to false with the VISA Initialize Serial Port. And please, clean up that wiring where you convert to a string for the VISA Write. Wires should go from left to right.
04-17-2007 10:08 AM
04-17-2007 10:38 AM
The first thing to do is to determine which loop is running. Put a probe on the conditional terminal in each loop to see if either become true. In your second loop, you have a problem. The number of bytes to read should be coming from the VISA Bytes at Serial Port in that loop. Not the function in the first loop. You should also put a small wait (ms) or delay function in each loop.
At some point, if there is the possiblity that the instrument connection might fail, you would want to add some timeout check in each loop. For example, an elapsed time function could be used and the Boolean output OR'd with the other condition.
04-17-2007 11:40 AM
04-17-2007 12:04 PM - edited 04-17-2007 12:04 PM
Message Edited by Dennis Knutson on 04-17-2007 11:04 AM
04-17-2007 12:39 PM
Works by removing the second loop. Thanks so much for the help!
07-14-2011 02:34 PM
Dennis, thank you for your insight. This solved a big problem I was having when communicating with a serial device!
12-06-2011 10:50 AM
Thanks!!! It's help me a lot