From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How temporary store data from CRio?

Hi,

 

I am using a CRio to control a system. I am finding that there is a little variation in readings from the ADC module of the CRio, so the reading on the screen is a little eratic. The input signal is more stable than what the reading is making it out to be, so i know it is to do with a sampling error in the CRio (Which is to be expected). To solve this problem, i want to apply a simple filter. Where i record 4 or 5 readings and take the mean average. The 4-5 readings are continuously rolling, so as soon as the CRio has taken a new reading. The value enters the stack and the oldest reading is removed.

 

Now the way i would like to do this is to use a shift register. If a shift register is able to store values and not just boolean?

I've seen other posts in hear talking about a shift register but i can't find it (I've even searched for it but the results doesn't return anything to do with a shift register). Where should i be able to find it?

 

I have the CRio sampling the inputs using a flat sequence structure. Where i have a timer in the first section and everything else that is related to it in the next section. Obviously, the timer in the first section sets the frequency that CRio samples the data. If i increase the timer and therefore decrease the frequency, would the length of time that the CRio takes to samples the data naturally increase? The longer the ADC card takes to sample the signal, the ADC card is therefore given more time to settle and will naturally filter itself.

 

Failing both of these, is there another way i can do what i want to achieve?

0 Kudos
Message 1 of 2
(2,049 Views)

A shift register is a fundamental LabVIEW concept.  It allows you to store any type of value from one iteration of a loop to the next.  Search the LabVIEW help for shift registers.  One common approach to your problem is to store an array of values in the shift register.  Inside the while loop, on each iteration, rotate the array (there's a function for this), then replace the first element with the new data.  This works well for a small array (for example 4-5 previous values); there are faster but more complicated approaches if your array is larger.  If you're doing this in the FPGA on the cRIO you might need a different approach as well: keep track of an array index, insert the new value at that index, increment the index, and reset to zero when you reach the array length.

 

LabVIEW also provides a number of built-in filter VIs that manage all the previous values for you; see if one of those will do what you want.

 

Changing your loop rate will not affect the sample time; as far as I know, the sample time is fixed, or at least not easily accessed.

0 Kudos
Message 2 of 2
(2,043 Views)