Creating a multi-tap software delay buffer16 Feb 2015 | Ken Wada
Share this page with your friends
Figure 4 shows the test results of the SMA filter for the 4-tap and the 8-tap case. This figure shows that the SMA filter is quite decent at filtering data which has uncorrelated noise. The SMA however, is notoriously bad at rejecting out-of-band signals. For this, you need a different kind of filter.
Figure 4: SMA filter test results for 4 and 8 taps.
High pass filter, (differencing filter)
We can setup an array of coefficients for a different kind of FIR filter. Here, we specify a simple ± 1 filter coefficient set. This type of high-pass filter also has a small low-pass averaging characteristic. This averaging characteristic is important when we wish to do any kind of real-time differencing or derivative computation on real time data. This is because the act of differencing increases the noise gain on the signal. Listing 6 shows the header file for the differencing, or high pass FIR filter.
Listing 6: The header file for the high pass or differencing FIR filter.
The coefficient array is organised in TAP order. The correlation between the TAP index and the USER buffer index is shown in Equation 2. The coefficient initialisation for the differencing filter is shown in listing 7.
Listing 7: This is the case where we initialise the high-pass or differencing filter.
The update and convolution is shown in listing 8. We need the 'for' loop for doing the multiply-accumulate operation. Even though the FIR construct is simple, the implementation of the FIR algorithm does take some time. This listing clearly shows why we need the TAP to user buffer index translation. We need this index translation in order to properly order the convolution computation loop.
Notice how the macro FIR_DIFF_NUM_TAPS is only used in the initializer function. All of the other functions reference the number of taps by accessing its mtapBufferS member. By limiting the access to the number of taps to the initialisation; we can readily generalise these filters to any number of taps by simply changing the reference to the user buffer and by changing how the initialisation is accomplished.
Listing 8: The update implementation of a high pass FIR filter.
Figure 5 shows the test results for a 4-tap and an 8-tap FIR high pass filter. The larger spike for the 1st derivative of the leading and trailing edges of the pulse is due to the lower pass band frequency of the filter with the larger number of taps. Of course, a more sophisticated coefficient selection will yield better results.
Figure 5: FIR difference filter results for a 4-tap and 8-tap simple high pass filter.
Just the beginning
Now you know how to create a generic multi-tap software delay buffer. I also showed how to apply this generic method for two specific FIR implementations. Of course, you can go much further than what I describe here. One of the things you can do is to go out and grab a good book on signal processing and try some filter coefficients on your own. It should not be too difficult to generate some test wave forms using an Excel spreadsheet and do some experimenting using some different coefficients for various types of FIR filters.
About the author
As the president and owner of Aurium Technologies, an independent product design and consulting firm, Ken Wada brings over 25 years of experience architecting and designing products and systems for various high-tech industries. His design experience includes such high-profile systems as the FASTRAK vehicle sensing system for toll roads and bridges and one of the 1st RAID servers while under contract for the National Security Agency.
Want to more of this to be delivered to you for FREE?
Subscribe to EDN Asia alerts and receive the latest design ideas and product news in your inbox.
Got to make sure you're not a robot. Please enter the code displayed on the right.Please enter the valid code. Sorry, you have reached the maximum number of requests allowed. You may wish to try again after a few hours.
Time to activate your subscription - it's easy!
We have sent an activate request to your registerd e-email. Simply click on the link to activate your subscription.
We're doing this to protect your privacy and ensure you successfully receive your e-mail alerts.