LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start button within a control and simulation loop

Hi,

 

I have a control and simulation loop where the output is the position of a vehicle. The output will be send to an external device via TCP communication. Currently i am using a flat sequence structure with four columns. The first two columns are to send the initialization message (via TCP and only once) and to set a 20s time delay before i send the output of the simulation loop respectively. Third column is the tcp send with the control and simulation loop. The last is the tcp message to inform the external device that i am stopping the connection.

 

The problem i have lies in the third column. I mentioned earlier that i need to send the vehicle position output (generated by the simulation loop) to the TCP. On top of that i need to send the simulation elapsed time to the external device too, this is very important as there is a need to sync the timing. Now, is there a way whereby i can insert a "start button" within the simulation loop? This is because when the program comes to the third column, both the TCP send and simulation loop will start together. I need the simulation loop to wait because i need to verify if the TCP connection is stable or not first. Until i have verified that the connection is fine, then i will want to start sending the vehicle position output to the TCP send. I understand that i can put a delay to delay the starting of the simulation loop but i have a "simulation time" function in the simulation loop which i do not need a delay. i.e. when the third column is being called, i need this simulation time function to start and to send to the external device via TCP while the rest of the subsystems in the loop remains as zero, until a "start button" is activated.

 

Any help/suggestion is very much appreciated. Thank you.

0 Kudos
Message 1 of 3
(2,693 Views)

You should look into  a state machine. If you look in the examples in LabVIEW the state machine would be a much better solution than the flat sequence and it will give you more flexibility. If you have any questions once you look it over and try it come back and we will help more.

Tim
GHSP
0 Kudos
Message 2 of 3
(2,671 Views)

I agree with Tim,

 

You should consider a state machine.  As a matter of fact, you should look at the Producer/Consumer Design Pattern (Events), which is located in the VI Templates.  You would use the Event Structure to handle events that you want to use to change the state of your program.  A change of state could be pushing a button or something triggered by the software itself.

 

Flat sequences are not the way to go, and from my personal belief, should only be used if it is the only way to force dataflow, in the odd case where wires (ie Error Out) doesn't do the trick.

 

0 Kudos
Message 3 of 3
(2,664 Views)