This is an intelligent data compression algorithm targeted for LabVIEW FPGA that aims to reduce the amount of raw data acquired using a NI device with re-programmable IO. The algorithm ensures that the minimum number of data points are transferred, whilst ensuring a specified level of accuracy. This means that the algorithm compresses the data on a defined-loss basis.
The algorithm works in the following way:
![]() | ![]() | ![]() |
As each new point is acquired, the gradient between that point, plus and minus the specified accuracy, and the last stored point will be calculated. This will provide a gradient range. | As new points arrive, the union set of these gradient ranges will be calculated. This is the region within which a straight line from the last stored point will never pass more than the specified accuracy from any of the acquired data points. | If a new acquired point means that the union will no longer exist, a point will be stored for the time of the previous data point at the mid-point of the union. This ensures that when the resulting filtered data is interpolated, it will always be within the specified accuracy of the original points. |
Once a point is stored, the algorithm begins again with a new gradient range.
To minimise any data loss in an event such as a power failure, you can define the maximum amount of time allowed between two points. If this time has been exceeded then the algorithm will store the current point regardless of whether the union of gradients still exists.
To view the data in its uncompressed form you can simply plot it on an XY Graph and the waveform plotted will be within the specified accuracy of the original data. If you need to access individual points then you can use linear interpolation on the compressed set of data points.
We have provided both FPGA Top-level and Host example VIs. You can use these together to read 1 second's worth of data from the FPGA and plot it as illustrated in screenshot below. Follow the instructions on the 'Host Example.vi' to run the example.
The current implementation of the algorithm has the following limitations/trade-offs:
Please contact ITDev for integration support, or to discuss solutions optimised for higher compression, different signal characteristics, or higher channel counts.
Inside the attached Data Compression.zip are the following files:
The algorithm has been developed on a PXI-7831R board which uses the Xilinx Virtex II 1M Gate FPGA. The provided example almost uses up the full size of this FPGA due to its small size but should comfortably fit on all the other FPGAs in National Instrument's range.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.