LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use for loop to acquire 1/2 second of data and write to .txt file

Hello,

 

I am trying to develope a vi in which will access a daq board and acquire 0.5 seconds of voltage data from specific inputs on the board.  The below posted vi will continously sample after start is pressed and write the data to a file.  I want to modify this code to fit inside another vi so when accessed it will record the data for each step in the "outer" vi.  Any assistance would be greatly appreciated. 

 

Brian

0 Kudos
Message 1 of 5
(2,645 Views)

The VI you have posted is setup to be a top level VI because of its while loop with a front panel stop button.  How many "steps" do you want to acquire?  You really don't need a subVI.  You should set up your main VI to create the DAQ task before and sample clock before the loop like you do now.  Replace the While Loop with a For Loop with your "# of steps" wired to the N terminal.  Inside the loop, acquire the number of samples that is equivalent to a 1/2 second of your data rate.  So for a 1 kHz sample rate, acquire 500 samples.  After the For Loop, clear the task like you are doing now.

Message 2 of 5
(2,633 Views)

My problem is the "acquire samples" part inside the loop.  When I wire my # of samples to N, I don't know where to wire the N within the for loop.  As you alluded to, I would like this to be a "background" vi in the sense that it will just run when propmted by another vi.  Thanks again,

 

Brian

0 Kudos
Message 3 of 5
(2,629 Views)

Are you sure you even want a For Loop?

 

If you want this to be a subVI, you can't have any kind of loop inside of it.  If you want precisely 1/2 seconds worth of data, you will have to change the 4096 constant to whatever makes sense for your data rate.

 

Exactly what are the "steps" you are talking about for the top most VI?  Perhaps you can give a little more description of your application so that instead of just answering your question (which I have a feeling isn't going to solve your problem) we can suggest a solution that will do what you want it to do.

0 Kudos
Message 4 of 5
(2,625 Views)
Sorry for being to vague.  Basically what I am trying to do is drive a picomotor by 1 step ~ 30 nm or so and acquire a voltage signal from a detector I have wired to the daq board.  I want to vi to function such that a certain number of steps is taken as an input and the vi drives the motor 1 step, acquires the 1/2 second of data, writes it to a file, then drives another step, etc...  The driver vi i am using is included as an attachment.
0 Kudos
Message 5 of 5
(2,623 Views)