Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > sci.electronics.design > #505889 > unrolled thread

square wave to sine filter

Started byJohn Larkin <jjlarkin@highlandtechnology.com>
First post2018-05-19 10:31 -0700
Last post2018-05-20 01:41 -0400
Articles 16 — 5 participants

Back to article view | Back to sci.electronics.design


Contents

  square wave to sine filter John Larkin <jjlarkin@highlandtechnology.com> - 2018-05-19 10:31 -0700
    Re: square wave to sine filter George Herold <gherold@teachspin.com> - 2018-05-19 15:17 -0700
    Re: square wave to sine filter "Tim Williams" <tiwill@seventransistorlabs.com> - 2018-05-19 18:46 -0500
      Re: square wave to sine filter bitrex <user@example.net> - 2018-05-19 21:09 -0400
      Re: square wave to sine filter John Larkin <jjlarkin@highlandtechnology.com> - 2018-05-19 18:34 -0700
    Re: square wave to sine filter bitrex <user@example.net> - 2018-05-19 21:04 -0400
      Re: square wave to sine filter John Larkin <jjlarkin@highlandtechnology.com> - 2018-05-19 18:32 -0700
      Re: square wave to sine filter "Tim Williams" <tiwill@seventransistorlabs.com> - 2018-05-19 23:37 -0500
        Re: square wave to sine filter bitrex <user@example.net> - 2018-05-20 01:47 -0400
        Re: square wave to sine filter John Larkin <jjlarkin@highlandtechnology.com> - 2018-05-20 08:35 -0700
    Re: square wave to sine filter bill.sloman@ieee.org - 2018-05-19 19:20 -0700
      Re: square wave to sine filter bitrex <user@example.net> - 2018-05-19 22:56 -0400
        Re: square wave to sine filter bill.sloman@ieee.org - 2018-05-19 20:49 -0700
        Re: square wave to sine filter "Tim Williams" <tiwill@seventransistorlabs.com> - 2018-05-19 23:47 -0500
          Re: square wave to sine filter bitrex <user@example.net> - 2018-05-20 01:33 -0400
            Re: square wave to sine filter bitrex <user@example.net> - 2018-05-20 01:41 -0400

#505889 — square wave to sine filter

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2018-05-19 10:31 -0700
Subjectsquare wave to sine filter
Message-ID<d0n0gdhcfmsiukt0eufh92ovlnh0kfa24v@4ax.com>
https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1

Input is a PWM square wave from an ARM. This makes a nice looking
sine, 3rd harmonic down almost 40 dB.

It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
better than an equivalent-part active bandpass. Maybe the bandpass
wastes resources rejecting stuff below the fundamental, where there is
nothing to reject.


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [next] | [standalone]


#505913

FromGeorge Herold <gherold@teachspin.com>
Date2018-05-19 15:17 -0700
Message-ID<4249eda4-1ee7-44de-b74b-4e5c3557a03d@googlegroups.com>
In reply to#505889
On Saturday, May 19, 2018 at 1:31:59 PM UTC-4, John Larkin wrote:
> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
> 
> Input is a PWM square wave from an ARM. This makes a nice looking
> sine, 3rd harmonic down almost 40 dB.
> 
> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
> better than an equivalent-part active bandpass. Maybe the bandpass
> wastes resources rejecting stuff below the fundamental, where there is
> nothing to reject.
Yeah the bandpass falls off half as fast at high freq.

George H. 
> 
> 
> -- 
> 
> John Larkin         Highland Technology, Inc
> 
> lunatic fringe electronics

[toc] | [prev] | [next] | [standalone]


#505918

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2018-05-19 18:46 -0500
Message-ID<pdqd02$626$1@dont-email.me>
In reply to#505889
Well, yeah...

You can do even better by adding an RC in front for 3rd order.  Ceramic chip 
caps are cheap.  Well, they used to be.

Even better still with an elliptical, with the notch at the fundamental (if 
you're doing PWMDAC) or harmonic (otherwise*).  But this requires another 
op-amp, so meh.  Handy and cheap with discretes at RF, though.

*If you're doing PWM, that implies duty other than 50% _as a fundamental 
feature of operation_, in which case you get 2nd harmonic too.  If it's 
constant 50%, it's not really PWM, is it?  It's just a flat, dumb square 
wave oscillator.  And of course, woe be unto anyone who wants more than a 
little adjustable frequency range. :-)

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Contract Design
Website: https://www.seventransistorlabs.com/

