LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Producer-Consumer executes very slow

Solved!
Go to solution

Hi!

 

I'm currently using a producer consumer structure that is extremely slow and I hope to get some help in how I can speed it up.

 

One of the consumers opens a front panel wit two dots, these dots have a distance that can be increased/decrease with a rotary encoder (connected to LabVIEW via Arduino).

 

The problem is the following: There's a really (really really) noticable delay from when i turn the rotary encoder to the dots moving (Bonus question: Can one make the front panel not shut down, cause i think this is a part of the delay (that it needs to close and for every iteration)..

 

I've read around a bit and seen that many people make the consumer a subVI but i tried it and it didn't help.

 

 

I've attached the a file (if it helps, its kinda big). Hope that somebody can help!

0 Kudos
Message 1 of 6
(3,616 Views)
What do you mean that the front panel has to close for each iteration? I can't look at your code, but there is only one VI. A front panel doesn't close unless you tell it to.

You should consider breaking the producer and consumer into two separate VIs that run in parallel. It will be easier to build, easier to test and much easier to maintain.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 2 of 6
(3,585 Views)

Hi Firas,

 

which front panel are you talking about? There are a lot of missing subVIs…

 

- Please don't use that much local variables! Especially when the terminals are unused in the block diagram!

- Your BD is way too big! It doesn't fit on my FullHD screen - it uses atleast 6 of those screens!

 

Clean up! Modularize! Uses wires and THINK DATAFLOW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 6
(3,572 Views)
Solution
Accepted by topic author Firas_M

Writing to the Value property node is EXTREMELY slow.  Change those to use the terminals of the indicators.  You also have a lot happening in your producer that could potentially slow you down (hard to tell without the subVIs).

 

Why are you limiting your queue to only be 1 element?  That kind of defeats the purpose of a Producer/Consumer.  Do not limit your queue size and use the normal Enqueue Element.

 

You should also use another loop for the logging of data.

 

Instead of using an array of booleans, it would be easier to understand your code if you used an Enum in your queue.  That will make the case structure simpler and you will likely be able to break up your code to make it more modular.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 6
(3,532 Views)

Index Array is resizable by dragging down the bottom border.  No need to split the array into different branches and have multiple Index Array's to get to different elements.

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

Seems like my answer didn't commit last time.... Sorry for that. 

 

I thank you all for your answers. I redesigned the program with subVIs and less property nodes and local variables.

 

Seems to be a bit quicker and further progress is to be made.

 

Thanks!

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