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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I create use producer consumer architecture using typedef clusters?

I am acquiring data using cdaq 9223 @ 1M samples / channel and it consist of 3 channels. I am currently queueing the data in producer loop and dequeueing at consumer loop. But it is bugging me. I want to use it with typedef clusters. How should I do it?

0 Kudos
Message 1 of 22
(4,241 Views)

Hi shivam,

 

I am currently queueing the data in producer loop and dequeueing at consumer loop.

Yes.

 

But it is bugging me.

What is "bugging" you? Where do you have problems with? What errors do you get?

 

I want to use it with typedef clusters.

What kind of cluster? Why not stick with an array of waveforms?

Which additional information do you need to put in this "typedef cluster"?

 

How should I do it?

Define your typedef cluster. Use it to send data through this queue…

 

Recommendations:

- Don't use a queue for the stop condition. Use a notifier!

- Don't use SplitSignal to index the single waveforms, it only creates those dreaded blue DDT wires. Use IndexArray to index array elements (aka waveforms from your waveform array)!

- Don't wire the "number of samples" input at DAQmxTiming. Use this input only when you have read the full help for this functions - and after you understand all of its implications!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 22
(4,216 Views)

hello GerdW,

I am currently queueing the data in producer loop and dequeueing at consumer loop.

Yes.

 

But it is bugging me.

What is "bugging" you? Where do you have problems with? What errors do you get?

This code was working fine earlier but now its not acquiring full 1 min data. i am just getting data of 45 seconds then it shows me "vi's memory full" error.

 

I want to use it with typedef clusters.

What kind of cluster? Why not stick with an array of waveforms?

Which additional information do you need to put in this "typedef cluster"?

 I read somewhere on forum only that typedef clusters are better than using queues.

How should I do it?

Define your typedef cluster. Use it to send data through this queue…

 

Recommendations:

- Don't use a queue for the stop condition. Use a notifier!

- Don't use SplitSignal to index the single waveforms, it only creates those dreaded blue DDT wires. Use IndexArray to index array elements (aka waveforms from your waveform array)!

- Don't wire the "number of samples" input at DAQmxTiming. Use this input only when you have read the full help for this functions - and after you understand all of its implications!

I'll definitely follow the recommendations. I hope this will optimise my code.

 

Best Regards

shivam_2

0 Kudos
Message 3 of 22
(4,143 Views)

Qualified guess as an answer.

A common design/solution when using e.g. Queues are to make a (typedef'd) Cluster of an Enum and a variant and use that as data format in the queue, just wire the cluster to the datasource when creating the queue.

That way you can send a Command with the Enum and Anything as data through the variant. You'll need to convert the data back in the consumer through Variant to data, and ofc. a Unbundle to get the components.

 

Was that what you were looking for?

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 4 of 22
(4,134 Views)

Hello Yamaeda,

Basically i want to optimise this program and wants to resolve Memory full Error.

 

0 Kudos
Message 5 of 22
(4,129 Views)

I'm on LV2011 today, so can't open the file. Can you downsave it?

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 22
(4,116 Views)

Hii Yamaeda..

 

I have downsaved it to ver 2011.

0 Kudos
Message 7 of 22
(4,112 Views)

Hi shivam,

 

this one runs nicely for more than a minute:

check.png

I replaced the DAQmx stuff by some dummy waveforms consisting of 1e6 samples…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 22
(4,109 Views)

Hii GerdW..,

 

But then why isn't it working for daqmx part. Does the code blocks memory or something when it is used for a long time ?

0 Kudos
Message 9 of 22
(4,088 Views)

I removed the Waits and moved the Destroy queue and some little polish. The memory of LV is rock solid while working on the same file (as long as you don't Probe 😉 ) but steps up when starting a new file. This might be a problem in longer runs, but for a few minutes it's no problem.

If you cannot consume fast enough (write to disk) the queue will build up and eat lots if memory. The Waits just adds to this problem in this case, then there's ofcourse the question on where you save the file, locally? Slow disk or occupied with other stuff and so on.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 10 of 22
(4,081 Views)