LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie - how would I start saving values to an array once a trigger is hit?

I am trying to watch two channels. One channel (channel zero) is my trigger. The other channel is my data. What I need to do is start saving data from my data channel when my trigger goes over a certain value. What I have so far looks like this:

 

SaveData.png

 

  • My logic is collect the data every 1/10th second.
  • Take the waveform and split it into trigger and signal
  • iterate the trigger until I find one that exceeds 3.
  • Start saving the data into an array.
  • Append the array for that 1/10 second to a array that saves all the data (perhaps up to 20 seconds worth).
  • Write the data to a NI file format for review later.

 

I may be over complicating this, I am a text based programmer learning NI.

I am having trouble creating an array with the values once the trigger exceeds 3. I am totally blank of any ideas on how to do so.

 

I only have one module - NI 9205 voltage so I am using a voltage signal for a trigger.

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

Hi flycast,

 

I saw you mention you want to acquired data in rate of 1/10 s but I didn't see the timing setting.

 

Btw, why after the DAQ start node is a for loop structure with terminal condition but wired also to the count terminal N? are you going to run the whole program only once? 

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

@CL_lee wrote:

Hi flycast,

 

I saw you mention you want to acquired data in rate of 1/10 s but I didn't see the timing setting.

I'm assuming that the timing is set in the DAQmx Task in MAX. 

 


@CL_lee wrote:

 

Btw, why after the DAQ start node is a for loop structure with terminal condition but wired also to the count terminal N? are you going to run the whole program only once? 


I also don't understand this. I think this should just be a while loop, or no loop at all. Also, a method for stopping should be included - the Abort button at the top of the screen is there just for development purposes. A proper stop routing should be practiced.

 

You do not have to wire the Number of Iterations terminal of the FOR loop if you are using an autoindexing array.

 

Keep the wires straight as much as possible. This aids in the readability of the program just like indexing does in a text based language.

 

I think that all you really need to do is on the output to your inner FOR loop right click and select Conditional output. Then wire your boolean value to that terminal.

0 Kudos
Message 3 of 7
(1,934 Views)

@CL_lee wrote:

Hi flycast,

 

I saw you mention you want to acquired data in rate of 1/10 s but I didn't see the timing setting.

 

Btw, why after the DAQ start node is a for loop structure with terminal condition but wired also to the count terminal N? are you going to run the whole program only once? 


The timing is in the task.

 

I want to run the program 24/7/365 to monitor a piece of manufacturing equipment. The program is intended to watch up to 8 channels for different conditions and then run some tests (to be developed later) against some of the readings. I have the loop running once at this point to debug.

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

@johntrich1971 wrote:

@CL_lee wrote:

Hi flycast,

 

I saw you mention you want to acquired data in rate of 1/10 s but I didn't see the timing setting.

I'm assuming that the timing is set in the DAQmx Task in MAX. 

 


@CL_lee wrote:

 

Btw, why after the DAQ start node is a for loop structure with terminal condition but wired also to the count terminal N? are you going to run the whole program only once? 


I also don't understand this. I think this should just be a while loop, or no loop at all. Also, a method for stopping should be included - the Abort button at the top of the screen is there just for development purposes. A proper stop routing should be practiced.

 

You do not have to wire the Number of Iterations terminal of the FOR loop if you are using an autoindexing array.

 

Keep the wires straight as much as possible. This aids in the readability of the program just like indexing does in a text based language.

 

I think that all you really need to do is on the output to your inner FOR loop right click and select Conditional output. Then wire your Boolean value to that terminal.


I'll add a stop button. Good practice apparently.

Autoindexing array and for loops - Great!

It is really easy to get spaghetti going, especially when new to this.

I did not know about a conditional output. Great gem there!

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

@flycast wrote:


I'll add a stop button. Good practice apparently.

Autoindexing array and for loops - Great!

It is really easy to get spaghetti going, especially when new to this.

I did not know about a conditional output. Great gem there!


I've written some spaghetti code myself (thankfully a long time ago).

 

The stop button is the simple way. I also often use an Event structure and capture the Panel Close event (no button needed). 

 

There are a lot of good resources to help give you a jump start in using LabVIEW. Some of them are listed at the top of this board.

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

@flycast wrote:


The timing is in the task.

 

I want to run the program 24/7/365 to monitor a piece of manufacturing equipment. The program is intended to watch up to 8 channels for different conditions and then run some tests (to be developed later) against some of the readings. I have the loop running once at this point to debug.


because you wire the count terminal with 1 so you get the loop running only once although your terminal condition set to always run.

 

Agree with john, the outer loop in your program is better change to while loop with a stop button.

 

In for loop, if both count terminal and auto-indexing is wired, it will choose the less iteration to run. This case is similar to when you auto-indexing 2 array, the number of iteration will follow the array with less element if both array are not having same number of element.

If you set terminal condition, when stop condition is triggered it will abort the loop although the count terminal iteration or the auto-indexing haven't finish.

 

Btw, in LabVIEW, it is better to let the data flow wire connection between the node in the program from left to right 

 

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