LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

unnecessary redundancies in my code?

I have a sneaking suspicion that I may have some redundancies in my code, but I'm not really familiar enough with LV to pick them out.

In this portion of the VI I'm trying to read all the channels from the modules, keep the channels in order, sort out the max readings and send them to individual indicators.

 

Thanks for having a look.

unnecessaryredundancies.PNG

0 Kudos
Message 1 of 22
(2,765 Views)

I do see two major problems.

 

How long does a For Loop run if it runs Negative Infinity times?

 

Also, your tasks imply that each one has multiple channels, but in the For Loop, you are reading 1 channel 1 sample.  So you are only getting what I assume is the data from the first channel in each of the tasks.

 

I don't really see redundancies, and the stuff I listed above needs to be fixed first.  But I think you could do a max comparison on each channel within the acquisition loop rather than waiting until after it is done.

 

Example_VI_BD

Actually you can remove that inner For Loop.  Max and Min will work on arrays.  Just right click and make sure it is set for Compare Elements.

Message 2 of 22
(2,750 Views)

RavensFan has addressed the DAQ issues. There is also the issue of updating a ton of indicators. I would try my hardest to reduce the number of controls (with arrays, clusters, etc...) but based on a previous post I know that you want them all separate. One way to do it without too much overhead is to use the "control index". You first have to obtain the index for your controls, then you can just send in an array with the correct datatype to update the array of control indices. You will probably already have the indices in the correct order, but in case you don't, I have sorted them first so they are always in alpha numeric order.

 

Capture.PNG

Message 3 of 22
(2,742 Views)

I just wanted the for loop to run till I hit the stop button, +infinity filled the memory up in my computer in about 4 seconds which is why I used -inf.

 

I didn't notice they were set to read 1 channel, i'll set them to multi channel 1 sample.

 

I put max comparison outside the acquisition loop mainly because I want to data log once per minute all channels, but I don't want to log the max comparison just whatever the channel value is at the time of the log reading.

0 Kudos
Message 4 of 22
(2,730 Views)

@LabNoob14 wrote:

I just wanted the for loop to run till I hit the stop button, +infinity filled the memory up in my computer in about 4 seconds which is why I used -inf.

 


For that you can use a While Loop 😄

Message 5 of 22
(2,727 Views)

haha yeah, hence my screen name.

 

I'm a little confused what you mean by "controls" on your previous reply. I have a ton of indicators not controls,right? Or are you talking about the controls to change the BG colors for indicators on the front panel?

0 Kudos
Message 6 of 22
(2,724 Views)

Oh yes, in this case you can interchange control with indicator. There is no such thing as an "indicator index", it is called a control index whether it is for controls or indicators.

0 Kudos
Message 7 of 22
(2,719 Views)

@LabNoob14 wrote:

I just wanted the for loop to run till I hit the stop button, +infinity filled the memory up in my computer in about 4 seconds which is why I used -inf.

 


But your code doesn't show a stop button.

0 Kudos
Message 8 of 22
(2,713 Views)

@RavensFan

 Ravensfan,

 

Example_VI_BD

Actually you can remove that inner For Loop.  Max and Min will work on arrays.  Just right click and make sure it is set for Compare Elements.


Does your example render this portion of code useless(red circle)?

overcomplicated.PNG

0 Kudos
Message 9 of 22
(2,710 Views)

It also renders the For Loop outside the while loop useless.

Message 10 of 22
(2,696 Views)