LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Project Organisation

Dear All,

I am a LabVIEW user for 2 years and I have no much experience about programming architecture. In the project I am handling everything works fine but the program consumes lots of CPU. I took a snap of the performance analysis for you to get my case. In the project I have around4-5 subVIs and 20 while loops. I am trying to catch sychronised control over the components of the project that is why I have used many while loops. But I would like  to know about your suggestions and guidance about HOW TO MAXIMIZE LABVIEW PERFORMANCE and HOW A GOOD PROGRAMMING ARCHITECTURE SHOULD BE. 

Respectfully.

P.s.: According to the rights of the project I am not able to share my VI. Sorry about that.

before running the project.PNGduring project run.PNG

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 1 of 11
(4,034 Views)

Hi N.,

 

put some wait statements in your loops!

 

(Waits can be functions like "Wait(ms)", but also any other function with a TimeOut feature like QueueRead, WaitOnNotification, VISARead, DAQmxRead, etc.!)

 

To answer your generic question with a generic answer: LabVIEW comes with several example projects. Those example projects explain how to setup different architectures like statemachines or prdoucer-consumer. The projects are available through file menu -> "New…"!

 

P.s.: According to the rights of the project I am not able to share my VI.

You should be able to create some example VIs to show the general problem(s) without including any of your proprietary stuff!

Best regards,
GerdW


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

Hi GerdW,

Thanks for the reply. I will consider your advices.

Below I have shared a snap of the program. This is how it looks like but with more while loops.

Program.PNG

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 3 of 11
(4,019 Views)

Go to Help->LabVIEW Help->Fundamentals->Application Development and Design Guidelines

(Here is the online reference: https://zone.ni.com/reference/en-XX/help/371361N-01/TOC96.htm)

-Look more into subtopics : Best Practices for Large Application Development and Managing Performance and Memory

Thanks
uday
0 Kudos
Message 4 of 11
(4,001 Views)

Hi N.,

 

This is how it looks like but with more while loops.

As I already suggested: put some waits in your loop!

It doesn't make sense to update enums within nanoseconds!

 

Once you have done that: Think about proper architectures! Using loops running endlessly on a standard PC isn't what I expect from a Windows executable.

And why are there loops running endless inside of loops also set to run endlessly? What's the point of having a loop at all when it will NEVER iterate? Homer says "Doh!"… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 11
(3,986 Views)

Hi GerdW,

That is a standard approach for FP data tracking. In the outer loop initialization of the front panel components made. Than it passed through inner loop which consist of an event structure that is used to compare if the old value of the corresponding parameter is same as the new value (No change) or not (There is change). Than pass the info to the outer loop back via shift register. Display the new value in a string indicator and update the value of the corresponding parameter using Reg Events function. Hope it is clear now.

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 6 of 11
(3,969 Views)

Hi,

 

Few quick suggestions..

1) Try to reduce as many while loop as possible. Handle all events in a single Event Handler. Update the Enums based on the events. This will reduce atleast 5 loops

2) Have a wait (ms) with atleast 100ms in all the while loops.

3) Implement a Stop control which should stop all the loops once pressed

4) Learn about various architectures in LabVIEW ( Its too late after you have 2 years of experience )

 

Have fun!

 

Mirash

Coding is a combination of intelligent and creative work - someone
Message 7 of 11
(3,965 Views)

Hi N.,

 

That is a standard approach for FP data tracking.

It's standard to use loops running endlessly to track UI events? Where did you learn this?

 

Than pass the info to the outer loop back via shift register. Display the new value in a string indicator

How will you ever pass any information to your outer loop when the inner loop NEVER stops?

 

I'm talking about this one:

check.png

Best regards,
GerdW


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

Hi Mirash,

Thanks for your reply. I will surely consider your suggestions.

Regarding architecture; I am using LabVIEW for programming purposes so often. That is why I am not well skilled on that. 

Add 273 on whatever Celcius said.
-Kelvin
0 Kudos
Message 9 of 11
(3,952 Views)

Instead of setting controls, use Queues, Notifiers, and/or User Events to pass the updates to whoever needs it.  This will eliminate the needs to constantly read control values since you will get the message immediately (assuming you are actually waiting) and the waiting for the message uses 0 CPU.

 

As already stated, all GUI control should be done from a single loop and that loop should only have an event structure.  You can use a queue or notifier to send the updates to whoever needs it.

 

I highly recommend you find the time to take LabVIEW Core 2 and Core 3.  There are plenty of architecture discussions in those.


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
0 Kudos
Message 10 of 11
(3,933 Views)