Computing > Embedded Computing

FIR FILTER

(1/1)

**lorenrus**:

Hello everybody

I'm here to ask you for your opinion.

in practice I have an ADC that has its own reference voltage. To this reference voltage, when the temperature reaches a certain value, a ripple of 128mVpp and a freq equal to 10khz are added. The data that the ADC converts, including the core temperature, I send them over the CAN to view. But when you add this ripple the values that are plotted are out of order.

I cannot add a HW filter to the reference output because the card has already been made.

A colleague proposed to put a FIR filter on the samples converted by the ADC, before being sent over CAN. But in my opinion this does not make sense, because I apply the filter on an analog signal which I then sample and filter and not on digital samples?

Quite right ?

Thank you

**Siwastaja**:

Well, if the error signal is always reliably at 10kHz, and you can guarantee no other errors happen - this is very strange, by the way; you should try to eliminate the 10kHz error signal to begin with -;

then indeed a FIR filter would be excellent at filtering that 10kHz away. Of course assuming no signal of interest is near that frequency.

For this to be possible, the ADC needs to sample at very least at 20ksamples/s (so that Nyquist is at 10kHz) but more is preferable.

I'm assuming you have no interesting content above 10kHz, so you need a lowpass. Design the FIR in Matlab or Octave or with some online tool, apply to the ADC samples, send through CAN.

A so-called decimating FIR filter may be what you need if you don't want to output 20ksamples/s to CAN which would hog all your CAN bandwidth.

Decimating FIR filter is like calculating FIR for every sample then dropping some, for example send out only one of eight samples. A specialized "decimating FIR" is an optimization reducing amount of unnecessary CPU work by only calculating those samples that are not removed.

In any case, filtering out an unknown source of error signal which shouldn't exist in the first place is asking for trouble.

**David Hess**:

What sample rate can you achieve?

Even if your sample rate is too low to prevent aliasing, you may be able to filter out the interference if it is sufficiently narrow. How stable is the 10kHz ripple?

**gf**:

In the first place I'd analyze the signal in the frequency domain, i.e. capture a sequence of contiguous samples (as may as you can buffer, say a few thousand - the more the better), save them into a file and and do a FFT (in Matlab, Octave, numpy, or howsowever). Then you will see which frequency regions are actually "polluted", and you have a basis for designing the filter.

Edit: What is the sampling rate? And what is the desired bandwidth of the wandted signal? If the frequency components of the ripple1) happen to overlap with the wanted frequencies, then it will be hard to separate them with a filter.

Furthermore, what MCU is it? Is is fast enough to run the filter?

1) after potentially down-folding them to 0...fs/2

**AndyC_772**:

--- Quote from: lorenrus on July 22, 2021, 03:06:49 pm ---To this reference voltage, when the temperature reaches a certain value, a ripple of 128mVpp and a freq equal to 10khz are added

--- End quote ---

When you say "added", is this a deliberate act, or something that just seems to happen for reasons you've not yet identified?

I have a rule; anything you observe but don't understand must be investigated, because if you don't, it'll come back and bite you on the ar*e later on.

I'd start by checking the power supply.

Navigation

[0] Message Index

Go to full version