Simple Pulse Width Modulation Compressor Design

Started by rring, August 04, 2013, 11:22:18 PM

Previous topic - Next topic

rring

I cooked this thing up last week and it shows great promise. It can work as a feed forward compressor or in feedback mode by just changing one wire connection. I hope someone will experiment with it a make it better. It uses a TL5001 PWM chip at about 500KHz. There is very little distortion and the compression curve can be made linear, log, or antilog, very easily by altering the feedback amplifier in the the PWM chip. The design has low noise also because no amplifier gain is ever changed just the average buffered signal level.




psychedelicfish

First off, good job! Sounds good, low noise, what more could you ask of a compressor?
How easy would it be to mod for more controls (attack, release etc.)?
Where did you get your TL5001?
Other than that, I think I might have to build one!
If at first you don't succeed... use bigger transistors!

psychedelicfish

Would it be possible to make a variant of this circuit using a 555 timr ss the PWM? I think it would be a cool addition to the list of 555 pedals
If at first you don't succeed... use bigger transistors!

rring

The Tl5001 is a Texas Instruments part - so Digikey, Mouser, etc will have them - I think they are 2 bucks with Digikey. A 555 probably could be made to work, but I think it would be more trouble than its worth. I have used a 555 for PWM before but it worked by just making the off time stay the same and making the on time longer - so the frequency changes which is bad. This device is constant frequency with only the ratio of on/off changing.

Attack can be altered by adding a resistor in series with D3 or changing the comp cap on pin 3 of the Tl5001. In the demo I am using a .01uF compensation cap which makes the attack a little slower that it can be.

Decay is set by R19 it can go down to about 220K(faster release) and up to over a 1Meg (slow release).

R23 sets the PWM frequency and  has an effect on all of this also- right now I am pushing the frequency to highest I can get. It works down to 100KHz easily but some of the component values around the TL5001 will have to be tweaked

samhay

Wow - a no-gain compressor is a very cool idea. It sounds good, so what needs to be made better at this stage?

As drawn, I don't see what IC3B is doing.
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

slacker

Ic3b makes an ideal diode. To positive signals hitting ic3a non inverting input it looks like an open circuit, so ic3a is a non inverting buffer. For negative signals it looks like a short to vref, turning ic3a into an inverting buffer. Hope that makes sense.
EDIT: except its referenced to ground, not sure how that works, possibly a mistake?

rring

IC3 is a full wave rectifier so the (peak detector that follows) gets both the positive and the flipped negative excursion of the audio signal to charge the filter cap faster and require less filtering. It is a unity gain buffer for the positive excursions(positive half wave rectifier) then on the negative excursions the IC3B shorts out the + input of IC3A making it a inverting unity gain buffer providing the negative side flipped up to be positive - hence the full wave. It works surprisingly well and is single supply. The LM358 is used because it works down to 0 volts and can tolerate signals below the negative supply (ground in this case) with out going crazy (it is called phase reversal and most op amps have this problem).

With regard to refining the circuit, not sure the pre-emphasis and de-emphasis are really needed - so need to experiment with just simple gain stages. The range of compression can probably be improved by optimizing the PWM frequency and drive. Slower means sharper edges and better pulses( can get narrower) but also requires you change some the R values around the PWM IC. This also makes filtering the PWM more challenging. From the demo you can hear and see that the compression stops near 100% duty cycle but it could get closer - giving more dynamic range of compression. Maybe using a schmitt trigger to drive the switch would help?

This makes the feed forward mode hit a little bit of a brick wall - where it wants to compress more for the signal level coming in but it can't. In feedback mode there is probably a more optimal attack and release settings that can be used.

In general, its about optimizing values, frequency/dynamic range. Maybe there is a better device to use as a switch(adapt it to use a more common N JFET)? R8 is really low and I just tried it to start with - it probably can be increased, providing a little less loss across the switch. If it is too high, there probably will be some jitter noise from the PWM that gets through.

The point here is - I am not claiming the circuit is perfected.

midwayfair

Very cool design. Your stuff is always out-of-the-box thinking!

A couple questions:

How critical is the op amp choice? Would different op amps work if we have a buffer in front of the whole thing (your note says that a low impedance input is necessary)?

What happens if we have a cap at the PFET gate instead of connecting it directly to pin 1? Will it still work? I ask because I did this on an LFO with a FET setup like that, and I got noise/whine until a cap was put there. If it's possible, then it might avoid the need for R9 & C7 and prevent frequency loss from the audio path.
My band, Midway Fair: www.midwayfair.org. Myself's music and things I make: www.jonpattonmusic.com. DIY pedal demos: www.youtube.com/jonspatton. PCBs of my Bearhug Compressor and Cardinal Harmonic Tremolo are available from http://www.1776effects.com!

rring

Yes the full wave circuit is correct - it works because C14 gives AC coupling - if you tied directly to the input with out this it would be a positive half wave rectifier

