LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem suitable for consumer producer?

Hi!

My application would aquire  a certain number of signal samples at a certain time, specified by GPS. The NMEA time is read, and the acquisition is started at the next 1PPS from the GPS, if the time is right. The 1PPS is read from a  NI-6009 DAQ device. The number of samples is determined in a text-file, only the start is GPS-synced.

 

I have done this before with two parallel while loops, passing a "start aquisition" boolean from the GPS-loop to the aquisition-loop with a local variable. Data is written to file and displayed within the aquisition-loop. If a new timing or datafile is needed this is also done within the acquisition-loop.

 

This works ok, but I would like to improve the code and the userinterface, and make it more modular. 

 

Would this task be suitable for a producer/consumer type of template? I`m not sure how to set it up correctly, and how to pass GPS-data to the acquisition loop?

0 Kudos
Message 1 of 6
(3,394 Views)

Hi Gunnar, data is often passed to a loop using a queue. To use a queue you must "Obtain Queue" once at the beginning of the application. Use "Enqueue Element" to send data and "Dequeue Element" to receive data, and at the end of your application you use "Release Queue". You want to make whatever data you are sending into a typedef (often a typedef cluster works well) so that if you change the data, everything updates automatically.

0 Kudos
Message 2 of 6
(3,383 Views)

like gregoryj said, Queues are applicable. and things that build up on that:

User Events

Message Queues

Actor Framework

 

i would recommend you to have a look at least at the User Events as an alternative to Queues,

i find the use of the Event Structure quite nice, because you can have your organizational logic in the Timeout-Case (note the default-timeout-value is -1ms (never) which i would set to 0ms) and generate user events there, and wait there if no events were fired.

 

hope that helps and good luck 😉


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 6
(3,371 Views)
0 Kudos
Message 4 of 6
(3,362 Views)

Hi Gunnar,

 

My name is Hashim, and I am an Applications Engineer at NI. To reiterate what gregoryj and  jwscs have said, it sounds like the producer/consumer architecture would suit your application quite well.

 

I have found a comprehensive article produced by NI which details the producer/consumer architecture. It will teach you why we use the architecture, and also how to set up a queue for your own application. Hope you find this helpful:

 

https://www.ni.com/en/support/documentation/supplemental/21/producer-consumer-architecture-in-labvie...

 

Kind regards,

 

0 Kudos
Message 5 of 6
(3,304 Views)

Thanks to everybody!

I`ll have a closer look, and try to make myself an example. It`s a bit unclear for me what would be the producer and what would be the consumer. NMEA-data and 1PPS from the GPS-receiver need to be decoded all the time, and at the right time start an acquisition. So the right time could trigger an event that start the acquisition? At the same time, I need a user interface to load a new timing file, change acquisition file etc..

0 Kudos
Message 6 of 6
(3,281 Views)