TI E2E Community
MSP430 Ultra-Low Power 16-bit Microcontroller Forum
Filter Library for MSP430?
I’m trying to measure reactive energy with MSP430F47187 and its SD16_A module. To calculate reactive energy I need a 90 degree phase shifter known as hilbert filter. If I use FIR filter, matlab says It requires 106 tabs(Transition Width 35 Hz, Passband Ripple 0.02dB/0.1% and Sampling Frequency 1024). I don’t know MSP430 can do this job at that frequency by using Q1.15 style fixed point arithmetic for each phase which is totally three.
Here are my questions:
1. In SLAA409A software code there are some coefficients for 90 degree phase shift. But they are for 4096 Hz sampling frequency and totally 128 tabs. In that C file (emeter-fir-table.c), it is written “This file was generated automatically by generate-fir-table”. Where can I find this “generate-fir-table” software? (I think it is software¿)
2. Can I do same job by using IIR filter instead of FIR which requires too much processing power?
3. Does TI have a filtering library for MSP430 series?
4. In same application note, there is a dc filter function which I didn’t understand how it works.
// A routine to filter away the DC content from an AC mains waveform
// signal. It does this my using a heavily damped integrator to estimate
// the DC level. The current DC level is then subtracted from the signal.
int16_t dc_filter(register int32_t *p, register int16_t x)
*p += ((((int32_t) x << 16) - *p) >> 14);
x -= (*p >> 16);
I think it was designed for 4Khz sampling frequency, because for me it becomes stabile after 40 seconds. I need something faster, is it possible?
Thanks for useful information. For the DC Filter I found this trick:
I can attenuate signals under 20Hz which we can say DC for this application.
MSP430F471xx series has 32 bit hardware multiplier module with fixed point support which is good news for me. But SLAA409A uses only Q15 style multiplication, while the module support Q31 style multiplication and accumulation (MACS32). May be it is highly enough for this application.
Is his mean with ‘standard cascaded biquad sections’ this one?
Second-order (biquadratic) IIR digital filtering
Another question, when I design Hilbert by using FIR (linear-phase, odd symmetry, type 3), it also produces a fixed delay. Let say it has 128+1 tabs, 90 degree shifted signal comes after 64th sample. I already have a buffer for inputs. Because of that, I need another circular buffer for also output. Isn’t there a way to prevent this lag?
Hi,That DC blocking algorithm looks good. Thanks for mentioning it.
BasePointerIs his mean with ‘standard cascaded biquad sections’ this one?Second-order (biquadratic) IIR digital filteringhttp://www.mathworks.com/access/helpdesk/help/toolbox/signal/sosfilt.html
BasePointerMSP430F471xx series has 32 bit hardware multiplier module with fixed point support which is good news for me. But SLAA409A uses only Q15 style multiplication, while the module support Q31 style multiplication and accumulation (MACS32). May be it is highly enough for this application.
BasePointerAnother question, when I design Hilbert by using FIR (linear-phase, odd symmetry, type 3), it also produces a fixed delay. Let say it has 128+1 tabs, 90 degree shifted signal comes after 64th sample. I already have a buffer for inputs. Because of that, I need another circular buffer for also output. Isn’t there a way to prevent this lag?
At some length it is theoretically more efficient to calculate FIR filters via a forward and inverse FFT, but I think that is not so practical on the MSP430 if it has very limited RAM and also the fixed point precision limitations it has et. al. and you're only filtering with an impulse response of 130 or so length, and, anyway it doesn't reduce the delay intrinsic to the z^-1 storage needed for the causal filter, it just reduces the arithmetic complexity of the implementation of the filtering, so it doesn't solve the problem entirely.
If you used a 'complex' filter type implementation where you'd filter both the V channel and the I channel into a pair of filters which generated relative outputs in quadrature then you'd process each channel in a corresponding fashion and then you'd directly be able to multiply the outputs of the V and I filters without (as far as I know) adding additional large delays to either branch.It is possible that using a smaller state / order IIR approximation of a Hilbert transformer would reduce your arithmetic processing and your tap / state memory storage needs substantially and alleviate the problems in those areas with long high delay high MAC count FIR implementations.If there's some other aspect of 'output' delay that you're concerned about, I don't quite understand how it arised based on a limited understanding of your application's architecture. SLAA409 page 12's diagram doesn't seem to show any additional large delays other than that which is needed to shift the phase of one channel by 90 degrees.Here's more references which may or may not be useful...http://www.student.oulu.fi/~oniemita/dsp/hilbert/http://www.dsprelated.com/showmessage/21946/1.php"Hilbert IIR filter implementation"http://www.dsprelated.com/showmessage/24752/1.php"Designing IIR hilbert transform pair"http://www.dsprelated.com/showmessage/88412/1.php"High Speed IIR"http://www.dsprelated.com/showmessage/22749/1.php"Hilbert transform & analytic signals"http://newsgroups.derkeiler.com/Archive/Comp/comp.dsp/2009-03/msg01457.htmlhttp://www.ti.com/sc/docs/products/micro/msp430/wave.pdf"Wave digital filtering for TI's sensor signal processor MSP430"http://focus.ti.com/lit/ml/slap108/slap108.pdf"Optimized Digital Filtering for the MSP430 "http://focus.ti.com/mcu/docs/litabsmultiplefilelist.tsp?sectionId=96&tabId=1502&literatureNumber=slaa331&docCategoryId=1&familyId=342"Wave Digital Filtering using the MSP430"http://focus.ti.com/general/docs/litabsmultiplefilelist.tsp?literatureNumber=slaa357"Efficient MSP430 Code Synthesis for an FIR filter"http://www.bdti.com/faq/2.htm#210"How do I calculate the coefficients for a Hilbert transformer?""Synthesis of very sharp Hilbert transformer using the frequency-response masking technique"Y.C. Lim, Y.J.Yu"Wave digital filters with minimum multiplier for discrete Hilbert transformer realization"S.A. Samad, A. Hussain, D. Isa"Analytic signal generation---tips and traps", Andrew Reilly and Gordon Frazer and Boualem Boashash, IEEE Transactions on Signal Processing, no. 11, vol. 42, Nov. 1994, pp. 3241-3245."Optimal FIR and IIR Hilbert transformer design via LS and minimax fitting" - Instrumentation and Measurement, IEEE Transactions on; Istvan Kollar, Rik Pintelon, Johan Schoukens."Design of multiplierless elliptic IIR halfband filters and hilbert transformers", Miroslav D. Lutovac, Ljiljana D. Milic"A Uniformly Convergent Approximation for Ideal Complex Half-Band Filters", Gagan Mirchandani, Mohamed Elfataui"Approximate linear phase Hilbert transformer" Ljiljana D. Milic, Miroslav D. Lutovac"Design of Hilbert transformer for solid-state energy meter"Bojan Anđelković, Milunka Damnjanović"Elliptic half-band IIR filters" Miroslav D. Lutovac, Ljiljana D. Milichttp://metalab.uniten.edu.my/~farrukh/DSP/DSP%205%20-%20IIR%20Filter%20Design.ppthttp://metalab.uniten.edu.my/~farrukh/DSP/DSP%206%20-%20FIR%20Filter%20Design.ppthttps://ccrma.stanford.edu/~jos/sasp/Matlab_Support_Least_Squares_FIR.html[/code]
All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.
TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs andembedded processors, along with software, tools and the industry’s largest sales/support staff.