# A lowpass filter for a DAC

Started by November 11, 2021
```Hi All,

I am trying to work out the likely phase lag for a lowpass filter
whose job is to take out the notches from a DAC.

The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
driven at around 250x i.e. 100kHz. So the fundamental to filter out
will be 100kHz.

I am not good at maths but doing some digging around, it looks like a
simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
around 1 degree when a factor of 100 away from that (40kHz).

I am happy with 1-2 degrees of lag, but more importantly it needs to
be fairly constant from 400Hz to 500Hz, or at least quantifiable,
because the table feeding the DAC can be shifted to compensate.

What about a 2nd order filter? The filter performance should be better
for a given phase lag, no?

Obviously perfection is impossible to achieve but I think a 10kHz
rolloff frequency would produce a really clean result. The Q is what
delay can be achieved at that rolloff.

There is a huge amount of stuff online but a lot of it is the audio
stuff, which is full of BS :)
```
```On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
wrote:

>Hi All,
>
>I am trying to work out the likely phase lag for a lowpass filter
>whose job is to take out the notches from a DAC.
>
>The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>driven at around 250x i.e. 100kHz. So the fundamental to filter out
>will be 100kHz.
>
>I am not good at maths but doing some digging around, it looks like a
>simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>around 1 degree when a factor of 100 away from that (40kHz).
>
>I am happy with 1-2 degrees of lag, but more importantly it needs to
>be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>because the table feeding the DAC can be shifted to compensate.
>
>What about a 2nd order filter? The filter performance should be better
>for a given phase lag, no?

Much better. 2nd order lets you place the -3 dB frequency much higher
than 1st order. You can run a program like FilterPro to get the
curves.

The classic Williams book has graphs of attenuation and phase shift
too.

250x should be easy. 3x needs more serious filtering.

--

Father Brown's figure remained quite dark and still;
always most valuable when he had lost it.

```
```Jan Panteltje <pNaOnStPeAlMtje@yahoo.com> wrote

>>There is a huge amount of stuff online but a lot of it is the audio
>>stuff, which is full of BS :)
>
>http://sim.okawa-denshi.jp/en/CRCRkeisan.htm
>?

Thank you. That looks like both a 1st order and a 2nd order passive
lowpass, with 40kHz values (10k/400pF etc) will achieve ~ 0.5 degree
of phase shift.
```
```On 11/11/2021 1:08 PM, jlarkin@highlandsniptechnology.com wrote:
> On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
> wrote:
>
>> Hi All,
>>
>> I am trying to work out the likely phase lag for a lowpass filter
>> whose job is to take out the notches from a DAC.
>>
>> The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>> driven at around 250x i.e. 100kHz. So the fundamental to filter out
>> will be 100kHz.
>>
>> I am not good at maths but doing some digging around, it looks like a
>> simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>> around 1 degree when a factor of 100 away from that (40kHz).
>>
>> I am happy with 1-2 degrees of lag, but more importantly it needs to
>> be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>> because the table feeding the DAC can be shifted to compensate.
>>
>> What about a 2nd order filter? The filter performance should be better
>> for a given phase lag, no?
>
> Much better. 2nd order lets you place the -3 dB frequency much higher
> than 1st order. You can run a program like FilterPro to get the
> curves.
>
> The classic Williams book has graphs of attenuation and phase shift
> too.
>
> 250x should be easy. 3x needs more serious filtering.
>
>
>

Getting 1/2 of one LSB of 12 bits worth of rejection at 100kHz, -75dB,
and meanwhile just 1 degree of phase lag at 400 Hz, is going to be a
real challenge with only 2 poles I think, if I'm understanding their
requirements correct.

So I think OP needs to specify how much fundamental rejection is
acceptable or I think higher order than that will be needed.
```
```On 11/11/2021 2:00 PM, bitrex wrote:
> On 11/11/2021 1:08 PM, jlarkin@highlandsniptechnology.com wrote:
>> On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> I am trying to work out the likely phase lag for a lowpass filter
>>> whose job is to take out the notches from a DAC.
>>>
>>> The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>>> driven at around 250x i.e. 100kHz. So the fundamental to filter out
>>> will be 100kHz.
>>>
>>> I am not good at maths but doing some digging around, it looks like a
>>> simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>>> around 1 degree when a factor of 100 away from that (40kHz).
>>>
>>> I am happy with 1-2 degrees of lag, but more importantly it needs to
>>> be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>>> because the table feeding the DAC can be shifted to compensate.
>>>
>>> What about a 2nd order filter? The filter performance should be better
>>> for a given phase lag, no?
>>
>> Much better. 2nd order lets you place the -3 dB frequency much higher
>> than 1st order. You can run a program like FilterPro to get the
>> curves.
>>
>> The classic Williams book has graphs of attenuation and phase shift
>> too.
>>
>> 250x should be easy. 3x needs more serious filtering.
>>
>>
>>
>
> Getting 1/2 of one LSB of 12 bits worth of rejection at 100kHz, -75dB,
> and meanwhile just 1 degree of phase lag at 400 Hz, is going to be a
> real challenge with only 2 poles I think, if I'm understanding their
> requirements correct.
>
> So I think OP needs to specify how much fundamental rejection is
> acceptable or I think higher order than that will be needed.

My bad, neglect that, I'm thinking of PWM DACs! Just need to attenuate
the sinc-weighted component of the switching frequency which will be
```
```On Thu, 11 Nov 2021 14:00:14 -0500, bitrex <user@example.net> wrote:

>On 11/11/2021 1:08 PM, jlarkin@highlandsniptechnology.com wrote:
>> On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
>> wrote:
>>
>>> Hi All,
>>>
>>> I am trying to work out the likely phase lag for a lowpass filter
>>> whose job is to take out the notches from a DAC.
>>>
>>> The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>>> driven at around 250x i.e. 100kHz. So the fundamental to filter out
>>> will be 100kHz.
>>>
>>> I am not good at maths but doing some digging around, it looks like a
>>> simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>>> around 1 degree when a factor of 100 away from that (40kHz).
>>>
>>> I am happy with 1-2 degrees of lag, but more importantly it needs to
>>> be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>>> because the table feeding the DAC can be shifted to compensate.
>>>
>>> What about a 2nd order filter? The filter performance should be better
>>> for a given phase lag, no?
>>
>> Much better. 2nd order lets you place the -3 dB frequency much higher
>> than 1st order. You can run a program like FilterPro to get the
>> curves.
>>
>> The classic Williams book has graphs of attenuation and phase shift
>> too.
>>
>> 250x should be easy. 3x needs more serious filtering.
>>
>>
>>
>
>Getting 1/2 of one LSB of 12 bits worth of rejection at 100kHz, -75dB,
>and meanwhile just 1 degree of phase lag at 400 Hz, is going to be a
>real challenge with only 2 poles I think, if I'm understanding their
>requirements correct.
>
>So I think OP needs to specify how much fundamental rejection is
>acceptable or I think higher order than that will be needed.

Given a 12-bit DAC making a 500 Hz sine wave at 100K samples/second,
it will look perfect on a scope, with no filter. It would look awfully
good on a spectrum analyzer too. It doesn't need much filtering.

Good thing to Spice. I have a quantizer block around here somewhere.

--

If a man will begin with certainties, he shall end with doubts,
but if he will be content to begin with doubts he shall end in certainties.
Francis Bacon
```
```On 11/11/2021 4:45 PM, John Larkin wrote:
> On Thu, 11 Nov 2021 14:00:14 -0500, bitrex <user@example.net> wrote:
>
>> On 11/11/2021 1:08 PM, jlarkin@highlandsniptechnology.com wrote:
>>> On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> I am trying to work out the likely phase lag for a lowpass filter
>>>> whose job is to take out the notches from a DAC.
>>>>
>>>> The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>>>> driven at around 250x i.e. 100kHz. So the fundamental to filter out
>>>> will be 100kHz.
>>>>
>>>> I am not good at maths but doing some digging around, it looks like a
>>>> simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>>>> around 1 degree when a factor of 100 away from that (40kHz).
>>>>
>>>> I am happy with 1-2 degrees of lag, but more importantly it needs to
>>>> be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>>>> because the table feeding the DAC can be shifted to compensate.
>>>>
>>>> What about a 2nd order filter? The filter performance should be better
>>>> for a given phase lag, no?
>>>
>>> Much better. 2nd order lets you place the -3 dB frequency much higher
>>> than 1st order. You can run a program like FilterPro to get the
>>> curves.
>>>
>>> The classic Williams book has graphs of attenuation and phase shift
>>> too.
>>>
>>> 250x should be easy. 3x needs more serious filtering.
>>>
>>>
>>>
>>
>> Getting 1/2 of one LSB of 12 bits worth of rejection at 100kHz, -75dB,
>> and meanwhile just 1 degree of phase lag at 400 Hz, is going to be a
>> real challenge with only 2 poles I think, if I'm understanding their
>> requirements correct.
>>
>> So I think OP needs to specify how much fundamental rejection is
>> acceptable or I think higher order than that will be needed.
>
> Given a 12-bit DAC making a 500 Hz sine wave at 100K samples/second,
> it will look perfect on a scope, with no filter. It would look awfully
> good on a spectrum analyzer too. It doesn't need much filtering.
>
> Good thing to Spice. I have a quantizer block around here somewhere.
>

Agreed, I have PWM on the mind. The 100k isn't full amplitude it's just
the steppies.

```
``` John Larkin wrote:
===================
>
>
> Given a 12-bit DAC making a 500 Hz sine wave at 100K samples/second,
> it will look perfect on a scope, with no filter.

** Not on good analog one, with a sharp trace.

> It would look awfully
> good on a spectrum analyzer too. It doesn't need much filtering.

** Must know the app to say if harmonics or a small phase shift really matter.

But JP will never let that secret out of his bag.

.....  Phil

```
```On 11/11/2021 4:45 PM, John Larkin wrote:
> On Thu, 11 Nov 2021 14:00:14 -0500, bitrex <user@example.net> wrote:
>
>> On 11/11/2021 1:08 PM, jlarkin@highlandsniptechnology.com wrote:
>>> On Thu, 11 Nov 2021 16:13:52 +0000, Peter <nospam@nospam9876.com>
>>> wrote:
>>>
>>>> Hi All,
>>>>
>>>> I am trying to work out the likely phase lag for a lowpass filter
>>>> whose job is to take out the notches from a DAC.
>>>>
>>>> The DAC is 12 bit and will be generating a 400Hz sinewave. It will be
>>>> driven at around 250x i.e. 100kHz. So the fundamental to filter out
>>>> will be 100kHz.
>>>>
>>>> I am not good at maths but doing some digging around, it looks like a
>>>> simple RC has a 45 deg phase shift at the 1/2piRC point, and somewhere
>>>> around 1 degree when a factor of 100 away from that (40kHz).
>>>>
>>>> I am happy with 1-2 degrees of lag, but more importantly it needs to
>>>> be fairly constant from 400Hz to 500Hz, or at least quantifiable,
>>>> because the table feeding the DAC can be shifted to compensate.
>>>>
>>>> What about a 2nd order filter? The filter performance should be better
>>>> for a given phase lag, no?
>>>
>>> Much better. 2nd order lets you place the -3 dB frequency much higher
>>> than 1st order. You can run a program like FilterPro to get the
>>> curves.
>>>
>>> The classic Williams book has graphs of attenuation and phase shift
>>> too.
>>>
>>> 250x should be easy. 3x needs more serious filtering.
>>>
>>>
>>>
>>
>> Getting 1/2 of one LSB of 12 bits worth of rejection at 100kHz, -75dB,
>> and meanwhile just 1 degree of phase lag at 400 Hz, is going to be a
>> real challenge with only 2 poles I think, if I'm understanding their
>> requirements correct.
>>
>> So I think OP needs to specify how much fundamental rejection is
>> acceptable or I think higher order than that will be needed.
>
> Given a 12-bit DAC making a 500 Hz sine wave at 100K samples/second,
> it will look perfect on a scope, with no filter. It would look awfully
> good on a spectrum analyzer too. It doesn't need much filtering.
>
> Good thing to Spice. I have a quantizer block around here somewhere.
>

In fact if you can clock at 250x but only need 400 Hz question is why
you need a 12 bit DAC in the first place, you could do pretty good just
by selectively knocking out harmonics before you even go analog e.g.
this old chestnut:

<http://enginuitysystems.com/files/msinexec%20(Magic%20Sinewaves).pdf>
```
```On Thu, 11 Nov 2021 15:12:58 -0800 (PST), Phil Allison
<pallison49@gmail.com> wrote:

> John Larkin wrote:
>===================
>>
>>
>> Given a 12-bit DAC making a 500 Hz sine wave at 100K samples/second,
>> it will look perfect on a scope, with no filter.
>
>** Not on good analog one, with a sharp trace.

I'd expect that if the sine wave fits on the screen, you wouldn't see
the stairsteps.

How many spot diameters fit on one screen? Surely not 4000.

--

If a man will begin with certainties, he shall end with doubts,
but if he will be content to begin with doubts he shall end in certainties.
Francis Bacon
```