Forums

My first Digital Filter: Can I ask your help?

Started by gpezzella June 17, 2010
Hello

this is the first time that I approach to DSP so I'm really newbie.
I have to write a program that realize a Low Pass Filter at 50 Hz.

My processor (ATTINY) have 10bit ADC so for first time I have used
Oversampling and Decimation technique for add 3 "Virtual Bit"

First Question:
Since my Oversampled Frequency is:
              
            4^3 * F-nyquist = 64 * 100 = 6.4KHz

Taking sample at this precise rate I obtain directly a signal already
filtered at 50Hz??

The maximum sample rate of ATTiny is about 15KHz
Is Better take sample at this rate and after filter a signal with a DSP
Filter?

In this last case can you explane me how to write 50Hz Low Pass Filter?

Thanks

  


On 06/17/2010 02:23 PM, gpezzella wrote:
> Hello > > this is the first time that I approach to DSP so I'm really newbie. > I have to write a program that realize a Low Pass Filter at 50 Hz. > > My processor (ATTINY) have 10bit ADC so for first time I have used > Oversampling and Decimation technique for add 3 "Virtual Bit" > > First Question: > Since my Oversampled Frequency is: > > 4^3 * F-nyquist = 64 * 100 = 6.4KHz > > Taking sample at this precise rate I obtain directly a signal already > filtered at 50Hz??
Not unless the processor does it for you, which I doubt.
> The maximum sample rate of ATTiny is about 15KHz > Is Better take sample at this rate and after filter a signal with a DSP > Filter?
From what perspective? It's more work for the processor, does it have the bandwidth to spare? Assuming plenty of processor resources, faster sampling is generally better.
> In this last case can you explane me how to write 50Hz Low Pass Filter?
Hit the books! Is this for school? If so, ask the prof. If it's for work, or if it's project work, look on Wikipedia, and do some web searches. You need to know if you want to use an IIR or FIR filter (web searches will tell you what those are, and give some guidance of why one or the other will be good), whether you want to decimate (web search), etc. If you come up with more questions as you go along, ask. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
Hello 

I will try to explane better and if there are errors, please correct me.

My goal is to acquire very low frequency and voltage signal (5Hz-50Hz 1mV
-2mV) with 10bit DAC.

I have Voltage Reference = 1.1Volt that give me at 10bit 1mV resolution.
So for first thing I have add 3 virtual bit for increase resolution by
using Oversampling and Decimation Technique:

'F-cut = 50Hz
'F-nyquist = 100Hz
'Virtual Bit = 3
'Scale Factor 2^Virtual_Bit = 2^3 = 8
'F-oversampling = ( 4^3 ) * 100 Hz = 64 * 100 = 6400 Hz.

Since I can set only FIX Sample Rate at 9.8 KHz is correct that my real
f-cut will be 76Hz and not 50Hz? 


NOW FILTER

I have read that FIR sync filter sen(x) / x is good low pass filter.
Is correct that:

1) My "Virtual Sample Rate" is 152 HZ and hence Filter f-cut = [0 - 0.5] *
152


For last
2) Since I have very few memory on micro, how I must choose M value?

Please do not reply vaguely but use number and value.

Thanks


p.s.
This is the tutorial that I'm reading: http://www.dspguide.com/ch16/2.htm





>On 06/17/2010 02:23 PM, gpezzella wrote: >> Hello >> >> this is the first time that I approach to DSP so I'm really newbie. >> I have to write a program that realize a Low Pass Filter at 50 Hz. >> >> My processor (ATTINY) have 10bit ADC so for first time I have used >> Oversampling and Decimation technique for add 3 "Virtual Bit" >> >> First Question: >> Since my Oversampled Frequency is: >> >> 4^3 * F-nyquist = 64 * 100 = 6.4KHz >> >> Taking sample at this precise rate I obtain directly a signal already >> filtered at 50Hz?? > >Not unless the processor does it for you, which I doubt. > >> The maximum sample rate of ATTiny is about 15KHz >> Is Better take sample at this rate and after filter a signal with a DSP >> Filter? > > From what perspective? It's more work for the processor, does it have >the bandwidth to spare? Assuming plenty of processor resources, faster >sampling is generally better. > >> In this last case can you explane me how to write 50Hz Low Pass Filter? > >Hit the books! Is this for school? If so, ask the prof. If it's for >work, or if it's project work, look on Wikipedia, and do some web >searches. You need to know if you want to use an IIR or FIR filter (web >searches will tell you what those are, and give some guidance of why one >or the other will be good), whether you want to decimate (web search),
etc.
> >If you come up with more questions as you go along, ask. > >-- >Tim Wescott >Control system and signal processing consulting >www.wescottdesign.com >
On 18.6.10 2:04 , gpezzella wrote:
> Hello > > I will try to explane better and if there are errors, please correct me. > > My goal is to acquire very low frequency and voltage signal (5Hz-50Hz 1mV > -2mV) with 10bit DAC. >
EKG/ECG/EEG signal? Please note that the built-in A/D converters of small processors (like ATTiny) are far too noisy for this kind of work. If you have biological signals, you need a proper pre-amplifier, and you were much better off with a separate A/D converter. -- Tauno Voipio, MSEE
On 6/18/2010 7:04 AM, gpezzella wrote:

