LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I improve this VI? (make it faster, better programming sequence). All suggestions are welcome!

I'm trying to find a better and faster way to write/run this VI.  To summarize, I'm trying to read resistance values from a source array and determine their percentages relative to the resistance values on the first iteration (assigned as baseline values).

 

All suggestions are welcome since i consider myself a beginner/novice in LabVIEW programming.

 

 

Thanks in advance for the help!

 

 

Improve VI-Block Diagram.PNG

 

Improve VI-Front Panel Results.PNG

0 Kudos
Message 1 of 10
(2,914 Views)

I don't know about faster or better, but the following snippit eliminates unneeded stuff.  You don't need the innermost While Loop because it runs only once.  Move the shift registers to the outermost loop.  Your Basline array is the same as the original Resistance array, so you don't need to index the 2D array to get those values.  But you still need a loop to divide each 2D row by the baseline array.  I created code to create variation in the resistances for demo purposes.  You will have to change to add code to gather the actual new resistor values.  The bottom-most shift register would be replaced by the new gathering code.

 

Resistance.png

 

 

Before anyone says anything about the 500 mS delay, it was added to see front panel updates occur slowly.  Change the 500 to 0 to run quickly.  Despite objections from other parties, I still put a delay, even 0, in most of my loops to avoid chewing up CPU time.

 

Message Edited by tbob on 04-01-2010 02:24 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 10
(2,877 Views)

Thanks tbob for all your help.

 

One question, how would you modify the code you wrote above if the Resistance array needs to stay within the boundaries of the while loop?

0 Kudos
Message 3 of 10
(2,857 Views)

Please attach some actual code instead of oversized pictures.

Also include some typical data in the controls (make current values default before saving).

 

A picture cannot show all features and we cannot run it for testing.

 

We cannot tell what's in the other cases!!!

A feedback node is probably more appropriate for your application. 

 

What does "Boolean" do? Give it a more descriptive name!

 

 

 

Message Edited by altenbach on 04-01-2010 03:07 PM
0 Kudos
Message 4 of 10
(2,851 Views)

They tend to get a bad rap but I would favor a feedback node here.  Also, it's a bit hard to figure out the intended behavior of your vi.  The way you have it coded it will keep appending the same resistance array to the Stacked Resistances until you stop the vi.  Your FP image doesn't reflect that so I assume that's not you intent?

 

 

 

Example_VI.png

Message Edited by Daklu on 04-01-2010 03:34 PM
0 Kudos
Message 5 of 10
(2,838 Views)

I guess its personal preference, but I hate feedback loops.  They are very unclear.  A good old shift register and a loop makes much more sense to me.

 

 To vince-ndt:  As Altenbach stated, we need more info before we can help any further.  Where are you getting your resistance values from?

 

Message Edited by tbob on 04-01-2010 04:56 PM
- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 10
(2,806 Views)

Sorry for not providing enough details to my question/s.  It's hard for me to describe my VI's and sub-VI's since I'm working off a massive code that I'm trying to understand and modify/compress to suit my needs.

 

I'll try to be more definitive and provide more details next time I post questions in this forum.

 

 

All your feedbacks are much appreciated.

 

thanks,

 

-Novice LabVIEW user

0 Kudos
Message 7 of 10
(2,805 Views)

Since the arrays you are using are quite small then you will probably not gain any noticable speed.

 

I see that you are using the Build Array function.  Here is a very interesting thread which is advises against that:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=476505&query.id=1750399#M476505 

 

This VI does not need any While loops.  Infact these that you have will never stop running without user intervention.

 

Cheers,

 

Battler.

0 Kudos
Message 8 of 10
(2,802 Views)

FYI-Resistance values are being provided by a sub-VI that reads resistances acquired by an Agilent 34970A DAQ Unit with a 16-channel Reed multiplexer (we can have anywhere between 2-16 channels providing resistance readings at a time).

0 Kudos
Message 9 of 10
(2,801 Views)
I see no subVIs.  Anyway, of they are being "provided" (i.e. fixed number) then you still don't need a While loop...
0 Kudos
Message 10 of 10
(2,783 Views)