06-10-2015 09:20 AM
Hello everyone,
I am trying to program a control for some manufacturing equippment. For that, I am using a queued message handler. Within the QMH, I have a VI that controls a particle size probe (called PPC, at the bottom of the first image. When I start the main-vi, the PPC.vi is set to the "Parsum measurement" case, in which the measurement data is repeatedly called in a while loop (the vis to call the data were provided by the probe manufacturer. Also, I am aware that I don't log the data yet. That will come later.). When I want to stop the measurement, I send the "Exit" message to the PPC.vi (last picture). However, the vi is stuck in the while loop in the measurement case and does not respond. I tried to send a notifier with a true-constant, but that didn't work as well.
Do you have any suggestions, how I can stop the while loop before sending the "Exit" message? Or is the a completely different way to approach this problem?
Thank you!
Solved! Go to Solution.
06-10-2015 10:20 AM
What I like to do in situations like this is use a timeout of the queue, stores in a shift register so you can change it. The idea is to use one state to start your acquisition and set your timeout to 0. Then in the default case (when you get the timeout) do your measurement and loop back around. This way you are constantly looking for the commands. Your timeout should be -1 (wait forever) when you are not in the measuring mode.
06-11-2015 03:55 AM
Thanks for taking the time to answer me. I get the idea of what you propose, however, I somehow can't implement it. For once, I don't really know how to do it, but I hope I can figure that out in some time. What is more irritating is that I used the dequeue message.vi that was handed out during the Core 3 course. That one doesn't have a timeout input (I uploded the whole project, It would be great if you took a look at it). When I use the "normal" dequeue element.vi, I get an error because the element that is dequeed is not a string, which the case structure expects. Do you have an idea what I can do? I am not that deep into LabVIEW to have a good approach 😕
06-11-2015 06:00 AM
I just threw together a very fast framework to get you started. The thing I did notice is that the Message Queue library does not have a timeout input for the Dequeue Message. Since it is your own local (to the project) copy, add a timeout input and wire it to the Dequeue Element function. I would set the default to -1 and make it "recommended".
06-11-2015 08:15 AM
This is very elegant and also something even I can add to my code!
Except to "add a timeout input". I know I somehow need to add the "standard timeout input", where -1 means continuous waiting for a message, etc.. Google told me that there doesn't seem to be an easy solution, or is there?
I hope I don't stretch your patience too far 😕
06-11-2015 09:01 AM
Here you go. It took 30 seconds to make the change.
06-11-2015 09:22 AM
Ok...now I feel just a little stupid
I didn't look in the code of the dequeue messeage-vi. I started directly by looking for a command or code block to use and couldn't finde one. Thank you!!