LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reinitailizing a variable after executing a command sequence

I am trying to set a condition where when a command is sent to a particular operation that it will only do it once and then stop until the command is sent again. The operation in LV resides in a while loop with many other simultaneous operations, so if the command is not changed or reset, it would contiune to execute while I dont want it to. The command is a string that is sent by an external device at irregular intervals.
If I were doing something like this in VB or C, the command sequence would look something like:
IF command = "xyz" then
{does the operations}
command = ""
END IF
0 Kudos
Message 1 of 6
(2,357 Views)
You could use a local variable to write to that control to re-initialize it after you write it to the external device.
0 Kudos
Message 2 of 6
(2,357 Views)
The event is being executed from a external device. But I am still unclear on exactly what I need to do to clear the variable in question, because in what I have tried so far, the input string seems to remain in the buffer, so it tries to re-execute the command
0 Kudos
Message 3 of 6
(2,357 Views)
If you only want to do the operation if the string changes, wire the string to a shift register and compare the current string to the contents of the shift register. The operation would be inside only one state of a case structure.
0 Kudos
Message 4 of 6
(2,357 Views)
Do you have an example of how you would do that? I cannot visualise how to wire it, I am still new at using labview.
0 Kudos
Message 5 of 6
(2,357 Views)
I have included 2 examples for you (in LV 6.0).

The first illustrates how to compare the current string with the past string using a shift register. This vi enables you keep the string showing the last setting, but if you want to repeat this same setting then it wouldn't work.

The second vi shows how to reset the string to an empty string, so if the string contains something then the operation will run. The last setting will be lost using this method, but repeats will work.

I hope this makes things a little clearer for you..

Kim
Download All
Message 6 of 6
(2,357 Views)