square wave to sine filter

formatting link

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
Reply to
John Larkin
Loading thread data ...

Yeah the bandpass falls off half as fast at high freq.

George H.

Reply to
George Herold

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:

formatting link

Reply to
Tim Williams

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

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.

Reply to
bitrex

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

Reply to
bitrex

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.

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
Reply to
John Larkin

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

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

If you have a DAC in the ARM you can start off with a much better approxima tion 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 ou t of a PWM driver.

If you could tri-state the output of the PWM generator you could generate t he 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 thi rty degrees.

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

--
Bill Sloman, Sydney
Reply to
bill.sloman

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.

Reply to
bitrex

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.

--
Bill Sloman, Sydney
Reply to
bill.sloman

As long as you're feelin' memey tonight bro, you might enjoy this

formatting link

Tim

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

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/
Reply to
Tim Williams

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.

Reply to
bitrex

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.

Reply to
bitrex

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!

Reply to
bitrex

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

--

John Larkin         Highland Technology, Inc 

lunatic fringe electronics
Reply to
John Larkin

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.