LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to save 3 seconds sample

Hello!

I have great problem with saving specified length of sample. My vi is running on backround and I am observing the waveform and power spectrum of the signal, and when I think it is right time to save sample I press save button it saves specified length of data(e.g.3seconds). How I can make this possible?

I made one that multiplies scanrate with seconds and result was the buffer size of AI Config. That worked fine but I want that vi is running afterwards also.

Difficult to explain my problem, but hope that somebody undestands my problem.

Neuvos
0 Kudos
Message 1 of 4
(2,862 Views)
Hi Neuvos,

I'm trying to understand the problem clearly in order to provide proper advice.

The first thing is to understand the constraints..

What do you mean by "specified length of sample"? Do you mean time (ex. 3 sec) or filesize, or something else? It looks like you mean time.

If your vi runs in the background waiting for you to press the "Store" button, then it proceeds to save samples for 3 seconds (continuously), then you can implement something like this:

If you run this for a single event:

Have a loop which monitors for the "store button" action. For instance it can be a while loop which stops when the button is pressed. The vi then goes to another while loop which is initialized by a timestamp and runs until timestamp = timestamp + 3 sec. In this same while loop, you can also initialize a shift register which acts as a buffer for the incoming data. You combine (add) the new data to that from the previous loop by using the appropriate function (concatenate string, build array, etc). When the loop ends, you do what you want to do with the output of the shift register (save to file, etc).

If you run it for multiple events, you could combine the second while loop within the first one.

I'm sure you get the idea.

The above assumes that the length of data was based on time constraints. You can change the constraint by using another constraint to the conditional terminal (loop condition).

The reason I split the single and multiple event is because it looks like you want to change scanrates, etc when running the vi. If that is the case, then you may want to place either a Case Structure that is true if a certain amount of time has elapsed. Within this Case Structure, you can change the instrument settings. This can be inside the second while loop which saves the data.

You also mention "buffer size". If that was the constraint, then replace all refernce to time by buffer size. You can get the size of the data within the second while loop and use that as a condition for loop or for the case structure to change the instrument settings.

Hope this helps...

JLV
0 Kudos
Message 2 of 4
(2,862 Views)
Thanks JoeLabView!

Somebody said here that his head is in chaos,I think I have same situation.

You thought that I get the idea, you were wrong. I thought that I got the idea but, no.

I meant the time when I said about specified length of sample. I have two vi's first one works like I want it to, but it doesn't run continuously. Another is the scribble I tried to do by your help but I wasn't able to.

I took one example and modified it, but when I run it hungs up. So what's wrong with it or didn't i get the glue att all.

Thanks
Neuvos.
Download All
0 Kudos
Message 3 of 4
(2,862 Views)
Here are some comments:

The firstone.vi does not have a loop, so it may take a single reading or snapshot of the values (I didn't run it).

Comments on "Taka_A_Sample.vi":

Are the values in the vi the default values that you were using? If so, why is the "number of scans to acquire" set to 0?
You should probably use a higher value.

Are you storing the "TaskId" to file? I think you intended to store the measurements.

Check out the attached vi. I did not run it, so I don't know if it will work. I just wanted to implement what I described in my original reply.

Hopefully it will help you.

JLV
Message 4 of 4
(2,862 Views)