LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Flat Sequence not Initiating

Solved!
Go to solution

Why are they consuming so much processing power in the false case? Most of them aren't doing anything in that situation.

 

Sorry I didn't see your response but I hit send on this

0 Kudos
Message 11 of 20
(2,220 Views)
Solution
Accepted by topic author endlessOranges

@endlessOranges wrote:

Why are they consuming so much processing power in the false case? Most of them aren't doing anything in that situation.


Yes, they are doing something!!!!

 

Since there is no small wait, they spin as fast as the computer hardware allows, millions of times per second! Constantly polling the buttons values and local variables.

 

Even a 1ms wait would reduce the CPU consumption by many orders of magnitude.

Message 12 of 20
(2,214 Views)

What is a more efficient way to handle all of my conditional statements then?

0 Kudos
Message 13 of 20
(2,207 Views)

Well, I don't know your system enough to give detailed advice, but as a first step you should chose a suitable code architecture and eliminate some glaring programming mistakes and inefficiencies. Here is some general advice:

 

  • Use a state machine with one loop dealing wit the UI and another loop dealing with parallel background processes. Look at the design templates that ship with LabVIEW.
  • Create the virtual channel for the digital ouput exactly once before any loop. Don't create the same virtual channel over and over in two places in parallel without ever closing it. Create it once before the loop, write the points as needed inside the loop, and close it after the loops have finished at the end of the program.
  • same with the VISA stuff. Configure the port once before the loop and not over and over. Close the VISA session once the loop has completed.
  • Eliminate all these local variables, most (probably all with good coding) are not needed.
  • When you write to the file, the use of a dataqueue of size=1 to basically convert a scalar to an array with one element is just silly. Just use "built array".
  • Eliminate the dataflow flaws and race conditions. For example if somebody would switch the "system shutdown" button on and off, some loops would terminate while others would keep running. It is just not predictable.
  • Use subdiagram labels to label the loops. Free labels may go elsewhere after a diagram cleanup.
  • Change some of the blue diagram constants to U32 to eliminate the coercion dots.
  • You write to "backwash pump error" in two different locations. How do you know where the problem occured?
  • Your "sensor error" indicator only gets written once the program is stopped. Wouldn't it be more interesting to see these errors while the program is running? That terminal belongs inside the loop!
  • etc....

 

0 Kudos
Message 14 of 20
(2,183 Views)

So I started putting your ideas together and threw a five second timer on my bottom loop so it stops sampling so quickly and taking up processing speed and the code runs smoothly.

0 Kudos
Message 15 of 20
(2,177 Views)

I'll take a look at some of these other problems to improve the code. Thank you so much for the advice!

0 Kudos
Message 16 of 20
(2,168 Views)

Five seconds seems excessive. Did you mean five milliseconds?

0 Kudos
Message 17 of 20
(2,167 Views)

I just set it to five seconds because that was still pretty small compared to the ten minute cycles I have it set to for the actual system but if I can drop it much lower I will try that.

0 Kudos
Message 18 of 20
(2,135 Views)

What is it that makes the array method superior to the queueing? Is it something behind the scenes in how labview handles these nodes because otherwise they look pretty similar other than the fact that the queue requires I tell it to make it a length of 1 first.

0 Kudos
Message 19 of 20
(2,115 Views)

Built array is a labview primitive and highly optimized.

 

The queue ptbypt is a subVI with lots of code (you can double-click it and inspect it). Firstly, you have the subVI call overhead, then you are invoking a huge queue machinery for basically nothing. It also retains old data until it gets overwritten or exceeds the configured size. It has four inputs and produces five outputs, but you only use one of them. It is like using an industrial robot to remove the toast from the toaster or use the supercomputer cluster ant the National Atmosperic Reasearch Center in Boulder to solve 1+1=2. Definitely possible, but there are easier ways.

 

Built array works with (almost) any datatype (strings, paths, numeric, references, etc.) while the queue ptbypt works exclusively with DBL. (There is a second version in the palette that works with complex double). This means that if you next time work with integers, you would need to re-learn from scratch.

 

And no, they don't look similar!

 

0 Kudos
Message 20 of 20
(2,108 Views)