07-06-2017 10:01 PM
Hi,
I am quite new to LabView and have just completed my first "real" complex application. In it, 32 samples are acquired from an NI-9206 and the app allows for individual scaling factors to be applied to each channel before writing to a file and displaying both a live waveform and a plot of the points saved to the file. The app also optionally controls (steps through current setpoints from csv) a BK Precision model 8600 DC Load.
The application works well (I won't be surprised to hear about potential issues however) and now I would like to make some optimisations with sub VIs or other enhancements. I wanted to start by making a subVI from the scaling block in the producer loop I have included a picture of.
I would have thought I could make the 32 scaling factors on the front panel into an array and perform some kind of multiply with the DAQmx output array (32 channels by the sample number - typically 100 but user set) but this has not worked for me so far.
I hope its a simple block or math operation I'm not familiar with that could do this without having to make a 32x100 scaling factor array (which seems like a bad idea).
Thanks
Michael
07-07-2017
01:51 AM
- last edited on
12-18-2024
10:32 AM
by
Content Cleaner
Hi Michael,
OMG! 😄
Have you ever thought about using arrays and loops - whenever you repeat the very same task 32 times?
Create an array of your input parameters and apply them to DAQmx configuration and sample scaling in an autoindexing loop!
Example:
Beside of this:
DAQmx allows to apply custom scales to channels. Do you know this very basic AppNote?
- Your VI shows several race conditions due to overuse of local variables. Please replace those locals by wires!
- Please try to avoid coercion dots - or be sure they don't hurt you. Create constants using the right-click menu to avoid wrong datatypes! (The "disabled" property likes to get a typedef'd enum instead of a DBL value!)
- I strongly advise NOT to use DDT wires when all the rest of the code doesn't use it. Why don't you use IndexArray to get your channels from the 2D array? (Well, you don't need all this once you use an autoindexing loop!)
- Clean up your VI by using (more) subVIs. A very basic rule from StyleGuide recommends to keep the BD size smaller than the monitor size. Do you use a 4K/8K monitor?
- What's the reason to stuff new queue data at the "wrong" end of the queue?
- Why do you need to flush the queue because of "too much data"?
- What's the point of the additional wait in the producer loop when loop rate is determined by sample rate and sample number?
07-07-2017 06:48 AM
Everything GerdW said is true - you should go ahead and create a For loop with two auto-indexed array inputs and you'll have a much easier time.
That being said, congratulations on some amazingly tidy DDT wiring... I mean, it's not a great idea to do it, but it's impressive that it's even vaguely readable with so many different inputs!
07-07-2017 07:01 AM