04-01-2010 12:59 PM
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!
04-01-2010 04:23 PM - edited 04-01-2010 04:24 PM
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.
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.
04-01-2010 04:58 PM
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?
04-01-2010 05:06 PM - edited 04-01-2010 05:07 PM
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!
04-01-2010 05:24 PM - edited 04-01-2010 05:34 PM
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?
04-01-2010 06:54 PM - edited 04-01-2010 06:56 PM
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?
04-01-2010 06:56 PM
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
04-01-2010 06:56 PM
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.
04-01-2010 07:01 PM
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).
04-01-2010 09:06 PM