"John Larkin" <jjlarkin@highlandtechnology.com> wrote in message 
news:d0n0gdhcfmsiukt0eufh92ovlnh0kfa24v@4ax.com...
>
> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
>
> Input is a PWM square wave from an ARM. This makes a nice looking
> sine, 3rd harmonic down almost 40 dB.
>
> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
> better than an equivalent-part active bandpass. Maybe the bandpass
> wastes resources rejecting stuff below the fundamental, where there is
> nothing to reject.
>
>
> -- 
>
> John Larkin         Highland Technology, Inc
>
> lunatic fringe electronics
> 

[toc] | [prev] | [next] | [standalone]


#505931

Frombitrex <user@example.net>
Date2018-05-19 21:09 -0400
Message-ID<yV3MC.41654$IF4.34948@fx14.iad>
In reply to#505918
On 05/19/2018 07:46 PM, Tim Williams wrote:
> Well, yeah...
> 
> You can do even better by adding an RC in front for 3rd order.  Ceramic 
> chip caps are cheap.  Well, they used to be.
> 
> Even better still with an elliptical, with the notch at the fundamental 
> (if you're doing PWMDAC) or harmonic (otherwise*).  But this requires 
> another op-amp, so meh.  Handy and cheap with discretes at RF, though.
> 
> *If you're doing PWM, that implies duty other than 50% _as a fundamental 
> feature of operation_, in which case you get 2nd harmonic too.  If it's 
> constant 50%, it's not really PWM, is it?  It's just a flat, dumb square 
> wave oscillator.  And of course, woe be unto anyone who wants more than 
> a little adjustable frequency range. :-)
> 
> Tim
> 

Making a second-order Sallen-Key filter from an AD8044 is like putting a 
Yugo transmission in a Ferrari please bruh why do this plz

[toc] | [prev] | [next] | [standalone]


#505934

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2018-05-19 18:34 -0700
Message-ID<14k1gdlcai2or7gcihi3cfjvgue52cddn8@4ax.com>
In reply to#505918
On Sat, 19 May 2018 18:46:26 -0500, "Tim Williams"
<tiwill@seventransistorlabs.com> wrote:

>Well, yeah...
>
>You can do even better by adding an RC in front for 3rd order.  Ceramic chip 
>caps are cheap.  Well, they used to be.
>
>Even better still with an elliptical, with the notch at the fundamental (if 
>you're doing PWMDAC) or harmonic (otherwise*).  But this requires another 
>op-amp, so meh.  Handy and cheap with discretes at RF, though.
>
>*If you're doing PWM, that implies duty other than 50% _as a fundamental 
>feature of operation_, in which case you get 2nd harmonic too.  If it's 
>constant 50%, it's not really PWM, is it?  It's just a flat, dumb square 
>wave oscillator.  And of course, woe be unto anyone who wants more than a 
>little adjustable frequency range. :-)
>
>Tim

The ARM people call this a PWM output. We'll program a square wave.


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#505930

Frombitrex <user@example.net>
Date2018-05-19 21:04 -0400
Message-ID<HQ3MC.183853$w94.178864@fx43.iad>
In reply to#505889
On 05/19/2018 01:31 PM, John Larkin wrote:
> 
> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
> 
> Input is a PWM square wave from an ARM. This makes a nice looking
> sine, 3rd harmonic down almost 40 dB.

10 bit i2c DACs are so cheap, that's a $4 op amp or something bruh

> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
> better than an equivalent-part active bandpass. Maybe the bandpass
> wastes resources rejecting stuff below the fundamental, where there is
> nothing to reject.


The Sallen-Key topology is geared to be economical, not for stellar 
performance, and the Sallen-Key bandpass is the suckiest performer of 
the bunch.

[toc] | [prev] | [next] | [standalone]


#505933

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2018-05-19 18:32 -0700
Message-ID<1aj1gd5e39fk9bh8t0kpu5rmt97ad2ep34@4ax.com>
In reply to#505930
On Sat, 19 May 2018 21:04:38 -0400, bitrex <user@example.net> wrote:

>On 05/19/2018 01:31 PM, John Larkin wrote:
>> 
>> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
>> 
>> Input is a PWM square wave from an ARM. This makes a nice looking
>> sine, 3rd harmonic down almost 40 dB.
>
>10 bit i2c DACs are so cheap, that's a $4 op amp or something bruh

I couldn't persuade my ARM guy to pump out DAC data fast enough to
make a 10KHz sine wave. We have done it at 400 Hz, basically software
DDS.


