LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie - How would I accumulate the output of a for loop?

I have a for loop that examines the last set of measurements acquired from my DAQ. When there is a value in a certain channel over 3 I want to start accumulating the acquired data from the other channels. When the trigger channel drops to three again I want to write the data to a file. 

 

I am having a hard time finding the answer to this issue. As a text base programmer I would initialize a array and just start appending the values coming out of the for loop to the initialized array. I have tried to create an array and then check it's length. If the length is zero then use it to feed into insert array. If the length was over zero then feed itself back in. I get a error that tells me to try a feedback node.

 

My for loop code looks like this:

Image 14.png

 

What is the design pattern I need to accumulate this data?

0 Kudos
Message 1 of 7
(1,406 Views)

@flycast wrote:

I have a for loop that examines the last set of measurements acquired from my DAQ. When there is a value in a certain channel over 3 I want to start accumulating the acquired data from the other channels. When the trigger channel drops to three again I want to write the data to a file. 

 

I am having a hard time finding the answer to this issue. As a text base programmer I would initialize a array and just start appending the values coming out of the for loop to the initialized array. I have tried to create an array and then check it's length. If the length is zero then use it to feed into insert array. If the length was over zero then feed itself back in. I get a error that tells me to try a feedback node.

 

My for loop code looks like this:

Image 14.png

 

What is the design pattern I need to accumulate this data?


Can you explain a little further what you mean? What you have here makes no sense. Why are you autoindexing on both the Y array and the waveforms? I thought that in your previous post you were trying to remove values from one waveform if the other was not above a threshold. That is not what you are doing here. Assuming that you are reading from 2 channels and are reading 2 or more points on each channel then your inner loop will run exactly 2 times. The output will be an array of 0 to 2 waveforms depending upon the first 2 values in the first waveform. If you want to take out all of the points in the second channel when the first channel is not greater than 3 then you should do your conditional output on the Y value. This will output an array containing all of the Y values (the values accumulate at the border). 

0 Kudos
Message 2 of 7
(1,345 Views)

One of the problems with coming from a C-based language is understanding and accepting what the system does for you. That way LV has similarities to Python.

If you want to gather all samples you get in the loop to one large Array, just wire the Y to the loop border (since it's a While loop i think it'll default to Last vaue, r-click and change to Indexing)

That way it'll be like you explain, except the Array initialization is automagically handled by LV. You just append to the Array at the loop border.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 7
(1,326 Views)

Please bear with me as I just started learning this week. As a text based programmer the NI way of doing things is fundamentally different.

 

What I am trying to do is set up something that runs 24/7/365 and watches multiple inputs for certain conditions. When certain things happen then send out alerts somehow. My thought process is:

 

  1. Acquire data from the DAQmx at 100 times per second.
  2. Examine one of the channels for the signal to go from zero to 5 volts. When this happens then a certain process is happening with the equipment that we want to watch.
  3. Start accumulating data for analysis when the trigger hits 5v until the trigger returns to 0v. This phase can last from 0.1 seconds to 3 or 4 seconds.
  4. Look at the accumulated data using various algorithms to determine if things are in control or not.
  5. If there are faults then keep a record of the full waveform data for later examination if needed.
  6. If there are any faults keep a record of the fault for later notification. 

I know of at least two different circumstances that I need to test for. To test these I will need to look at the entire data set (0.1 seconds - 4 seconds) and compare one channel to another.

 

I have been doing about 10 of the training videos a day and then attempting various ideas to learn. This is the first one that is close to what I am trying to do.

 

It is clear that I do not understand how the for loop works yet. I think I missed something fundamental. I thought it was iterating all 100 points of the waveform. In reality (based on what you said above) it is iterating 3 times if I have three channels.

 

At any rate I will need a waveform that has somewhere between 100 to 4,000 or so data rows to anylize. That is why I am trying to accumulate data.

0 Kudos
Message 4 of 7
(1,324 Views)

Actually coming from Pascal, PHP (Yuck!), Visual Basic and C#. C# is my preferred language,  A lot to love there.

 

I am absolutly struggling with the different mindset needed to LabVIEW!

 

Thanks for the tip, I'll look at that using a simpler example.

0 Kudos
Message 5 of 7
(1,317 Views)

@flycast wrote:

 

It is clear that I do not understand how the for loop works yet. I think I missed something fundamental. I thought it was iterating all 100 points of the waveform. In reality (based on what you said above) it is iterating 3 times if I have three channels.

 

The FOR loop will iterate the number of times of the smallest of the indexing inputs or the value wired to the iteration terminal. Since your array of channels is autoindexing it will only iterate 3 times. Don't autoindex that and you will run for the full 100 samples.

 

It's beginning to sound like you may need a better architecture. A simple state machine would probably be suitable for your needs.

0 Kudos
Message 6 of 7
(1,315 Views)

@flycast wrote:

Actually coming from Pascal, PHP (Yuck!), Visual Basic and C#. C# is my preferred language,  A lot to love there.

 

I am absolutly struggling with the different mindset needed to LabVIEW!

 

Thanks for the tip, I'll look at that using a simpler example.


I have seen that a lot with programmers coming from a background such as yours. You actually appear to have a better start than some. It is definitely a different mindset.

0 Kudos
Message 7 of 7
(1,312 Views)