LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Real-time updating '1D array double' data converting to periodically updating 'double'

Solved!
Go to solution

Hi, I am very new to LabVIEW and I am stuck on this one part.

 

To begin with, my project consists of a gas analyzer updating the percentages of gases flowing in a tube. This information is received in '1d array of double'. I need to first make sure the percentages of gases are passed onto a cluster periodically (maybe once every 10 seconds). Everything else in the while loop should be running consistently. Also, the percentages should be passed in type 'double' instead of '1d array of double'.

 

I attach my current VI here, please let me know if there are additional information I should provide. Thank you all!

0 Kudos
Message 1 of 6
(1,932 Views)

You didn't include the VI that you are passing the data into. Therefore, we have no idea what type of data that VI is expecting as an input. You should zip up all of the related files and attach that.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 6
(1,921 Views)

Here are the missing VIs. Also, the VI is expecting a cluster of 15 inputs being 5 unsigned word, 5 doubles and 5 booleans.

0 Kudos
Message 3 of 6
(1,915 Views)
Solution
Accepted by topic author mattdoo

You already have the data you need to pass to the subVI. Instead of wiring the array, wire the corresponding calculated percentage that you are wiring into the indicators on your front panel. BTW, the code is failry messy and I would never put unlabeled controls or indicators on the block diagram. You have free floating text over the indicators on the front panel but your actual indicator values are empty. Controls and indicators have both a label and a caption. Use those. This helps to document your code. In addition, I would not use the bundle operation but bundle by name instead. Again, this makes you code more readable. Bundle by name does require a cluster, preferably a typedef, input so you know what the cluster contains and what the element names are. Since you are using a third party library and it is not likely to change you can simply create a constant from the input to Write Composer Gas Mix vi and use that as the input to the bundle by name. Another benefit of doing this is that you don't have to wire the unused elements of the cluster. Simply make sure they have the correct value in the cluster constant.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 4 of 6
(1,898 Views)

I was in the middle of trying new things out, which made organization worse (I am also very new to LabVIEW). Thank you so much for your time to explain it clearly and solving my issue. 

 

One more potential issue is that my 3rd party subVI needs the three percentages to equal exactly 100. Since I am taking the 3rd gas as (100 - (gas1+gas2), would it be perfectly 100 all the time? (wondering about significant digits of doubles)

Lastly in terms of organization, is there any other tips/recommendations to make the wiring nicer? I tried ctrl+u to automatically clean up wires but it isn't properly organizing the wires.

0 Kudos
Message 5 of 6
(1,883 Views)

First and for most I would avoid using the express VIs. Learn the DAQ primitives and use those. Express VIs tend to reinitialize the DAQ task every time and this will cause a performance issue. I can't really comment on whether your percentages will always equal 100 or how your third party library will deal with that. When working with floating point values you should never rely on testing equality but rather test using a tolerance. Because as you stated, digits of precision can come into play.

 

Regarding some basic tips for clean code, here are a few basic guidelines:

Keep your wire flow going left to right

Avoid wire bends as much as you can

Don't run wires backwards

Keep your block diagram small, it should not be larger than a single display. Smaller is not bad since it will accommodate laptops.

Use subVIs. Especially if you find yourself copying and pasting code on your diagram.

Label things

Take some time to learn some of the various architectures (basic: state machines and producer/consumer; advanced: queued message handler, actor framework)

 

There is an older book by Peter Blume but it is still very informative:  LabVIEW Style Book 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 6
(1,872 Views)