CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Analog (anti-aliasing) and digital filtering mixed together

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Dargar



Joined: 12 Dec 2003
Posts: 25

View user's profile Send private message

Analog (anti-aliasing) and digital filtering mixed together
PostPosted: Tue Apr 19, 2005 6:04 pm     Reply with quote

I am going to measure a set of (pressure) transducers. The transducers are wildly ringing, and I am only interested in an "averaged" value of the pressure at any time. That is, even if a couple of samples results in 250psi, as long as the "general" pressure is below ~240 psi it should be okay.

My first design iteration was to LP-filter and average, but several questions have cropped up. Following is a more or less detailed description of my analysis so far:

PIC18F6520 @40MHz
12 ADC channels @10bit resolution

4 Samples/channel then move to next channel (@31192samples/sec)
Various code, averaging and other tasks: estimated total of 2786 instructions
--> Sample all 12 channels and then do 2786 cycles of program takes (as far as I know) 0.8966ms (ADC) + 0.2786ms (program cycles) = 1.1752ms

---------
First question:

Even though the samples are taken at ~30k samples\second, they are only repeated every ~1.2 ms. This gives a REAL sample rate of 850 Hz, and I should use 850Hz as the sample rate when I calculate my filters OR?
(I use Microchip's free tool FilterLab2.0 to do all my filters. I use the anti-aliasing filter wizard.)


--------------
The filter

*I put 10Hz as the Passband Frequency since I am only interested in the slower changes to pressure.

*I put 850Hz as sample-rate and 10bit as the resolution (which gives a -61dB stop-band attenuation)

== The result is a 2'nd order Butterworth

-------------
Second question:

Is it necessary to average over for example 4 samples in quick succession when I use an active filter such as the one above prior to sampling the signal?


---------------
Third and final question:

Will this design do what I want it to do?
I need to system to react to "out of bounds" pressures whithin 100ms of the pressure exceeding the limits. Since I complete some ~850 full "main-loop" cycles \second, that wont pose a problem, BUT

With a treshold of 10Hz on the filters, I am basically creating a delay of 100ms for the signal? OR?? (I would say no, since the filter takes away higher frequency components, but if the signal changes, it changes, or will it actually take 100ms for the analog signal to get its new value at the output of the filter?)

Thought-experiment: Applying a step-change to the amplitude on the filter input, say from 2V to 2.2V, how long will it take before I see 2.2V on the filter output? Will it take ~100ms since the treshold is at 10Hz?


Thank you ever so much for taking the time to read, and hopefully give your two cents on this question!
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Wed Apr 20, 2005 2:03 pm     Reply with quote

Let me clarify:
1) You are taking a burst of four 10 bit samples at 30k samples/sec with 1.2ms between bursts.
2) You need to respond to a fault condition in 100ms.

Based on that:
1) I would just sum the four readings to get one 12 bit sample every 1.2ms or 850Hz. There is no need do the division at the end. Or you could sum the four keeping track of the highest and lowest of the four and subtract them out. In a previous thread I called this "Olympic Scoring" comparing it to some judged events where the highest and lowest judges scores are removed. It is a good technique for removing outlyers that does not require multiplication, division, or sorting. If you know your outlyers will only be high or only be low you can simplify by only looking for odd values on one side.
2) Since you need an answer in 100ms I would set the bandpass at something higher than 10Hz. By rule of thumb I would start at 3 x 10Hz = 30Hz. Your filter software may give you more accurate delay figures.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

Re: Analog (anti-aliasing) and digital filtering mixed toget
PostPosted: Thu Apr 21, 2005 3:41 pm     Reply with quote

Dargar wrote:

Thank you ever so much for taking the time to read, and hopefully give your two cents on this question!


There is a thread in the Code Library on filtering with several options.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group