>
>> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
>> better than an equivalent-part active bandpass. Maybe the bandpass
>> wastes resources rejecting stuff below the fundamental, where there is
>> nothing to reject.
>
>
>The Sallen-Key topology is geared to be economical, not for stellar 
>performance, and the Sallen-Key bandpass is the suckiest performer of 
>the bunch.

This works better than a bandpass. The high-Q S-K lowpass filter isn't
commonly seen. It has a gain peak at 10 KHz, which improves the sine
wave a lot. I'd go for higher Q and a better sine wave, but tolerances
would get tricky. The sine wave looks great.

This lowpass config has a 90 degree phase shift at the gain peak,
unlike a bandpass that's 0 degrees. So one of these plus an XOR or a
multiplier makes a really nice quadrature FM disciminator.

The dual AD8034 costs about $2. I have a mess of them on my board
already. Really a nice amp. In my business, it's more important that
things be reliable, and be done, than what the parts cost.


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#505945

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2018-05-19 23:37 -0500
Message-ID<pdqu2j$uec$1@dont-email.me>
In reply to#505930
"bitrex" <user@example.net> wrote in message 
news:HQ3MC.183853$w94.178864@fx43.iad...
> 10 bit i2c DACs are so cheap, that's a $4 op amp or something bruh
>

As long as you're feelin' memey tonight bro, you might enjoy this
https://i.imgur.com/4Yqzo5m.jpg

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Contract Design
Website: https://www.seventransistorlabs.com/ 

[toc] | [prev] | [next] | [standalone]


#505950

Frombitrex <user@example.net>
Date2018-05-20 01:47 -0400
Message-ID<uZ7MC.92744$pK.30126@fx13.iad>
In reply to#505945
On 05/20/2018 12:37 AM, Tim Williams wrote:
> "bitrex" <user@example.net> wrote in message 
> news:HQ3MC.183853$w94.178864@fx43.iad...
>> 10 bit i2c DACs are so cheap, that's a $4 op amp or something bruh
>>
> 
> As long as you're feelin' memey tonight bro, you might enjoy this
> https://i.imgur.com/4Yqzo5m.jpg
> 
> Tim
> 

My first real PC was a 386SX at 16MHz with 1 meg of RAM. I upgraded it 
to two eventually. It ran Wing Commander and Wolfenstein 3D okay but 
Doom was out of the question (4 meg RAM required, also.)

Never owned a 486 I jumped straight to a first gen Pentium around '97 or 
so. We got good value out of the 386 though it served as an email 
machine for my late father, happily running Windows 3.1 until probably 
around 2002!

[toc] | [prev] | [next] | [standalone]


#505980

FromJohn Larkin <jjlarkin@highlandtechnology.com>
Date2018-05-20 08:35 -0700
Message-ID<8953gd1lba8dphmmh8rmlghjdg2lbqm2m5@4ax.com>
In reply to#505945
On Sat, 19 May 2018 23:37:55 -0500, "Tim Williams"
<tiwill@seventransistorlabs.com> wrote:

>"bitrex" <user@example.net> wrote in message 
>news:HQ3MC.183853$w94.178864@fx43.iad...
>> 10 bit i2c DACs are so cheap, that's a $4 op amp or something bruh
>>
>
>As long as you're feelin' memey tonight bro, you might enjoy this
>https://i.imgur.com/4Yqzo5m.jpg
>
>Tim

Those purple ceramic 486's make excellent X-acto blade sharpeners.


-- 

John Larkin         Highland Technology, Inc

lunatic fringe electronics 

[toc] | [prev] | [next] | [standalone]


#505938

Frombill.sloman@ieee.org
Date2018-05-19 19:20 -0700
Message-ID<e4f45bb6-6c18-4d2a-9073-c31b4dc848c0@googlegroups.com>
In reply to#505889
On Sunday, May 20, 2018 at 3:31:59 AM UTC+10, John Larkin wrote:
> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
> 
> Input is a PWM square wave from an ARM. This makes a nice looking
> sine, 3rd harmonic down almost 40 dB.
> 
> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
> better than an equivalent-part active bandpass. Maybe the bandpass
> wastes resources rejecting stuff below the fundamental, where there is
> nothing to reject.

If you have a DAC in the ARM you can start off with a much better approximation to a 10kHz sine wave.

Don Lancaster's "magic sine wave" binary sequences have explored the matter at length for purely binary signals, which is presumably what you'd get out of a PWM driver.

