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

Hello,

Let me provide background to my project first. We have a conveyor belt we are controlling using LabVIEW programming. This specific part of the programming is to divert packages left and right. We are sending digital signals through a DAQ to the conveyor to do this, and it is working so far. For this diverting function, a photoeye sensor is read (bottom while loop in images), and once the sensor is covered by a package, it triggers the top while loop/case structure. This loop tells the conveyor to wait 2 seconds (to wait for the package to get the divert zone), then triggers the divert (by sending a digital signal to the conveyor), then waits 2 more seconds, then tells the diverting to stop. This system works and has been working fine for the most part.

 

(Note: These digital signal commands are through our DAQ company's SDK for LabVIEW, so don't pay much attention to it in the image below, it won't make much sense).

 

 

bcorduts_1-1652323723730.png

bcorduts_2-1652323749911.png

Here is the problem. This method does not account for if packages are too close to each other. In other words, while Package 1 is diverting, Package 2 could be crossing the sensor at the same time. But the program doesn't use Package 2's sensor signal to trigger the case structure process while it is being carried out for Package 1, so the diverting never triggers for Package 2. I want to make it so if Package 1 is diverting, Package 2 can still cross the sensor, and send the command to the top while loop so it can divert according also.

 

I have tried methods using Notifiers and Dynamic User Events, and either they didn't work or I wasn't using them correctly. Does anybody have any ideas on how I can accomplish this? Any input would be helpful. Thank you.

0 Kudos
Message 1 of 14
(1,667 Views)

Try bundling a timestamp with your "Pre-Divert Zone Sensor" trigger Boolean. Instead of waiting a fixed delay, wait the necessary time from the trigger time.

 

If the packages are very fast, you may have to turn that stream of triggers into a queue.

 

You might also want to consider creating a test VI that can verify your algorithm without requiring special drivers or any hardware. Heh, that would also make it easier for you (and us) to test our suggestions.

Doug
NI Sound and Vibration
0 Kudos
Message 2 of 14
(1,630 Views)

Thanks for your help.

I am fairly new to LabView and have never done anything with bundling timestamps. Do you know of any example VIs that deals with this? I'm not too sure how to do that or where to start. Same with queuing, I've never used it, I can see examples on it but I am unsure how to use queuing to adapt my VI to make my program work. Any thoughts?

0 Kudos
Message 3 of 14
(1,595 Views)

Hello Doug,

I tried the queueing and it does not seem to be working. Once the sensor is covered, it queues the true signal to trigger the diverting function correctly. However, it stays true and I can't get it to queue false signals after to make it stop, so the diverting function just turns on and off every 2 seconds. Below is my code.

bcorduts_2-1652834078780.png

 

bcorduts_1-1652834055845.png

bcorduts_3-1652834148231.png

 

Any thoughts as to why it's not working? I have never used queue before. Any help is much appreciated.

 

0 Kudos
Message 4 of 14
(1,574 Views)

Doug,

I also made this "Queue Test" VI showcasing more or less what I set up. It seems for this, the queue is delayed because it keeps adding to it every while loop iteration. How could I make it so the boolean value is just added to the queue when the switch is pressed? Maybe this will help me real problem? Idk

0 Kudos
Message 5 of 14
(1,570 Views)

@bcorduts wrote:

Doug,

I also made this "Queue Test" VI showcasing more or less what I set up. It seems for this, the queue is delayed because it keeps adding to it every while loop iteration. How could I make it so the boolean value is just added to the queue when the switch is pressed? Maybe this will help me real problem? Idk


"Just add to the queue when the switch is pressed"? Remove it from the false case...

 

But what you probably want is to enqueue once when the button changes.

 

Use a "Has Value Changed PtByPt.vi" or Is "Value Changed.vim"... Only send the button's value when the button changed.

 

Or refactor everything to an event based structure. Then you can use the button's value change event.

 

 

0 Kudos
Message 6 of 14
(1,549 Views)

Hello wiebe@carya,

 

Thank you so much for your response. This helps for my queue test. But if I actually want to apply it to my main problem, I would want it to add to the queue only on a value change from "False-->True". Is this possible to do? Do you know of a way to do this? I can't find anything about it. Thank you.

 

Bryan C.

0 Kudos
Message 7 of 14
(1,530 Views)

@bcorduts wrote:

Hello wiebe@carya,

 

Thank you so much for your response. This helps for my queue test. But if I actually want to apply it to my main problem, I would want it to add to the queue only on a value change from "False-->True". Is this possible to do? Do you know of a way to do this? I can't find anything about it. Thank you.

 

Bryan C.


if value changed AND new value = True, then add to queue 

Doug
NI Sound and Vibration
Message 8 of 14
(1,526 Views)

Thank you both for the help. I now have my "Queue Test" working similarly to my actual project. I have attached my updated version of the Queue Test VI so you can see. Still one problem.

 

The way I have it now is that once the switch is flipped on, the sequence is "2 second delay, light turned on for two seconds, and then light turns off". If I flicker the switch multiple times quickly, I have multiple triggers waiting in the queue. The first trigger runs the sequence including the initial 2 second delay. For the following triggers in the queue, the initial 2 second delay begins when the previous sequence is ended. Is there a way to make it so for the following triggers queued, the 2 second delay starts immediately once the switch is flickered, as opposed to when the sequence in front of it ends?

 

Hopefully this makes sense, if not I can try to explain it more. I would appreciate more help, I am almost there! Thanks!

0 Kudos
Message 9 of 14
(1,519 Views)

^^ Do you think this would be possible using timestamps? Or something else? I have been trying for a while now and can't seem to get anything to work out.

0 Kudos
Message 10 of 14
(1,506 Views)