LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem having two For Loops execute in the same manner.

I'm writing a program to collect two separate data points.

I found a way to get LabView to "weed out" the 0 values collected during the "no event" time of the while loop, but only for one of the data points [the "event" of the user asking for the first data point to be collected].

 

However, from the second For loop, I keep getting "0". Is the first For loop finishing first and ending the program? Or is there a flaw in my thinking that the two paths should function the same?

0 Kudos
Message 1 of 6
(2,826 Views)

There is no difference between the For Loops.  Any differences in behavior must be due to the way you are operating your program.

 

Rather than collecting zeroes by auto-indexing on the while loop with default data at the tunnels sometimes, just build the arrays in the while loop in the appropriate event case?

0 Kudos
Message 2 of 6
(2,821 Views)

I've tried building the array both in and outside. My problem is that I only want to take the one value from that array that's greater than 0.6, so I can subtract the two values. So I guess another related question could be whether I can get the event structure to pass only one element.

 

Or, if I keep the For loops, but put them within the while loop, can I use a shift register to keep a value from changing back to zero? (Like get it to keep that value every iteration?)

0 Kudos
Message 3 of 6
(2,800 Views)

If your device has analog trigger capability, set it to trigger at the 0.6 threshold and collect one point.  No extra data to manipulate.

 

The way you are using the event structure will likely lead to problems in the future if it does not already contribute.  Look at the Producer/Consumer Design PAttersn.

 

Lynn

0 Kudos
Message 4 of 6
(2,795 Views)

Unfortunately, with the way my experiment is set up, that wouldn't work.

 

I'm trying to find the linear calibration of a sensor using two weights, so I need to be able to collect data only once for each added weight.

0 Kudos
Message 5 of 6
(2,792 Views)

What you need to do is use a couple of shift registers in the while loop and then simply subtract when complete.  I attached my solution based on what you had already done.  I don't have DAQmx on this machine, so that part might have gotten messed up.  And I think I might have switched the direction of the subtraction.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(2,778 Views)