10-01-2020 05:32 PM
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:
What is the design pattern I need to accumulate this data?
10-02-2020 06:58 AM
@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:
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).
10-02-2020 09:20 AM
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.
10-02-2020 09:24 AM
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:
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.
10-02-2020 09:28 AM
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.
10-02-2020 09:32 AM
@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.
10-02-2020 09:35 AM
@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.