Community Documents

cancel
Showing results for 
Search instead for 
Did you mean: 

niScope : Multi Record Fetch with Decimation Code

Introduction

The niScope driver allows you to set the Record Length (samples) and the Sample Rate (samples/s). This in turn gives us the Record Time (s) =  Record Length/Sample Rate. For example, if we want a Record Time of 3 seconds and want our Record Length to be 30 samples, then we would set out Sample Rate to 10 samples/s. Now, each of our digitizer cards have a minimum sample rate, for the PXI-5105, the minimum sample rate is 915 samples/s. So how do we perform the previous acquisiton then? The niScope Driver will preserve the Record Time(s), and hence increase the Record Length. Then, to go back to having only 30 samples a record we will have to decimate our data. Decimation is a technique for reducing the number of samples in a discrete-time signal. This example shows the user how to do this.

Steps to Complete

1. Start with the niScope EX Multi Record Fetch which can be found in the NI Example Finder.

2. Next, you can simplify the code to look like the attached code below, ignore the decimation code to the right for now.

3. To create the decimation code we will use a For Loop with auto-indexing. Drag a For Loop to your block diagram.

4. Now, dividing the Actual Record Length by the Minimum Record Length will give you your decimation factor (n), i.e after ever n samples we will append the sample in a new array, creating a decimated array.

5. Then we round this number to the nearest interger and then make sure that during the correct iteration we will append the sample, this is done with the Quotient & Remainder VI.

6. Finally, we have to append this decimated sample to an array, we use the Insert Into Array VI with a shift register to preserve the array.

6. Copy the rest of the code and wire the VIs as seen in the attachment.

Additonal Notes

When you run this code you will be prompted to save data twice. The first time is your orginal data which can be saved in the attached Actual test data.txt file and the second time is your decimated data which can be saved in the attached Decimated test data.txt. Notice the difference in the number of samples in each file.

Applications Engineer
National Instruments
Contributors