rring

Its the output that is the issue ( I think I said output?) just need to be able to drive the switch hard - I used 470 ohm (R8) - perhaps this could be 1K or 2.2K - just haven' tried it out yet. So the op amp just needs to have a stiff output. A TL072 or similar should work fine- maybe up R8 to 1K.

rring

Can't put the cap at the gate of the PFET because it will mush the edges of switching waveform which needs to be as sharp as possible.
R9/C7 have a roll off of about 7K but you can make C7 much smaller if you like because the switching frequency is at greater than 500KHz.
Again some values I am using may not be optimal.

samhay

Quote from: slacker on August 05, 2013, 08:45:00 AM
Ic3b makes an ideal diode. To positive signals hitting ic3a non inverting input it looks like an open circuit, so ic3a is a non inverting buffer. For negative signals it looks like a short to vref, turning ic3a into an inverting buffer. Hope that makes sense.
EDIT: except its referenced to ground, not sure how that works, possibly a mistake?

Quote from: rring on August 05, 2013, 09:14:57 AM
IC3 is a full wave rectifier so the (peak detector that follows) gets both the positive and the flipped negative excursion of the audio signal to charge the filter cap faster and require less filtering. It is a unity gain buffer for the positive excursions(positive half wave rectifier) then on the negative excursions the IC3B shorts out the + input of IC3A making it a inverting unity gain buffer providing the negative side flipped up to be positive - hence the full wave. It works surprisingly well and is single supply. The LM358 is used because it works down to 0 volts and can tolerate signals below the negative supply (ground in this case) with out going crazy (it is called phase reversal and most op amps have this problem).

Thanks. I should have spotted the ideal diode, but haven't seen this design of a FWR before - nice one.

If we don't want to use a single sided op-amp(s) for the envelope detector, I think we could DC couple everything and reference to Vref instead? I guess we lose half our envelope magnitude though.
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

rring

yes that full wave rectifier uses that fact you can't go past ground - virtual or otherwise to forces all positive output. You could probably just use the D3/C15 peak detector with IC2( amp and buffer) and it would work fine - you would just have to increase R19 to slow down the decay.

rring

Here is an alternate version which may be preferred. It adjusts the compression ratio by simply bypassing the switch and leaving the side chain gain fixed. It also reflects some other tweaks I did. I think I like it better.


PRR

> using a 555 timr ss the PWM?

Need more parts. Accuracy is worse. TL5001 is a 2-buck part. CHEEP as audio gain-controls go.

Anyway if you know how, you don't need rring's plans.

TI page: http://www.ti.com/product/tl5001
TI Datasheet: http://www.ti.com/lit/ds/symlink/tl5001.pdf
TI application notes: http://www.ti.com/lit/an/slva034a/slva034a.pdf http://www.ti.com/lit/an/slvae05/slvae05.pdf
Lesson with 555 and TL5001: http://www.usna.edu/EE/ee320/Supplements/dcdc9_pwm.pdf
Unisonic datasheet: http://search.alkon.net/cgi-bin/pdf.pl?pdfname=utc/TL5001.pdf
If you favor DIP package, Mouser has hundreds of them in-stock under serveral suffixes.

_________________________________________________________

PWM is the dream-tool of audio. Tried many times. Used in some VERY good broadcast limiters. But VERY hard to get working *cleanly*. Rounded switching and supersonic hash everywhere. One famous job resorted to metal cans everywhere, a mechanical nightmare.

These power-switching chips *may* be a great help. Many of the system integration problems are already in the chip.

My only minor worry with rring's plan is that I think a JFET driving a 470 ohm load "must" distort some. Even with no gain reduction. Perhaps not enough to hear.

_________________________________________________________

> a no-gain compressor

A compressor, while working, is constantly changing gain. Saying "no-gain" makes no sense.
  • SUPPORTER

rring

Yes  I design PWM power supplies  - so I am familiar with these IC's and often think about non-standard applications. I had to build a complete PWM boost converter from the ground up up once for an unusual application and it was a pain - so to your point - a fully integrated controller provides many benefits!

I agree with what you have said. Just a couple points though.

I intentionally tried to make this as simple as possible so other experimenters would be willing to try it and it would have some value to the DIY community. So there are some trade-offs here. Not saying this design is a masterpiece but it is working surprisingly well on a breadboard so I am going to a build a PCB and see how it does.

Noise is a huge challenge - what I found was just when you are barely turning on the switch or just almost completely off, the switching action is lost and the device start behaving like its in the active region and goes to crap. So well defined pulses are required.  However, it was oscillator jitter that  generated the lion's share of noise, when I first fired this thing up. So it is important to utilize frequency compensation in the control loop so that the bandwidth of noise modulation is reduced. Also this is why I used a little pre-emphasis / de-emphasis along with the PWM low pass filter. The 470  ohm resistor  is low. It probably can be much higher. I tested the switch and it worked pretty well near a volt so I left it. It does start to distort beyond this but the low Z helps with noise reduction. I briefly tried 4.7K as a load and it seemed to work fine, but on a breadboard there are lot of parasitics...so I just stuck with the 470 ohm. I really need to make PCB board with a well defined ground plane.

