Showing posts with label HP. Show all posts
Showing posts with label HP. Show all posts

Monday, January 1, 2024

Biasing cap and filter response

1uF

While looking for the reason why the filter output jumps frantically between +/- max when the cutoff is low or the input is close to zero when turning up distortion (spoiler: it's the biasing capacitor), I realised that I should have a closer look at what the output biasing/centering capacitor is actually doing to the filter's response. 

The cap is there to make sure the output is centered around 0, i.e. filter out any DC component (AC coupling the signal). The higher the capacitor, the longer the filter takes to change to 0V after an abrupt (DC) change. In the case of the jumping described above, I would like the change to settle as fast as possible, which means replacing the current 1uF cap with a smaller one, but what would that do to the output?

Looking online, it seems that the most common value of cap is 10uF. The Juno synths use 1uF. The cap in combination with a resistor/resistance creates a high pass filter with the cutoff frequency f=1/(2*PI*C*R). In my case, I have an 82k resistor immediately following the cap so I assume that this is R in the formula (the JP8 uses 100k and Juno 6 56k + a 20k trimmer).

The red line in the first plot here shows what our current 1uF cap does.

0.47uF

1uF 3dB
The 470uF cap clearly moves the cutoff frequency higher. Its -3dB point is at approximately 2.9Hz, compared to the 1.4Hz of the 1uFthe calculated values are 1.94Hz and 4.2Hz so 82k is at least close to the "real" resistance).


0.47uF at 20Hz
The human hearing is usually considered incapable of hearing frequencies of less than 20Hz. At this point the 0.47uF cap attenuates the signal by 90mdB. This in itself is not a lot, but it means that any sub-audible, ground shaking frequencies are filtered out. This may not be a problem as the equipment later in the chain may also have similar filtering, but it is something to think about.


10uF

In comparison, the 10uF cap gives a cutoff of less than 0.2Hz which is probably the reason why it's the more common choice.

0.047uF
I've seen some designs use a 47nF cap. This gives a -3dB cutoff at 370Hz which is a complete no-go combined with my 82k resistor.

Thursday, April 9, 2020

Distortion breadboarded

I've breadboarded two versions of the distortion circuit, both with input attenuation and output amplification to keep a 10Vpp signal almost untouched.

Pre-distortion amplification


First I did the version with pre-distortion amplification. With distortion CV at 0V the distortion circuit sees around 30mVpp. This is heavily amplified to distort.

At the other end, a second OTA amplifies the signal. The output has unity gain for a 10Vpp input when CV is around 2.5V.


Hard clipping circuit with pre and post distortion VCAs

Hard clipping, distortion CV from 0 to 5V



Soft clipping circuit with pre and post distortion VCAs

Soft clipping, distortion CV from 0 to 5V



This circuit worked pretty much as in the simulation. I do have some issues with CV feedthrough so centering is not perfect when distortion changes.