If you could tri-state the output of the PWM generator you could generate the usual cheap approximation to a sine wave, which off from 0 degrees to 30 degrees, high from 30 degrees to 150 degrees, off from 150 degrees to 210 degrees, low from 210 degrees to 330 degrees and off again for the last thirty degrees.

No third harmonic content, and the fifth and seventh harmonics are down a bit.

-- 
Bill Sloman, Sydney

[toc] | [prev] | [next] | [standalone]


#505941

Frombitrex <user@example.net>
Date2018-05-19 22:56 -0400
Message-ID<Zt5MC.148443$T14.17529@fx44.iad>
In reply to#505938
On 05/19/2018 10:20 PM, bill.sloman@ieee.org wrote:
> On Sunday, May 20, 2018 at 3:31:59 AM UTC+10, John Larkin wrote:
>> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
>>
>> Input is a PWM square wave from an ARM. This makes a nice looking
>> sine, 3rd harmonic down almost 40 dB.
>>
>> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
>> better than an equivalent-part active bandpass. Maybe the bandpass
>> wastes resources rejecting stuff below the fundamental, where there is
>> nothing to reject.
> 
> If you have a DAC in the ARM you can start off with a much better approximation to a 10kHz sine wave.
> 
> Don Lancaster's "magic sine wave" binary sequences have explored the matter at length for purely binary signals, which is presumably what you'd get out of a PWM driver.

I've looked at those papers every once in a while for a decade or so but 
for the life of me I've never once seen him simply post some source code 
that does what the documents say in e.g. portable ANSI C.

> If you could tri-state the output of the PWM generator you could generate the usual cheap approximation to a sine wave, which off from 0 degrees to 30 degrees, high from 30 degrees to 150 degrees, off from 150 degrees to 210 degrees, low from 210 degrees to 330 degrees and off again for the last thirty degrees.
> 
> No third harmonic content, and the fifth and seventh harmonics are down a bit.
> 

[toc] | [prev] | [next] | [standalone]


#505944

Frombill.sloman@ieee.org
Date2018-05-19 20:49 -0700
Message-ID<685e34a5-d090-4767-8f95-41ec86c4146c@googlegroups.com>
In reply to#505941
On Sunday, May 20, 2018 at 12:57:01 PM UTC+10, bitrex wrote:
> On 05/19/2018 10:20 PM, bill.sloman@ieee.org wrote:
> > On Sunday, May 20, 2018 at 3:31:59 AM UTC+10, John Larkin wrote:
> >> https://www.dropbox.com/s/t4fv4gvx9f8hbqd/LPF_Trans.jpg?raw=1
> >>
> >> Input is a PWM square wave from an ARM. This makes a nice looking
> >> sine, 3rd harmonic down almost 40 dB.
> >>
> >> It's a sallen-key lowpass with a 12 dB bump at 10 KHz. It works a lot
> >> better than an equivalent-part active bandpass. Maybe the bandpass
> >> wastes resources rejecting stuff below the fundamental, where there is
> >> nothing to reject.
> > 
> > If you have a DAC in the ARM you can start off with a much better approximation to a 10kHz sine wave.
> > 
> > Don Lancaster's "magic sine wave" binary sequences have explored the matter at length for purely binary signals, which is presumably what you'd get out of a PWM driver.
> 
> I've looked at those papers every once in a while for a decade or so but 
> for the life of me I've never once seen him simply post some source code 
> that does what the documents say in e.g. portable ANSI C.

He wants to sell the sequences. There a very large number of possible sequences - a whole lot more as soon as you move away from 50/60Hz sine waves - and faster  switches allow longer sequences. 

The same customer could buy lots of different sequences, when they'd only pay once for the source code.


<snip>

-- 
Bill Sloman, Sydney

[toc] | [prev] | [next] | [standalone]


#505946

From"Tim Williams" <tiwill@seventransistorlabs.com>
Date2018-05-19 23:47 -0500
Message-ID<pdqukm$6to$1@dont-email.me>
In reply to#505941
"bitrex" <user@example.net> wrote in message 
news:Zt5MC.148443$T14.17529@fx44.iad...
> I've looked at those papers every once in a while for a decade or so but
> for the life of me I've never once seen him simply post some source code
> that does what the documents say in e.g. portable ANSI C.
>

He gives away the source code.

It's in PostScript.

;-)

Incidentally, I've not been too terribly excited about those sequences, 
since as soon as you need a slightly different waveform -- even amplitude --  
the whole thing goes to pot.

