To download NI software, including the products shown below, visit ni.com/downloads.
Overview:
Demonstrates on a correct method to initialize digital filter to remove artifact or start-up error.
Description:
Internally, they are various states in digital filtering. You may think of them as shift registers. As they comb over the data, the output for the n-th element depends on the last x elements.
The actual number varies based on the implementation. One common issue when using digital filters is seeing artifacts when they are uninitialized.
Take a look at the following example: The data in red is the unfiltered data, while the data in blue is filtered.
The one on the left was filtered by a VI where the internal states were initialized to zero (the default for many VIs). The one on the right, however, is what most of us would expect to see.
There is an artifact on the start of the left dataset as the internal zeros get filled up and the filter adjusts for the signal's offset. On the other hand, the signal on the right seems more intuitive.
To eliminate the artifacts or startup error from a digital filter, a subVI that initializes the internal storage elements of the filter to the first data element has to be created.
It was done by duplicating a large number of copies of the first element and append them to the beginning of the dataset.
Then only both of duplicated and original data will be fed into the filter. Afterward, the duplicated elements together with the startup artifacts are removed.
As a result, when the filter gets to the actual data, it will be fully initialized to the correct offset.
The number of extra elements to add may vary depending on your signal or on which filter you use on the lower level.
Additionally, if you are filtering signals continuously, it would not be necessary to do this because many of the filter VIs keep their states between calls.
That means if you are continuously filtering sets of continuous data, you will only see these artifacts at the very beginning and not at the beginning of each set.
Requirements:
Instructions:
Block Diagram Steps:
**This document has been updated to meet the current required format for the NI Code Exchange.**
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.