LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

During acquisition, I need to allocate a buffer to memorize past values. My problem should be easy to solve using other programming languages. With Labview, I suppose I have to use shift registers, but I don't know how. Please, read the additional text.

My problem is a DAQ problem. I am acquiring data; the results are waveform data. I use GetWaveformComponent to get X and Y values. If Yn value is greater than a threshold, I have to write on file (Xn-2,Yn-2) (Xn-1,Yn-1) (Xn,Yn). This means I have to record past Y and X values. Help me, because I have no practice on using shift registers!
0 Kudos
Message 1 of 3
(3,086 Views)
e: During acquisition, I need to allocate a buffer to memorize past values. My problem should be easy to solve using other programming languages. With Labview, I suppose I have to use shift registers, but I don't know how. Please, read the additional text.You need to store your data into an array. Append new input data to end of existing array. Keep an index counter of the present array element. When your threshold is met, use the index-2 or index-1 to retrieve previously recorded data to use in your formula. Only thing is that the array can grow quite large very quickly. If so, make your array act like a shift register by shifting the data up for each new acquisition. For example, suppose you decide to make a shift register of 5 elements. You read in the first five data points and store them into the array, elements 0 through 4. On the next data input, you need to redefine the array to make element 0 equal to element 1, element 1 equal to element 2, and so on until you get to element 4 which will be equal to
your new input. You can use the Rotate 1D Array function in the Array palette. Bring up the help screen on that function to learn how it operates. You can retrieve data from up to the fifth previous reading. In your case, you probably only need a shift register size of 3 (n, n-1, n-2). NOTE: This kind of shift register is not to be confused with the shift register symbol that is used in while loops. That shift register only stores one level of previous data.
Hope this helps.
- tbob

Inventor of the WORM Global
Message 2 of 3
(3,086 Views)
e: During acquisition, I need to allocate a buffer to memorize past values. My problem should be easy to solve using other programming languages. With Labview, I suppose I have to use shift registers, but I don't know how. Please, read the additional text.Hi Giulia,
this is a general advice on shift registers: if you input a Xn value (value at loop n iteration)in a shift register, you can expand the left terminal to get Xn-1, Xn-2 and so on.
Take a look at the example Random Average.vi in \EXAMPLES\GENERAL\SRUCTS.LLB
Let me know if you need more help,
Alberto
0 Kudos
Message 3 of 3
(3,086 Views)