10-03-2013 03:33 AM
I use a Standard State Machine to control a laser unit with multiple lasers. When I give the unit a command, it gives me much information back. When LabVIEW is reading this information, it is putting it in a string array.
But the program shows only the information in the array when I enable 'Highlight Execution'. What do I have to do to solve this problem?
Thanks for all commands,
Bjorn
10-03-2013 04:22 AM
Hi Bjorn
I think this is a race condition because the debug mode ("Highlight execution" enabled) slows down the code execution. So what I assume to happen is the following situation:
1. You send a command to the laser unit.
2. You want to read back the answer and check how many bytes have been queued in the input buffer.
3. Because you do this immediately (too early) no bytes are available yet (fast program execution without highlighting).
4. Bytes at port = 0 --> Your while loop terminates with an empty array which is plotted in the indicator.
A possible approach would be to insert a delay before querying the bytes or to poll the "Bytes at port" including an expedient timeout.
10-03-2013 05:25 AM
Yet another hint
In order to slow down your while loop (execution every 200ms) the metronome is only effective when placed inside the loop!
10-03-2013 06:46 AM
Does your device use a termination charcter at the end of each transmission? You are already set up to use 0xA as a termination character (default on the Configure Serial Port). If so, do not do the big mess with the checking of bytes at port and what not. Just use a VISA Read with a very large number for the bytes to read. The read will complete when that termination character is reached.