LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In line or Sub-VI ?

I have created a VI to do the following :

1. Get raw data from 4 AI channels once every 50ms.
2. Accumulate these in a 2D array as long as a cycle lasts.
3. At the end of the cycle find the mean of all four arrays and check if they are In-Bound and save the result in a BooleanArray.
4. Repeat steps 1 to 3 for three iterations.
5. At the end of the third iteration, find out if each of the channles have been within bound based on the boolean array and declare a Verdict.
( Verdict is FAIL if all the three iterations of one or more channels are FALSE )

The VI is sfucntional and attached. The various indicators help to track the performance and not need in the final version. I only need the controls for CycleCount,  NoOf Channels, LoLimit array and HiLimitArray and the final Verdict information.

Question is :

1. How to convert this into a sub VI  so that I can call this from inside of a 50ms timed loop that the has the DAQMx AI read function?
2. Or is it easy to just copy this code inside of a TimedLoop which my application anyway has ?

Thanks

Raghunathan
Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 1 of 3
(2,578 Views)


@Raghunathan wrote:
2. Or is it easy to just copy this code inside of a TimedLoop which my application anyway has ?

First of all, your VI is overly complicated. You need two shift registers just to keep track if indices because you use "insert into array" to appen a row to an existing array. You don't need those if you use "built array".

(Actually, if performance is an issue, you should allocate a fixed size array and replace columns as you go. In this case you would need these shift registers again ;))

The final code is almost nothing, and I don't think it is worth to create a subVI for it. Just put it inline in the main VI.

You are doing things again way too complicated! Here are some examples:

  1. Your code skips an acquisition set whenever it does the calculation (your new data array doe not enter the case!). You should use all data!
  2. You do an incredible song and dance to duplicate what we already have in "AND array elements" and "Or array elements".
  3. You don't need the "NoOfChannels" control, because the number is given by the array dimension already.

The attached is a quick attempt to solve some of these issues. Now it seems to operate correctly. See it if makes sense to you. The code works well at 50ms loop time.

Message 2 of 3
(2,561 Views)


@altenbach wrote:

You are doing things again way too complicated! Here are some examples:
  1. Your code skips an acquisition set whenever it does the calculation (your new data array doe not enter the case!). You should use all data!
  2. You do an incredible song and dance to duplicate what we already have in "AND array elements" and "Or array elements".
  3. You don't need the "NoOfChannels" control, because the number is given by the array dimension already.

The attached is a quick attempt to solve some of these issues. Now it seems to operate correctly. See it if makes sense to you. The code works well at 50ms loop time.



Thanks for your quick fix. solution. Oh yes it worked fine in the limited time I tested. And as recommended by you I will in-line the code.

Coming to writing "complicated codes" I really think its a case of  Obvious Code vs Smart Code . The  earlier is mine and the latter is yours Smiley Happy Using all the possible functions efficiently needs quite a bit of exposure ( and guidance from stalwarts like you)

Frankly I am just familiar with about - should I say 60% ?- of the functions on the palette. And every time something new has to be conjured up I sit through and read what looks like will solve my problem.

I am happy atleast that I did not do fundamental goof ups. Maybe I am improving ......Smiley Wink

Raghunathan


Raghunathan
LabVIEW to Automate Hydraulic Test rigs.
0 Kudos
Message 3 of 3
(2,548 Views)