0
$\begingroup$

I am a student working with digital circuits. I just started a term project with someone else working on an ADC. I need to design a IIR filter in verilog.

If the output of an ADC represents 1V by setting all output bits to '1' and 0V by all bits to '0', and I wanted to use a fixed point scheme for the filter coefficients, what do I expect from the output signals? I am a little confused about:

  1. Is the ADC output a fixed-point format, or it shouldn't be considered as any format?
  2. What does the output of my filter represent? If some of the coefficients are negative, what does a negative output mean?
  3. If the coefficients are represented in Q6.10 format for example, does the output need to be shifted?

Sorry if the questions seem quite naive, I have very limited exposure with DSP. Thanks.

$\endgroup$

3 Answers 3

0
$\begingroup$

Fixed point processing especially for IIR filters is quite complicated.

The main challenges are

  1. Make sure you don't overflow or clip for all filter coefficients and signal types.
  2. Make sure you end up with sufficient signal to noise ratio for your application
  3. Avoid spurious artifacts like limit cycles.

Some general rules that make this easier:

  1. Implement your IIR as cascaded second order sections.
  2. Use Direct Form I (safest and easiest) or Transposed Form II structures. Do NOT use Transposed Form I or Direct Form II.
  3. Use a double width accumulator for each section if you have it
  4. Throw a few extra bits at it if you can. Optimizing the bit width down to the last bit is an enormous amount of work.

Is the ADC output a fixed-point format, or it shouldn't be considered as any format?

It's fixed point format. Most common is 2's complement.

What does the output of my filter represent? If some of the coefficients are negative, what does a negative output mean?

Your output is the convolution of the input signal with the impulse response of the filter. And yes, both coefficient and the output can be negative unless you design your filter specifically to avoid that.

If the coefficients are represented in Q6.10 format for example, does the output need to be shifted?

Generally you try to shift your output and ANY intermediate result and state variable so that it can be as large as possible without clipping.

$\endgroup$
0
$\begingroup$

As far as I know now, most ADC and DAC chips communicate to their CPU or DSP chip over a serial protocol with 3 wires (word/frame clock, bit clock, data) and the data is represented as a twos-complement integer. But you should consult the spec sheet of the ADC/DAC chip and get all of the particulars. Representations such as Q6.10 or such really are in the mind of the programmer. The fixed-point twos-complement bits are exactly the same whether you consider it Q1.15 or Q2.14 or Q6.10 . That scaling factor is up to the programmer.

Now the Q scaling of the coefficients, that's a little different. That gets defined by the way you extract the 16-bit result out of the 32-bit words that result when you multiply two 16-bit numbers together. You really do have to consider that in advance.

If you're doing an IIR, numerical issues can get a little funky and you do need to worry about them. Maybe this answer will give you some insight in how to think about doing fixed-point IIR.

$\endgroup$
0
$\begingroup$

Is the ADC output a fixed-point format, or it shouldn't be considered as any format?

Without a format, the ADC output would be meaningless ones and zeros (or voltage levels, because mapping from a voltage to a 1 or a 0 is part of the format).

So -- yes, there's a format there. It's probably simple unsigned binary, but part of the format that you need to know is where the MSB, LSB, and all the significant bits in between are.

What does the output of my filter represent?

That depends on your system. You know what's feeding the ADC -- you should be able to figure out (or ask) what the voltage applied to the ADC means. From that you can figure out what the number out of the ADC means. From that, and the nature of the filter, then you can figure out what the number out of the filter means.

For instance, if the voltage going into the ADC came from a water level meter of some pond that's open to the air, then you'd expect a signal that averages out to the actual liquid level in the pond, but that would have some chop on windy days. From that, you could deduce that perhaps you need a low-pass filter to get just the average liquid level while ignoring the chop -- and you could figure out the correct scaling for your filter output to get the pond level into feet or meters or cubits or whatever.

If some of the coefficients are negative, what does a negative output mean?

First, you can have negative coefficients and a filter that's well-damped enough that for non-negative inputs the output never goes negative.

Second, there's a lot of reasons a filter output may go negative, so "what does it mean?" is vague. If it's supposed to be a low-pass filter, it means you have some overshoot, but what it means is a system-level question that you need to answer. On the other hand, if it's a high-pass filter then of course the output will go negative, because a high-pass filter, by definition, has a zero average so any positive excursion demands a negative excursion to even things out.

If the coefficients are represented in Q6.10 format for example, does the output need to be shifted?

Again, this is a system question, and it really has more to do with the filter's transfer function and what the desired output of the filter is than with the details of the coefficients. If it's a low-pass filter and you want it to be scaled the same as the ADC input and it has a DC gain of 1 -- no, you don't have to shift the output. This could happen with coefficents that are Q6.10, Q2.14, Q1.15 or many other Qwhatever.whatever.

You need to find your filter's transfer function, and find out what it's supposed to be doing -- then you'll know.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.