I think I have to bite the bullet this time and introduce AC coupling to get rid of this. Placing a cap in series with the 1k resistor to the distortion op amps negative pole seems to do the trick, and will function as a high pass filter as well (beware though, if not chosen correctly low frequencies will not be distorted, in fact they will be attenutated.

Distortion CV at 0V

Distortion CV at 2.5V, almost full distortion and more than double amplitude

Distortion CV at 5V, full distortion. Signal is clipped unevenly by the op amp.

Distortion CV at 2.5V, almost full distortion


Distortion CV at 5V. Very similar to half distortion.

It seems that the real life circuit sees a higher maximum input gain than the simulation. Full distortion is reached much earlier. Also, compared to the OTA in feedback loop version below, the CV response seems exponential, not linear.

OTA and parallel resistor in feedback loop


Then I tried breadboarding the OTA-in-feedback version. I had lots of trouble and could not get it working as expected at all. After much experimentation I ended up with a well functioning circuit. I then started documenting the changes, and realised what was going on: I had inadvertently put a 33k resistor in the feedback of the distortion op amp. This works in tandem with the signal fed back through the OTA, so it completely changes the amount fed back.

As a bonus, the CV control of this version seems to feel much more linear - in the other version all changes came at the start of the CV and very little later. Also, the soft clipping amplitude seems to stay very close to 5V, so in some ways it feels more "correct", the volume doesn't increase as much.

After discovering my error I simulated this circuit too and it works as on the breadboard.

PS: The distortion CV now works in reverse: 0V is max distortion, 5V is no distortion. Unity gain through the circuit is the same as above, approximately 2.5V.

OTA and 33k resistor in feedback of op amp

Soft clipping

Hard clipping, starts very soon after turning the distortion pot.


OTA in feedback loop without the 33k resistor


Now I went back to the circuit that I was TRYING to breadboard and looked at the simulation again. I think I got lost because I couldn't get it working the way I wanted to. Looking at my previous Distortion post, I realised that the hard clipping starts much later, and so the output has a higher amplitude when clipped than in my happy accident.

I then changed parts back to my original design and did some tweaking, resulting in this circuit:


OTA and no resistor in feedback. Soft clipping version


OTA and no resistor in feedback. Hard clipping version
Soft clipping

Hard clipping

Results on the breadboard for versions with OTA in feedback loop


The circuit on the breadboard have some small differences from the simulated one. The output amp uses a 120k resistor instead of a 150k to get unity gain at 2.5V CV. I left the 180pF (Low pass filter) in place, and used 1k pots instead of the resistors to ground on the OTA inputs (except for the distortion OTA in the version without resistor in the feedback.

The potentiometer settings used were:
VCA pot: 620 ohm to ground on negative input, 365 ohm to ground on positive input
Distortion pot: 479 ohm to ground on negative input,  512 ohm to ground on positive input in distortion OTA. For the version without a feedback resistor I breadboarded it as in the schematics.


All oscilloscope pictures are of a 473Hz 10Vpp input wave. Vertical resolution is 5V/square. Output VCA CV is at 2.5V which according to the simulations should give us unity gain for undistorted signals.

First, the circuit with both an OTA and a 33k resistor in the feedback, soft clipping:


Triangle wave, soft clipping selected and distortion CV is at max (5V) meaning least amount of distortion. Output is equal to input
Same as above but with distortion CV at 0V, meaning max distortion. Amplitude only changes slightly but output is heavily distorted.



Hard clipping:

Same as above, but this time with hard clipping. 5V distortion CV, No signs of clipping and still unity gain.

Again same as above, hard clipping, but with 0V distortion CV/max distortion. Heavy clipping and just slightly higher amplitude.

Without 33k resistor in feedback

Now for the circuit without the 33k resistor in the feedback loop. This didn't work very well, the clipping became very asymmetrical. This may be due to the high attenuation of the input signal? I tried replacing the resistors at the positive and negative OTA terminals with a 1k resistor but that didn't change things. Maybe an HP filter capacitor would help?

Soft clipping:

Soft clipping, max distortion CV. The signal passes unclipped but with the output VCA CV at 2.5V the amplitude is only around 7Vpp, and also not symmetrical around 0V.

Soft clipping, no distortion CV. Heavy but unsymmetrical clipping. Amplitude is almost the same as for the previous circuit.
Hard clipping:

Hard clipping, max distortion CV. Same as soft clipping, no surprises there.

Hard clipping, no distortion CV/max clipping, looks very similar to hard clipping for the other circuit except that the clipping is unsymmetrical.


Pre and post OTA breadboarded



510 ohm resistors instead of trimmer for version with 33k in feeback

I tried replacing the 1k trimmer pot on the distortion feedback OTA with two 510 ohm resistors to ground. That gave the following result:


The input is now distorted, meaning the OTA sees a too high voltage.

By measuring the position of the trimmer potentiometer for the distortion feedback OTA when signal does not clip at 10Vpp input (750 ohm), and using the resistor divider equation, I found that the distortion OTA sees +/-165mV. Going the other way, a resistor divider with 15k and 510 ohm will yield the same result. Here I have done the change:


When tweaking the potentiometer I could see that clipping starts right after I started turning the potentiometer. Since there may be production differences, an even smaller input resistor would give a litte room for trimming the input digitally. Here is the effect of 12k, a slightly smaller amplitude:



I also tried replacing the trimmer in the VCA OTA part, that heavily offset the output. It could be possible to use AC coupling here, but we would still get uneven clipping in the VCA at high gain, so it might be best to use a trimmer.

I also did see a slight distortion at minimum distortion CV, but this is probably not related to clipping.

510 ohm resistors in the simulation

In simulations though, it does not work very well:

Signal is much smaller than in the breadboarded circuit when no distortion CV is applied.






I am not sure I will do any more work on this now, I have a well functioning circuit that I will test with some "real" signals instead later (the one with the extra 33k resistor in the feedback, 12k on the input and 120k on the output).

Tuesday, March 31, 2020

Distortion (clipping)

Seems I can't stop working on my synth these days. There are two major parts missing from my synth voice cards: Digital playback and pre-filter distortion. I am not sure about the need for the last one, so I decided to build that first.

Googling distortion circuits I came across a resource that I have read long ago and forgotten about: Design your own distortion.

This page gives a great step by step introduction to two types of distortion: Hard and soft clipping. It also has some on filtering and tone control but it contains some errors (50nF cap in distortion does not give a lower frequency of 31Hz but 3.1kHz, the shown circuit will not give any distortion and indeed very little gain for frequences lower than 3.1kHz).

I decided to try simulating the circuit in LTSpice (with +/-15v supply lines) before breadboarding it, to get a feel of what it is doing.

Hard clipping

The hard clipping part of the circuit is easy. Two parallel diodes in reverse order from signal to ground after a buffer or similar that disconnects it from the input.

Hard clipping at around 750mV

What is going on? When the input signal, and thus the voltage across the diodes reaches the forward voltage drop of one of the diodes, it switches on, sinking the current to ground. This effectively cuts off the peaks of every wave cleanly. A fairly normal diode voltage drop is around 0.75V, meaning the signal is clipped at 0.75V. The amount of clipping is adjusted by attenuating the input (assuming a +/-5v input) to where you want the clipping to occur.

If one wants a higher clipping point it is also possible to connect diodes in series, going from 0.75V to 1.5V to 2.25V etc.

Hard clipping with series diodes, clips at around 1.5V


Soft clipping

This is slightly more involved. Soft clipping means that instead of brutally chopping off the wave tops, they are rounded off. Soft clipping can be achieved by placing two diodes in parallel / reverse order in the negative feedback loop of an op amp, parallel to the feedback resistor.

I first simulated inverting amplification instead of the non inverting "tube screamer" version on the web page because I could not get that one working due to the HP cutoff error in the article.



Here is what I think is going on, and why this is different to hard clipping:

When the voltage across the feedback resistor Rf is low, the diode will be turned off. Current only flows through Rf. Increasing the voltage (and thus current) gradually switches on the diode. Some of the current starts flowing through the diode while some still flows through the resistor.

Soft clipping currents - the original input current (red) is equal to the sum of the current through the resistor (blue) and diode (green). The diode only starts conducting after a while, but when it does almost all current goes through it.

Abiding to Ohms law, the opamp output voltage is still the current flowing through the resistor times the resistance, but as some of the current required to keep the two opamp inputs equal now flows through the diode, the output voltage is less than the input voltage (given a unity gain configuration where Rin = Rf).

As the input current increases, more and more current flows through the diode, and the amount of current flowing through the resistor flats out, cutting off the top of the input waves.



Another interesting thing to note is at what voltage the cut happens at is affected by the resistance of Rf. With a larger resistance, current starts flowing through the diode earlier (as its "resistance" is lower). Thus, the voltage across the resistor when it starts clipping is also lower, meaning the output is clipped more than with a lower value resistor.

Example values for a +/-1v input are clipped peaks at:

550mV for 1k,
450mV for 10k and
355mV for 100k.


A +/-5v input has peaks at 650mV and +/-15v peaks at 712mV (at 100k?)

Soft clipping with 1k resistor in feedback loop

Soft clipping with 10k resistor in feedback loop

Soft clipping with 100k resistor in feedback loop


Currents with 1k resistor, total current is 1mA

Currents with 10k resistor, total current is 100uA. A proportionally larger part of the input current goes through the diode (the diode "resistance" is still the same so it's easier for the current to go this way) and the output current is clipped earlier.

Currents with 100k resistor, total current is 10uA, an even larger part of the current goes through the diode


The non-inverting version probably works in the same way.

I first had issues getting the non-inverting circuit from Design your own distortion to work because of the HP cutoff error, but finally I found and was able to simulate a similar non-inverting circuit, this one:

https://electronics.stackexchange.com/questions/473989/need-help-designing-and-implementing-an-op-amp-based-distortion-circuit

Non inverting circuit, increased value of filter cap, meaning a lower high pass filter point distorts the wave.
The same circuit as above but without filter cap. The clipping part is more visible here.


The slight skewing is because of the cap in the feedback loop. Gain is (10k + 220) / 220 = 46

It also explains a very important thing: The guitar signal amplitude is 40mV, nothing near the 1-5V I've been experimenting with so far. Taking this into account I was able to simulate a +/-15v version of the original circuit, but WITHOUT the 50nF capacitor in series with the 1k input resistor on the positive terminal of the op amp, an the resistor connected to GND instead of the negative supply (in the original circuit it is connected to ground, but ground is the negative supply as this is a 9V circuit). See the filter section below for an explanation of why removing the 50nF cap was necessary (the cap value is simply wrong due to a calculation error in the article).

Further more, Rf must be much larger than 1k to get distortion, without this all the current flows through Rf and none through the diodes so no clipping happens. I've been working with 30k.

Working soft and hard clipping. The input (green) is multiplied by 31 to see how it matches (the non inverting opamp configuration here amplifies the input 31 times).

I have also simulated various types of diodes for the soft clipping circuit, more about this in a separate post.

Filtering

The webpage on top also talks a lot about filtering. The original article is about distortion for guitars and says that one should aim for keeping frequencies from 40Hz to 30kHz (NB: There is a serious error in the HP filter calculations in the article, see the end of this section). It may be different for a synth but that's a good starting point.

The article discusses high pass and low pass filtering in a non-inverting amplifier. The chosen circuit is often referred to as shelving filters elsewhere, it is not the most common circuit in examples on the web.

Shelving filters actually have two parts, the "normal" high or lowpass filter, and then a second part where it flattens out again at a lower or higher frequency with lower gain, but where the gain stays at this level instead of continuing to drop off, letting all frequencies below (for HP) or above (for LP) pass. - see http://www.linkwitzlab.com/filters.htm#5.

Here are the sub-circuits and formulas needed for calculating the 3dB points:

The full circuit (NB: Other component names than the original):


The second parts of the shelving filter: Both these have gain = 1. To find the frequencies, replace R1 in the HP formula with (R1 + R2), and R2 in the LP formula with (R1*R2) / (R1 + R2).

For example:

Given the values
R1 = 1kOhm
R2 = 10kOhm
C1 = 50nF
C2 = 470pF

For the HP filter:
HP filter frequency: 3.1kHz (Gain = 11)
Lower frequency: 290Hz (Gain = 1 for all freqs below this)

For the LP filter:
LP filter frequency: 33.9kHz  (Gain = 11)
higher frequency: 373kHz (Gain = 1 for all freqs above this)

PS: In the "Design your own distortion" article HP frequency capacitor selection calculation is wrong. 1 / (2 * PI * 1000 * 40) is not 0.039uF, it is 3.98uF. This explains my inability to get the distortion working without removing the cap during my simulation - I simulated using a 400Hz sine wave, this is well below the 3.1kHz HP cutoff, meaning it has unity gain and is not at all distorted.

In general, there is a lot of info about filtering missing from the "Design your own distortion" article. The Tube Screamer analysis at https://www.electrosmash.com/tube-screamer-analysis has a much better description, talking about how the filter frequencies are affected by changes in the gain of the distortion and how bass frequencies are passed undistorted (but also un-amplified).


When deciding on component values, one first chooses the gain, then calculate the necessary capacitors.

See also


https://www.premierguitar.com/articles/diode-stew-1
https://sound-au.com/articles/soft-clip.htm
https://anasounds.com/od-disto-fuzz-differences/
https://www.electrosmash.com/tube-screamer-analysis

Monday, September 11, 2017

Noise research

I intend for the XM8 to have noise as a waveform for both oscillators, and also to be able to switch between various 'colors' of noise. At the very least, white and pink noise should be present, possibly even red. But what exactly does this mean?

White noise is noise where the signal has equal intensity at all frequencies. In the synth world, it is commonly generated by using a transistor with one leg disconnected.

Pink noise is a signal where each octave carries the same amount of noise energy. But how is this achieved in practice?

According to Wikipedia, pink noise falls off at 3dB per octave. To get pink noise one filters white noise through a filter with 3dB/octave drop off.

Problem is, most basic active low pass filter has a 6dB drop off (which would actually give us red noise if used). So how may this be solved?

This page shows one method - use multiple filter sections to approximate a 3dB filter with a flat response. The more sections the better, but even four sections is pretty good for a 20-20 000kHz signal.

As a side note - the same page mentions NP capacitors, bipolar electrolytics, and says that film capacitors cannot replace them - this is interesting information as I've stumbled across NP in other circuits.

A similar approach seems to be in use on this page, which is a modification for the Sequential Circuits Pro One. It uses fewer sections (two?) and has an additional cap (C3).

But how does one calculate the frequency of each section?

In a normal active low pass filter (6dB), the frequency is 1/(2*PI*R2*C) and the gain is -R2/R1 where R2 is the resistor in the feedback loop.

It seems that the same holds true for each section in the multi section filter. For example:

1/6.28*100nF*1MOhm) = 1.59Hz
1/6.28*33nF*330kOhm) = 14.6Hz
...
which matches the frequencies next to the sections.

This would mean that the lower section of the Pro one filter is 338.8Hz, but the rest - the 270k and 3.3n combined gives us a 268.1Hz filter which seems a bit strange - however, I'm not sure this is the way to calculate the combined frequencies.

As for the gain, if the same formula as before is correct, it would be -270k/15k = -18.

The pink noise filter in the pro one matches the inverting shelving low pass filter found on this page. However, the only formula, found in the gif, is missing the lone cap in the feedback circuit.

Funny enough, the same filter topology is found in the BOSS CE-2 pedal's de-emphasis filter :). The de-emphasis filter reduces treble, which of course means it is a low pass filter of sorts. :)

On that page, the circuit is fully explained. When calculating the frequencies, the lone cap is omitted. It says that it is an LP of some sort but it is not essential when calculating the shelving frequencies.

The filter right after the transistor in the pro one circuit is a simple non-inverting HP filter. C2 and U1b forms a shelving HP filter like this.

The first filter in the Ray Wilson Noise Cornucopia is a simplified non-inverting amplifier filter as shown here and here. Its gain is 1 + R10/R9 (=48), the frequency is 1/(2*PI*R10*C4), or approx 34kHz.

ERROR: det er et lowpass non inverting shelving filter.