LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving string array in Standard State Machine.

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

 

 

Download All
0 Kudos
Message 1 of 4
(2,461 Views)

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.

0 Kudos
Message 2 of 4
(2,453 Views)

Yet another hint Smiley Happy

In order to slow down your while loop (execution every 200ms) the metronome is only effective when placed inside the loop!

0 Kudos
Message 3 of 4
(2,444 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 4
(2,427 Views)