05-11-2022 09:54 PM
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).
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.
Solved! Go to Solution.
05-11-2022 11:34 PM
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.
05-11-2022 11:47 PM - edited 05-12-2022 12:04 AM
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?
05-17-2022 07:38 PM
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.
Any thoughts as to why it's not working? I have never used queue before. Any help is much appreciated.
05-17-2022 08:00 PM
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
05-18-2022 07:09 AM
@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.
05-18-2022 04:24 PM
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.
05-18-2022 04:32 PM
@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
05-18-2022 05:04 PM
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!
05-18-2022 08:01 PM
^^ 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.