LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger case structure multiple times before it's done executing?

Solved!
Go to solution

There are a few ways.

 

You can use timestamps, to test if the dT between the end of a sequence and a new one is >x.

 

That will be more complicated then it needs to be.

 

Try this.

 

The dequeue has a time out output. By default, it's -1, so it will wait forever on an element or until the queue is destroyed. If you wire 50 the timeout input, the dequeue will either return an enqueued element and TO=F, or the default and TO=T.

 

If TO is true, use a case to execute nothing (a ~50 ms wait would be good). Store this value in a shift register.

 

If TO is false, execute the sequence, but bass the boolean from the shift register. This boolean is true if there was a TO, and false if the elements where piled up.

 

Queue skip wait.png

You can use the timeout of the dequeue with a value other then 50 ms. A value of 1000 will skip the wait if there is a new element within 1 sec.. The wait in the true case can go then. It's just there so the CPU (core) isn't 100% occupied.

0 Kudos
Message 11 of 14
(125 Views)

Hello wiebe@carya,

Thank you so much for taking the time to make and explain that. I tried to do what you did and relate it to my Queue Test Program, but I didn't fully understand how your example operated. I tried it and now it is only doing normal triggers, and not doing anything for piled up triggers. I definitely set it up wrong, but I'm just not sure how to set it up correctly so that the 2 second wait for piled up triggers starts whenever the switch is flipped for it. Could you please look at my code and try to see what is wrong? I also am attaching the VI so you can open it and try for yourself.

bcorduts_0-1652979197803.pngbcorduts_1-1652979223824.pngbcorduts_2-1652979232004.png

 

I am also not using the dequeued element anywhere, which seems strange, but I noticed you didn't have it connected to anything in your example. Please help if you get the chance, I would greatly appreciate it. Thank you.

 

Bryan C

0 Kudos
Message 12 of 14
(110 Views)
Solution
Accepted by topic author bcorduts

@bcorduts wrote:

Hello wiebe@carya,

Thank you so much for taking the time to make and explain that. I tried to do what you did and relate it to my Queue Test Program, but I didn't fully understand how your example operated.


My example doesn't operate. It is purely to illustrate the time out part of the problem.

 


@bcorduts wrote:

I tried it and now it is only doing normal triggers, and not doing anything for piled up triggers. I definitely set it up wrong, but I'm just not sure how to set it up correctly so that the 2 second wait for piled up triggers starts whenever the switch is flipped for it. Could you please look at my code and try to see what is wrong? I also am attaching the VI so you can open it and try for yourself.


I'm still in LV20, but at least you also included some images...

 

However, the part that enqueues elements when the switch is flipped isn't shown. If you have a problem with the enqueueing when the switch flips, it's in the enqueue part.

 

You can try to debug that part. The part where elements are enqueued has little to do with the receiving part (the benefit of decoupling code). With probes and\or breakpoints (and\or retain wire values and\or highlight execution), you should be able to make sure that part is working.

 


@bcorduts wrote:

I am also not using the dequeued element anywhere, which seems strange, but I noticed you didn't have it connected to anything in your example. Please help if you get the chance, I would greatly appreciate it. Thank you.


I used strings in my partial example. Just because it's the queue's default type. In a real situation, you would very often use that string in the timeout==false case. A queue can be just a signal, and then the data in it isn't used.

 

Of course you can pass the element to the timeout==false case, and use it to execute either the true or false value.

 

The time out construction should be added to what you had. So in your old situation, you use the true\false to execute a sequence with a true\false parameter. 

 

Set the queue's timeout, and use the timeout boolean to either execute the sequence as before, or to skip it. If it's skipped, the shift register will 'remember' this, and this is also passed to the sequence VI (so it can skip the wait).

 

If the two booleans (your element and the timeout) are confusing you (it actually is confusing), you can consider passing a type definition enum. This also allows to extend to more 'events', not just true\false.

0 Kudos
Message 13 of 14
(98 Views)
Ok I understand the logic now. I developed something that isn't quite how I initally envisioned but it probably makes more sense. I've tried it on my conveyor and it works pretty well. Thanks a ton for your help, I really appreciate it!!
Message 14 of 14
(81 Views)