>> On 06/17/2010 02:23 PM, gpezzella wrote: >>> Hello >>> >>> this is the first time that I approach to DSP so I'm really newbie. >>> I have to write a program that realize a Low Pass Filter at 50 Hz. >>> >>> My processor (ATTINY) have 10bit ADC so for first time I have used >>> Oversampling and Decimation technique for add 3 "Virtual Bit" >>> >>> First Question: >>> Since my Oversampled Frequency is: >>> >>> 4^3 * F-nyquist = 64 * 100 = 6.4KHz >>> >>> Taking sample at this precise rate I obtain directly a signal already >>> filtered at 50Hz?? >> >> Not unless the processor does it for you, which I doubt. >> >>> The maximum sample rate of ATTiny is about 15KHz >>> Is Better take sample at this rate and after filter a signal with a DSP >>> Filter? >> >> From what perspective? It's more work for the processor, does it have >> the bandwidth to spare? Assuming plenty of processor resources, faster >> sampling is generally better. >> >>> In this last case can you explane me how to write 50Hz Low Pass Filter? >> >> Hit the books! Is this for school? If so, ask the prof. If it's for >> work, or if it's project work, look on Wikipedia, and do some web >> searches. You need to know if you want to use an IIR or FIR filter (web >> searches will tell you what those are, and give some guidance of why one >> or the other will be good), whether you want to decimate (web search), > etc. >> >> If you come up with more questions as you go along, ask. >> >> -- >> Tim Wescott >> Control system and signal processing consulting >> www.wescottdesign.com >>
> Hello > > I will try to explane better and if there are errors, please correct > me. > My goal is to acquire very low frequency and voltage signal (5Hz-50Hz > 1mV -2mV) with 10bit DAC. > > I have Voltage Reference = 1.1Volt that give me at 10bit 1mV > resolution. > So for first thing I have add 3 virtual bit for increase resolution by > using Oversampling and Decimation Technique: > > 'F-cut = 50Hz > 'F-nyquist = 100Hz > 'Virtual Bit = 3 > 'Scale Factor 2^Virtual_Bit = 2^3 = 8 > 'F-oversampling = ( 4^3 ) * 100 Hz = 64 * 100 = 6400 Hz. > > Since I can set only FIX Sample Rate at 9.8 KHz is correct that my > real f-cut will be 76Hz and not 50Hz? Not correct. You must sample *at least* twice as fast as the data's bandwidth. In other words, the cut-off frequency should be *no more* than half the sample rate. Actually, one third is good practice. > NOW FILTER > > I have read that FIR sync filter sen(x) / x is good low pass filter. > Is correct that: Good for what? A truck is a good vehicle; so is a bicycle. > 1) My "Virtual Sample Rate" is 152 HZ and hence Filter f-cut = [0 - > 0.5] * 152 What is virtual sample rate? The reference you cite below deals with windowed-sinc filters, not resolution or accuracy. > For last > 2) Since I have very few memory on micro, how I must choose M value? > > Please do not reply vaguely but use number and value. > > Thanks > > > p.s. > This is the tutorial that I'm reading: http://www.dspguide.com/ch16/2.htm This isn't going to work. Other conditions being met, the precision gained by averaging increases with the square root of the number of measurements. To increase the precision eight times (three bits worth) you need to average 64 (8^2) measurements. Even at that rate, it probably won't work on your processor. To get 13-bit results from a 10-bit ADC, the converter needs to slice accurately to 13 bits thresholds. Any converter on a processor chip is most unlikely to be that good. If the spec sheet doesn't say it is, it isn't. There are other considerations, but one thing at a time. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
On 06/18/2010 07:01 AM, Jerry Avins wrote:
> On 6/18/2010 7:04 AM, gpezzella wrote: > >>> On 06/17/2010 02:23 PM, gpezzella wrote: >>>> Hello >>>> >>>> this is the first time that I approach to DSP so I'm really newbie. >>>> I have to write a program that realize a Low Pass Filter at 50 Hz. >>>> >>>> My processor (ATTINY) have 10bit ADC so for first time I have used >>>> Oversampling and Decimation technique for add 3 "Virtual Bit" >>>> >>>> First Question: >>>> Since my Oversampled Frequency is: >>>> >>>> 4^3 * F-nyquist = 64 * 100 = 6.4KHz >>>> >>>> Taking sample at this precise rate I obtain directly a signal already >>>> filtered at 50Hz?? >>> >>> Not unless the processor does it for you, which I doubt. >>> >>>> The maximum sample rate of ATTiny is about 15KHz >>>> Is Better take sample at this rate and after filter a signal with a DSP >>>> Filter? >>> >>> From what perspective? It's more work for the processor, does it have >>> the bandwidth to spare? Assuming plenty of processor resources, faster >>> sampling is generally better. >>> >>>> In this last case can you explane me how to write 50Hz Low Pass Filter? >>> >>> Hit the books! Is this for school? If so, ask the prof. If it's for >>> work, or if it's project work, look on Wikipedia, and do some web >>> searches. You need to know if you want to use an IIR or FIR filter (web >>> searches will tell you what those are, and give some guidance of why one >>> or the other will be good), whether you want to decimate (web search), >> etc. >>> >>> If you come up with more questions as you go along, ask. >>> >>> -- >>> Tim Wescott >>> Control system and signal processing consulting >>> www.wescottdesign.com >>> > > Hello > > > > I will try to explane better and if there are errors, please correct > > me. > > My goal is to acquire very low frequency and voltage signal (5Hz-50Hz > > 1mV -2mV) with 10bit DAC. > > > > I have Voltage Reference = 1.1Volt that give me at 10bit 1mV > > resolution. > > So for first thing I have add 3 virtual bit for increase resolution by > > using Oversampling and Decimation Technique: > > > > 'F-cut = 50Hz > > 'F-nyquist = 100Hz > > 'Virtual Bit = 3 > > 'Scale Factor 2^Virtual_Bit = 2^3 = 8 > > 'F-oversampling = ( 4^3 ) * 100 Hz = 64 * 100 = 6400 Hz. > > > > Since I can set only FIX Sample Rate at 9.8 KHz is correct that my > > real f-cut will be 76Hz and not 50Hz? > > Not correct. You must sample *at least* twice as fast as the data's > bandwidth. In other words, the cut-off frequency should be *no more* > than half the sample rate. Actually, one third is good practice.
This may help: http://www.wescottdesign.com/articles/Sampling/sampling.html
> > NOW FILTER > > > > I have read that FIR sync filter sen(x) / x is good low pass filter. > > Is correct that: > > Good for what? A truck is a good vehicle; so is a bicycle. > > > 1) My "Virtual Sample Rate" is 152 HZ and hence Filter f-cut = [0 - > > 0.5] * 152 > > What is virtual sample rate? The reference you cite below deals with > windowed-sinc filters, not resolution or accuracy. > > > For last > > 2) Since I have very few memory on micro, how I must choose M value? > > > > Please do not reply vaguely but use number and value.
(a) Specificity out requires specificity in. (b) Specificity takes more time than most here are willing to deliver. Really specific, number-for-number and code-line for code-line answers are _work_. Some of us are hobbyists with our own pursuits, some of us are retired, and some of us (like me) are professionals. Most of us give answers for the gratification of seeing people learn; it's rare to see one of us doing someone else's work for them. Conclusion: we provide general guidelines, you find number and value.
> > p.s. > > This is the tutorial that I'm reading: > http://www.dspguide.com/ch16/2.htm > > > This isn't going to work. Other conditions being met, the precision > gained by averaging increases with the square root of the number of > measurements. To increase the precision eight times (three bits worth) > you need to average 64 (8^2) measurements. Even at that rate, it > probably won't work on your processor. To get 13-bit results from a > 10-bit ADC, the converter needs to slice accurately to 13 bits > thresholds. Any converter on a processor chip is most unlikely to be > that good. If the spec sheet doesn't say it is, it isn't. There are > other considerations, but one thing at a time.
To correct Jerry's language, I'd use "accuracy" instead of "precision". Think of shooting a gun at a target range -- "precision" is how closely spread the bullet holes are on the target, "accurate" is how close they are to the bullseye. "Resolution" is the smallest increment that the ADC will deliver, and it is often misleading to equate it with either precision or accuracy. To add to what Jerry is saying, in general the hard part of making a really precise ADC is getting the threshold to be accurate; adding more bits to an ADC is easy. In general, if an ADC has a given number of bits of resolution (i.e. the number of bits it actually gives you), you can expect that the accuracy will be lower. For ADCs with high bit counts (14 or more for SAR types) you can expect that there will be noise with an amplitude of several LSBs, so the precision of any one measurement won't be good, but you _will_ be able to average readings for more accuracy. * But you can tease the TI app engineers with it. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com
On Jun 17, 5:23&#2013266080;pm, "gpezzella" <gpezzella@n_o_s_p_a_m.yahoo.com>
wrote:

> In this last case can you explane me how to write 50Hz Low Pass Filter? > > Thanks
use a simple RC equivalent filter, the equation is output = a*input +(1-a)*previous_output a = samplerate/(RC + samplerate) your samplerate you pick, the RC is a constant and it determines your cutoff cutoff frequency = 1/2piRC hz so 50 hz = 1/2piRC, solve for RC and stick in the equation above
Dear Friends

My application should detect signal that come from MicroWave cavity (the
one used in alarm).
When people walk in front a MW, a little signal of few mV and frequency
between 10-50Hz is generated. I should detect this!

I'm developing on ATTiny micro family. Now: 

a) Since AtTiny have 20x amplifier buit in, instead of add 3 new bit by
Oversampling and Decimation is better first amplify the signal and use the
basic 10 bit ADC?

b) After I have acquired the sample I must always filter it by FIR filter
like sen(x)/x with cut frequency = 50 Hz?

c) For understand if someone have walk in front MW I can stop here o must
do a FFT? 

d) Return to point b, which are the minimum point I must acquire and the
minimum value of M. I don't have experience in this and the memory of
ATTINY is very little.

Thanks


 
On 6/18/2010 12:08 PM, gpezzella wrote:
> Dear Friends > > My application should detect signal that come from MicroWave cavity (the > one used in alarm).
Start over from the beginning. What frequency is your microwave signal? What is the highest frequency that your hardware can respond to?
> When people walk in front a MW, a little signal of few mV and frequency > between 10-50Hz is generated. I should detect this!
10-50Hz is hardly microwave. Is it a beat frequency? How is this signal connected to the chip?
> I'm developing on ATTiny micro family. Now: > > a) Since AtTiny have 20x amplifier buit in, instead of add 3 new bit by > Oversampling and Decimation is better first amplify the signal and use the > basic 10 bit ADC? > > b) After I have acquired the sample I must always filter it by FIR filter > like sen(x)/x with cut frequency = 50 Hz?
Anti-alias filtering needs to be done *before* sampling.
> c) For understand if someone have walk in front MW I can stop here o must > do a FFT?
What does an FFT do for you?
> d) Return to point b, which are the minimum point I must acquire and the > minimum value of M. I don't have experience in this and the memory of > ATTINY is very little.
What is M? Jerry -- Engineering is the art of making what you want from things you can get. &#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;&#2013266095;
On 06/18/2010 09:08 AM, gpezzella wrote:
> Dear Friends > > My application should detect signal that come from MicroWave cavity (the > one used in alarm). > When people walk in front a MW, a little signal of few mV and frequency > between 10-50Hz is generated. I should detect this! > > I'm developing on ATTiny micro family. Now: > > a) Since AtTiny have 20x amplifier buit in, instead of add 3 new bit by > Oversampling and Decimation is better first amplify the signal and use the > basic 10 bit ADC?
You're not giving enough information for anyone to make that determination. Normally you want to amplify the signal as high as you can without it exceeding the amplitude that the ADC can handle, or hitting the rails of the ADC. But sometimes you do.
> b) After I have acquired the sample I must always filter it by FIR filter > like sen(x)/x with cut frequency = 50 Hz?
What gives you that idea?
> c) For understand if someone have walk in front MW I can stop here o must > do a FFT?
An FFT would probably be overkill.
> d) Return to point b, which are the minimum point I must acquire and the > minimum value of M. I don't have experience in this and the memory of > ATTINY is very little.
Minimum point what? What's M? Your problems go beyond just your low-pass filter: your entire system design is vague. Because the filter is only part of all the design tradeoffs you must make, you'll never pin down what the "best" filter is, because every time you change other parts of the system design -- or even your goals about what you want out of the system -- what the "best" filter is will change. I think at this point you want to start trying things, and see how they go. -- Tim Wescott Control system and signal processing consulting www.wescottdesign.com