LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I start, stop and restart a sequence with a periodic input?

Hi,
 
I have written some code that will monitor my com port (rs-232) continuously for an ASCII character (in this case a 'P'). When the P is received, I want a sequence structure to start working. The P will only appear once for a short while, but the sequence should carry on running until it finishes all the frames. On the next time a P appears on my monitor, I want to either stop the sequence structure regardless of which frame its in and restart the sequence from the beginning again or to run the sequence from the start again if it has already completed all the frames.
What sort of structure do I need to do this, are there any examples?
 
James
 
0 Kudos
Message 1 of 7
(3,995 Views)

Hi,

You need to have your "P detection code" separated from your sequence structure and running in paralel.

Use a diferente while loop for each other with no dependencies.

Look at attach example.

Paulo

0 Kudos
Message 2 of 7
(3,986 Views)

Hi,

Forgot to mention I have V. 6.1 Developer.

0 Kudos
Message 3 of 7
(3,982 Views)
Hi James2412,

you need the sequence structure, while loops and a lot of boolean querys. My think is that you have two separated threads, one for the serial communication and one for the sequence structure. You set for example a boolean lokal variable in thread one to true if "P" appears. Afterwards the while loop with the integrated sequence structure is starting (structure in case and case in while loop). In each sequence have to be a query if "P" appears again. If this is so, the sequence does not be executed with any code (think of an easy case structure in each sequence). Sadly there is no other chance to jump out from any sequence frame without ending the complete sequence.
You will find the named structures in the function palette in block diagram "structures".

Hope it helps

Indiana

0 Kudos
Message 4 of 7
(3,981 Views)
I have LabVIEW 7.1, so I can only convert it to 7.0.
But the main functionality is described.
Use different threads for the detection and the structure.
If you post your code here we can give you indications on how to go.
 
Paulo
0 Kudos
Message 5 of 7
(3,976 Views)

James,

 

Indiana is correct, my take on this is similiar.

If you have a 3 element sequence structure for example which runs if 'P' is returned from your COMs thread, you will need to query a variable in each element of the sequence in order to suspend execution of the next/remaining elements in the sequence if this event occurs. You can do this by reading the variable that your COMs thread sets using a case structure in each element of your sequence. In order to re-run your sequence if 'P' is returned during the execution you can simply set the suspend variable and ensure the code is in a while loop to recall the code.

See the attached example code/screen shot:

This is however not an elegant solution and the best way would probably be using the events structure and a user event to queue the P events. This is available in 6.1 but I believe its the professional package. See also my implementation using this method, again attached below:

Hope this helps,

 

Kind Regards

 

Steven Bird

Applications Engineer

National Instruments

0 Kudos
Message 6 of 7
(3,959 Views)
Heres the better way to approach the issue:
 
Kind Regards, Steven Bird
0 Kudos
Message 7 of 7
(3,957 Views)