One problem is that you have some what of a limited range of compression because at some point your duty cycle can get any smaller and abruptly jumps to all the way off. I can get about 23dB - with a slower PWM Frequency and a stiffer pull-up you could do better.

The point I was making about gain - I am not altering a feedback resistor in an op amp circuit or the transconductance of an OTA so I am not  changing the gain of amplifier stages - where the noise increases with gain increasing.

You don't here the background noise come way up as the compression drops off because of noise increasing with gain increasing in an amplifier stage. The difference is noticeable.

so yes of course as a system, the compressor is controlling signal gain of output to input.

As a side note:

I was able to use the IC's internal transistor as a switch, where the action was inverted and the switch was shunting to ground through a series resistor (22K). It worked okay but required an inverted control voltage.






PRR

I'm still fascinated by the power-chip PWM.

As you say, it goes nuts if the duty touches 100%... it puts a "hole" in the signal. In power use 100% duty is also problematic. That's what the dead-time feature is supposed to avoid. I think it works on the "wrong side" the way you phased it, so you did the clever clamp to limit duty to ~~5%. ALL gain-control circuits have their limits, true. Vari-Mu and OTA become too starved to drive a load. FET and LDR bottom-out and allow (grossly excess) signals to pass. Many ways to skin cats, none perfect.

For your amusement:

An old thread (albeit about PWM Tremolo) on this forum:
http://www.diystompboxes.com/smfforum/index.php?topic=30689.5

An old discussion on a PWM audio limiter. This is for "pro" audio and some details would be (must be!) less elaborate for a Pedal. It was never carried through, but there are some interesting sidelights on later pages.
http://www.groupdiy.com/index.php?topic=780.0

Operation/Theory manual for a very good broadcast PWM limiter. Some aspects do not apply here, such as Stereo. Perhaps metering. And "preemphasis" is a treble-boost applied to FM radio transmission, not relevant here. It additionally has delayed recovery when the source is "silent" so it does not pump-up the background noise in dramatic silences. Much of that may be ignored. It does have copious anti-aliasing filtering. And the designer seems to have thrown in every trick in every book, rectifiers and filter topologies I've never seen
http://www.inovonicsbroadcast.com/wp-content/uploads/catablog/downloads/260_Manual.pdf

> I am not changing the gain of amplifier stages - where the noise increases with gain increasing.

For the same results, you can get the same noise-level either way.

Yours has a good distribution of pre- and post-gain. A much better gain distribution than the too-popular OTA designs, which in straightforward connection require massive attenuation in front (to avoid gross distortion) and corresponding excess gain afterward.
  • SUPPORTER

GFR

The limiter I mention on that old thread is this:

http://imageshack.us/photo/my-images/105/pwmcomp8sr.gif/

The + and - inputs of U9A are swapped, sorry.

A single transistor plus one comparator from a LM339 to generate the ramp. The switching is done by two switches from a 4066 in a "L", and attenuates the signal being fed back around U9A. The plus side is only using very common stuff (so common that I could even buy them in stores in Brazil in 1987) but 339 and the 4066 are working too close or maybe past their limits :( so the waveforms are not that pretty, speciall near 0% and 100%. But it sounded OK, altough it needed a very good power supply or else it featured a lot of noise.

The power supply chip idea is great!

Gus

I noted the input resistor value is 1meg and this sets the ref for two op amps IC1A and IC2A
http://www.st.com/web/en/resource/technical/document/datasheet/CD00001188.pdf
http://www.ti.com/lit/ds/symlink/lm158-n.pdf

1meg to Vref and the input being connected to both + how much do the inputs offset voltage and offset current affect each other?

I have not seen the TS922 before that looks like an nice dual opamp to use in effects

rring

Yes  the dead time is on the wrong side as you noted. If you use a switching device as a shunt with a series resistor you can get the dead time control on the correct side.  The adjustment is critical though and I wanted to avoid not standard R values etc.

The PFET is easy but has headroom limitation (1.6 VPP) with positive excursions being clamped -

I tried a PNP transistor where, when switched on, it was biased at half supply - the swing was fine but something about applying DC across the device creates all kinds of horrible noise -perhaps working like a RF mixer.

so I tried an analog switch with superior headroom results though for guitar it doesn't matter much.

Now the headroom approaches the supply rails. I am using a TS12A4515 normally closed analog switch. One nice thing is that the inverters internal to the analog switch help sharpen up the edges of the switching extended the duty cycle range a little before the on or off time gets to small and blurred.

I built a PCB layout and I am adjusting a few things and will post a more final schematic after I get it dialed in.