It's a perfectly soluble problem today, where you can throw a friggin' dual 
core ARM9 plus FPGA at a stupid power converter, and save all the power 
consumption and cost of that brain on the few points of efficiency you gain 
in turn.

But if you're going to such lengths, it's worthwhile also to spend much more 
time figuring it out yourself, or hiring a guy to.  You can do worse than 
write the solver in Python, and run it on a platform like that.

Or for that matter, fill a ROM table with 256+ precalculated sequences, and 
just let that be that.

More generally, there are optimal-trajectory algorithms in the literature, 
which can run in real time on FPGAs.  That's good for high efficiency audio, 
say.

Tim

-- 
Seven Transistor Labs, LLC
Electrical Engineering Consultation and Contract Design
Website: https://www.seventransistorlabs.com/ 

[toc] | [prev] | [next] | [standalone]


#505948

Frombitrex <user@example.net>
Date2018-05-20 01:33 -0400
Message-ID<oM7MC.204310$br4.41176@fx34.iad>
In reply to#505946
On 05/20/2018 12:47 AM, Tim Williams wrote:
> "bitrex" <user@example.net> wrote in message 
> news:Zt5MC.148443$T14.17529@fx44.iad...
>> I've looked at those papers every once in a while for a decade or so but
>> for the life of me I've never once seen him simply post some source code
>> that does what the documents say in e.g. portable ANSI C.
>>
> 
> He gives away the source code.
> 
> It's in PostScript.
> 
> ;-)
> 
> Incidentally, I've not been too terribly excited about those sequences, 
> since as soon as you need a slightly different waveform -- even 
> amplitude -- the whole thing goes to pot.
> 
> It's a perfectly soluble problem today, where you can throw a friggin' 
> dual core ARM9 plus FPGA at a stupid power converter, and save all the 
> power consumption and cost of that brain on the few points of efficiency 
> you gain in turn.
> 
> But if you're going to such lengths, it's worthwhile also to spend much 
> more time figuring it out yourself, or hiring a guy to.  You can do 
> worse than write the solver in Python, and run it on a platform like that.
Rapidly solving for the optimal Fourier series frequency components for 
a given output amplitude seems like a similar problem to scale-invariant 
pattern recognition in the frequency domain, wonder if he has heard of 
the Mellin transform.

> Or for that matter, fill a ROM table with 256+ precalculated sequences, 
> and just let that be that.
> 
> More generally, there are optimal-trajectory algorithms in the 
> literature, which can run in real time on FPGAs.  That's good for high 
> efficiency audio, say.
> 
> Tim
> 

[toc] | [prev] | [next] | [standalone]


#505949

Frombitrex <user@example.net>
Date2018-05-20 01:41 -0400
Message-ID<VT7MC.138635$LR2.128202@fx41.iad>
In reply to#505948
On 05/20/2018 01:33 AM, bitrex wrote:
> On 05/20/2018 12:47 AM, Tim Williams wrote:
>> "bitrex" <user@example.net> wrote in message 
>> news:Zt5MC.148443$T14.17529@fx44.iad...
>>> I've looked at those papers every once in a while for a decade or so but
>>> for the life of me I've never once seen him simply post some source code
>>> that does what the documents say in e.g. portable ANSI C.
>>>
>>
>> He gives away the source code.
>>
>> It's in PostScript.
>>
>> ;-)
>>
>> Incidentally, I've not been too terribly excited about those 
>> sequences, since as soon as you need a slightly different waveform -- 
>> even amplitude -- the whole thing goes to pot.
>>
>> It's a perfectly soluble problem today, where you can throw a friggin' 
>> dual core ARM9 plus FPGA at a stupid power converter, and save all the 
>> power consumption and cost of that brain on the few points of 
>> efficiency you gain in turn.
>>
>> But if you're going to such lengths, it's worthwhile also to spend 
>> much more time figuring it out yourself, or hiring a guy to.  You can 
>> do worse than write the solver in Python, and run it on a platform 
>> like that.
> Rapidly solving for the optimal Fourier series frequency components for 
> a given output amplitude seems like a similar problem to scale-invariant 
> pattern recognition in the frequency domain, wonder if he has heard of 
> the Mellin transform.

That is to say there's an equivalent for the Mellin transform of the 
Parseval's/signal energy theorem relationship between the time and 
frequency domains except that the energy relationship for the Mellin 
transform is invariant under time-domain scaling rather than time-domain 
shifting.

[toc] | [prev] | [standalone]


Back to top | Article view | sci.electronics.design


csiph-web