LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Capture Last ten Shots (Shift Registers)?

Situation: -
I am continuously acquiring data on 4 channels of the DAQ card using conditional triggering. Each loop captures 2000 samples, which are stored in 2-D waveform arrays containing each scan of each channel. The data is continually updated on a waveform graph for the user to monitor. After a period of "test time" or when you press a button, the loop will end and the last loop of waveform data gets passed to the analysis VI where all the calcs are performed (I only perform calcs/analysis on static data once test time has completed).

Problem: -
I now want to average the last 5-10 points prior to the while loop ending (as the injection needle will jump around slightly shot to shot). I can enable indexing on the while loop and then select the points I require afterwards (i.e. the last 5-10 or whatever), but this takes up a hell of alot of memory and the processor starts caching to disk too often. Can you imagine just how many points are stored in memory (2000 samples/channel, 4 channels per scan, sampling at 80KHz, for 10mins).

There is no need to store all these points. Each time the loop iterates, the buffer is cleared so the program runs quickly and smoothly. All I need to do is store the last 5-10 waveform array's and pass these on to the next VI, not the whole XXXXXX amount of arrays/point.

I may try and use a sequence, so that the first sequence uses disable indexing and ends after the "Test time" has elapsed. This then continues into the next sequence and proceeds to capture a further 5-10 shots with indexing enabled, before passing to analysis VI. This still doesn't really capture the last 5-10 iterations, it captures the next 5-10 iterations, but it would do.

Ideally, I want the while loop to execute with indexing disabled, and at a certain point in time (comparing the "Test Time" with the "sample rate"), the while loop changes to 'indexing enabled' which will build up an array of waveform data until the loop ends (about 5-10 iterations later).

Any Ideas. If you've got time on your hands..........
0 Kudos
Message 1 of 6
(3,294 Views)
In applications like yours, where you want to pre-trigger, I use following mechanism.
Build a "memory vi" containing a shift-register of a 3-D array.
At every acquired shot, replace the last curve ( a rotary index: ..,8,9,0,1... ) with the newly acquired data.
When you decide to trigger, simply press a boolean that activates the read-out of the entire 3D array.
It is usefull to use two independant vi's or parallel loops, in one loop you acquire the data, in another you can read-out the "memory vi".
Do an average (be careful with using the right index of the array) on the 10 shots and voila:
The averaged curve is there.
Note: Be careful to initialise the "memory vi" at the init state of your program.

I hope you understand what I mean.
0 Kudos
Message 2 of 6
(3,294 Views)
I understand what you mean, but as I do not Use LabView often enough and I'm still learning, I would appreciate an example that you have.

Let me elaborate a little further. To simplify things, the set up is like so: -
A while loop executes a conditional retieval that terminates after 10 mins, or when you stop the loop (whichever comes first).
The conditional retrieval takes the form of a Waveform array containing 3 channels. I have got the average part to work fine (working with the correct index arrays 🙂 ), but at present i'm just enabling indexing and subtracting the last ten loops to work with.

Using the above method, it creates alot of memeory uptake with unnecessary loop of data stored. I know what I want to do, but can't think.
I need a
Shift register that will take in 10 values, and once full shift the first data point out and take a new point in. When my main loop then ends, the shift reg data will be forwarded to the ouitside loop as an array of 10 points, for me to perform average on.

Sorry mind not working today, can you help/show me an example vi.

Regards,
Ade
0 Kudos
Message 3 of 6
(3,294 Views)
You can use a shift register. This will just maintain the last "n" amounts of data sets. I've attached a really simple example to illustrate this.

This may work for you needs however there is an issue that the shift registers are in essence being used the whole time so you will have more memory interaction than you may want ... which depending on your performance requirements may not be desirable.

If that is the case then it may be best to slightly modifiy the approach you're using. Indexing continually instead of in the main loop. Set up a condition/case upon which within the main loop you initiate a sub loop that then starts logging the data you require for averaging.

Hope this helps,
Kamran
An
0 Kudos
Message 4 of 6
(3,294 Views)
ademason wrote:

> Situation: -
> I am continuously acquiring data on 4 channels of the DAQ card using
> conditional triggering. Each loop captures 2000 samples, which are

####### cut #####

Hi Ademason,
I'm not shure understandung your problem completely, but the way I see it,
you need a ring buffer.
Say you have a ring buffer buffering 10 elements. Put this in a loop,
filling the buffer with one more element each loop iteration. At the 11th
iteration, the first element gets overwritten.
You should be able to do this with two concentric while loops, I think.

There are explanations of the functioning of ring buffers some place named
like buffered DAQ, i think.
Well finally, when your iterations stop, fetch the count of the buffer
iteration terminal and scan ba
ck the last 10 element. Thats it!

Tell me please if this is what you need.

Bye,
Rainer
0 Kudos
Message 5 of 6
(3,294 Views)
Is this principle basically a shift register approach.
(This is what I have reverted to using now). I just shift 5 elements around the loop, continually overwriting the first element and shifting out the last.
0 Kudos
Message 6 of 6
(3,294 Views)