From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-09-2017 04:29 AM
Hi,
i´m trying to make first experiences with producer, consumer loops and event state machine with queues
Unfortunately my consumer loop doesn´t run as while loop.
Can someone explain it?
Solved! Go to Solution.
06-09-2017 05:09 AM
For a loop to move to the next iteration, everything inside it needs to finish.
In your consumer loop, you dequeue first a 'State'. This presumably doesn't change very quickly - I guess you change it only once per program run.
Normally, you only place one dequeue node inside a loop. This is often the main part of the consumer (like you have), but you have two dequeues. Can you see the issue?
06-09-2017 05:28 AM
Two dequeues are making a collision?
What can be the solution?
Later i have more states and will make restart the measurement and saving to tdms vor csv
06-09-2017 05:42 AM - edited 06-09-2017 05:42 AM
I think if you turn on Highlight Execution (the lightbulb icon) it will be clearer than I can type.
That being said, your first dequeue finishes when it gets a state. Probably the first state is "1", so then the loop finishes. Then, the same (first) dequeue gets a second state, "2". Your second dequeue finishes when the first data arrives. Then, the loop finishes the second iteration. Now, your loop goes back to the first dequeue. This doesn't receive a state for a long time (until you send "3", probably) and so the second dequeue never has another chance to read more data.
Setting a timeout on the first dequeue might solve your problem, but it isn't a great architectural design.
06-09-2017 05:46 AM
What is the optimal design architecture to combine user input events and daq aquisition?
06-09-2017 05:49 AM
you could also have a look at user events,
essentially a queue, where you can subscribe to events with the event structure
(i didn't come up with a good way to end both loops, so i took a local variable 😞 )
added as vi for 2014
06-09-2017 05:54 AM
The producer/consumer is a good architecture - I just meant it's not quite what you have.
Your consumer is trying to make some state driven decisions, and its state is controlled by a separate queue.
If you make your consumer only "consume", you shouldn't have a problem. At the moment, it's some queue driven state machine around a consumer, which is more tricky.
Like I said, I think a timeout on the first dequeue will solve the problem but it's more of a band-aid that a solution. Removing the case structure with the states might be a better choice - your first case is unnecessary (you can initialise a shift register to the blank value) and your third case is just a stop condition. You can use the error wire from the dequeue in the loop if you want to stop the consumer loop. Local variables are another option.
06-09-2017 06:11 AM
Oh.notifiers. more New themes. I will check next week what i want and need and try again.
Generally following steps should be created:
1) measuring three or more voltages
2) start/stop/reset/save data by user
3) scale values by customer
So i thought i was on right way
Thank you for the Moment.
06-09-2017 06:31 AM
you were .. don't give up
06-09-2017 07:06 AM
I'm attaching two VIs that I wrote some time ago when I was starting out with LabVIEW. They are extensions to the Event Driven Producer Consumer template.
Although large numbers of VIs are missing, hopefully you can see some information about how my event loop works and some overview of the data measurement loop.
I apologise for the messy front panel and I'm uncertain if I ever used the Timed Loop in the DAQ Loop VI. Previously, I remember it had a normal While loop...
Since then I have moved to an Actor Framework based implementation.