Tuesday, February 14, 2023

Filter CV range calculations

Update: I've used 17.9mV throughout this post as the V/oct input to the exponential converter. Not sure where I got this number from, but in my posts on temperature compensation I use 17.5mV per octave at 20C. The change in range per degree is approximately 60uV. This places 17.9V 0.4mV or 400/60 = 6.67 degrees up, at 26.67C. I've recalculated things and it doesn't really change anything except for the tracking so I've left this post as is. 

Now here's the fun part of the last post :-) 

I did a quick measurement of the input CV to the exponential converter.

For an output of 150nA we need an input of 72mV

For an output of 1.16mA we need an input of -149mV


This means we have a total range 231mV. With the expected 17.9mV/octave this covers 12.9 octaves. If we want to cover 14 octaves, we need 17.9 mV * 14 = 250.6mV.

It looks like 14 oct may be hard to achieve in practice, as < 150nA will give an output that always attenuates, and one additional octave when we're at 1.16mA would need 2.32mV which is much more than the max we're able to generate. But for the sake of this discussion, let's go for a 14V range, starting at 72mV.

We then want to add +/-3 octaves of tuneability, to cover temperature changes and parts differences. Normally, these 3 octaves will be useless, but being able to change the input voltage by a similar amount will give a voltage at the expo converter that is +/- 3*17.9mV.

To cover this, the range seen at the expo converter should have a range of 17.9mV * 20 = 358mV. It should start at 72mv - 3 * 17.9mV = 125.7mV and go down to -232.3mV

We know that the maximum output of the CV summer is around +/-10V with +/-12V rails. That means that if we set -10V out of the CV summer to end up as -232.3mV, we need an 1/43 attenuator.

Selecting a nice and round number for the attenuator, 1/40, we would need -9.25V in to reach -232.3mV

That would put the top voltage at 5.03V, giving a range of 5.03V - -9.25V = 14.28V

ok, so that is the MOST we can do. But let's pick a number that is easier to work with. Let's restrict the output of the CV summer to a range of 10V. Having a 0-5V CV input (that should cover 20 octaves) means we can use a -2x gain, that's pretty neat.

So, with a 10V range in, and a 358mV range out of the voltage divider before the expo converter, we need a 10V/0.358V = 27.93 attenuation. We already have a 560Ohm tempco at the bottom of the divider. Picking a 15kOhm resistor at the top will give us a 27.78 attenuation, that's pretty close - it gives 360mV out for 10V in.

Applying this to the original output values gives us:

Needed input top: 125.7mV * 27.78 = 3.49V

Needed input bottom: -232.3mV * 27.78 = -6.45V


So - we need a circuit that produces a 0 to -10V output from a 0-5V input, and then offsets that output by 3.49V

We already know that the first part is achieved by a -2x gain. Using a 100k feedback resistor we could use a 50k input to achieve that.

For the 3.49V we connect a resistor to -12V. The gain has to be 3.49 / -12 = -0.2908. With a 100k feedback resistor we thus require a 344k resistor. 

The nearest standard value is 330k or 360k if using a more fine grained scale. Using a 360k resistor will give a gain of 100 / 360 = 0.278 and an output of 3.33V. A 330k resistor gives a gain of 100/330 = 0.303 and an output of 3.64V. Let's go for the 360k first, just because -3.33(3333)V is such a nice number. The range at the input is now 3.33333V to -6.666V (mmmmm!).

Converting back to the output at the expo converter, we get 3.33/27.78 = 120mV and -6.66/27.78 = -240mV. 

If we instead go for the 330k resistor, it would set the range at 3.64 / 27.78 = 131mV to -6.36 / 27.78 = -228.9mV

Now, none of these cover the entire range we originally wanted. The 360k resistor is 5.7mV away from reaching the lowest point, the 330k resistor is 3.4mV away from the highest point. The worst offset is thus about 0.31 octave away from our intended range. As we have 3 octaves to work with in both directions, I'd say both options will work.

Backtracking a bit more, we get that our new range, 360mV (for the 360k resistor, or 359.9 for the 330k resistor), covers 360mV/17.9mV = 20.11 octaves. That's fairly accurate without any kind of tuning, which is a very good starting point!

To sum it up:

Use a 50k resistor between CV input and the negative op amp terminal

Use a 100k feedback resistor

Use a 330k resistor between -12V and the negative op amp terminal

Use a 15k resistor on top of the voltage divider (connected to the op amp output)

Use a 560R resistor to ground at the bottom of the divider

NB: 15V/-15V supply is really 12V/-12V, I just couldn't be bothered changing the labels.

Update:

When using 17.5mV the range is instead 124.5mV to -229.5mV. 20 octaves would be 350mV. Using a 0-10V input to the resistor divider would give perfect tracking for a 28.57 attenuation, which would require a 15.44k resistor on top.

If we keep the 15k resistor we will get 0.486V/octave instead of 0.5 at the input. It doesn't matter too much as we have a lot of tuning range, though we COULD combine a 15k and a 470Ohm resistor if we wanted to.

Now it's time to test this. Quick Batman, to the LTSpice-mobile!

(We have one last issue to tackle though, temperature compensation. But let's not spoil the fun yet!)


Edit: testing

Red: CV input, Blue: CV summer output, Green: I_abc

My calculations are correct. I see a 3.64V to -6.36V output after the CV (With a 330k offset resistor). 

The voltage at the expo converter is 130.87mV down to -161.3mV, after that it flattens out meaning we've reached the limit of the converter at its 25C state (we needed it to reac -149mV for a 1.16mA current so that's ok). This happens when CV is 4.44V btw.

I_abc is 15nA to 1.28mA.

Light blue: expo converter base voltage, Green: I_abc

We do see a bit of non-linearity when the expo converter base voltage reaches around -122mV (CV is around 3.6V). Not sure what is going on there, I saw the same thing with the unchanged circuit. It would mean that the last octave (-122mV to 149.9mV) is not tracking properly, though this either should not be a problem because it is so high anyway, or we have a bit of room to calibrate it out. 

Frequency response

I did some fairly manual frequency response measurements, plotting the filter response for various CVs and reading the -3dB cutoff frequency. It's not entirely accurate but gives a good indication:

CV: Frequency

0.75V: 3.48Hz (oct 0, but never gets above -2.2dB)

1.00V: 8.6Hz (oct 1)

1.25V: 17.9Hz (oct 2)

1.50V: 36Hz (oct 3) "Baseline" for expectations later

1.75V: 74.33Hz (oct 4)

2.00V: 150Hz (oct 5)

2.25V: 304Hz (oct 6)

2.50V: 606Hz (oct 7)

2.75V: 1.21kHz (oct 8)

3.00V: 2.34kHz (oct 9)

3.25V: 4.47kHz (oct 10)

3.50V: 8.20kHz (oct 11, expected 9.2kHz)

3.75V: 14.1kHz (oct 12, expected 18.4kHz)

4.00V: 22.34kHz (oct 13, expected 36.8kHz)

4.25V: 32.8kHz (oct 14, expected 73.7kHz)

4.50V: 41.9kHz (additional octave, highest reachable cutoff)

As we can see, tracking is quite accurate from between oct 1 and 2 up to between octave 10 and 11. We will be able to tune in 40kHz as well, with an additional 0.5V CV (=2 octaves) left for temperature compensation etc, meaning we can get a workable 4Hz to 40kHz.

PS: Since it looks like the most compensation is needed at the top range, we could perhaps go for the 360k shifting resistor option instead, it will shift everything up by about 2/3 octave and allow more calibration on top.


Temperature compensation

We're using a 560Ohm tempco. Let's see what PPM rating it should ideally have. Now, tempco values are usually defined with a 0% change at 25 degrees. At 25 degrees, we would expect the expo converter to need 17.5mV + 5 * 0.06mV = 17.8mV per octave. Let's calculate the necessary input voltage:

V_in * 560 / (15000+560) = 0.0178V, V_in = 0.494V

Now, if the temperature rises by 10 degrees, we would need 17.8mV + 10 * 0.06mV = 18.4mV for the same change. To keep the CV input equal, we see that

0.494 * x / (15000 + x) = 0.0184V

x = 580.32Ohm. In other words, the resistance needs to change by 20Ohm or 0.5Ohm per degree.

From my previos work I have that

560 * (1 + x * (10^-6)/10) = 580

x*10^-6 = 580/560 - 1

x = (580/560 - 1) / 10^-6 = 3571

Which should mean that the resistor should have a 3571ppm/C temperature coefficient.

The ones I have, Vishay Linear PTC, TFPT0805L5600FV (684-1021 from RS components), are nowhere near this. They are 4110+/-400 ppm/K, and a simple example says they are expected to be 560 * 1.042 = 583.52 at 35 degrees. The worst case scenario should be 1.046, = 585.76, let's round to 586. While this may not be good enough for a VCO, I think it has a fair chance of working for a VCF. Let's calculate.

The output of the voltage divider at 35 degrees should be near

0.494V * 586 / 15586 = 18.57mV, or 0.17mV off from what we expected.

At 35 degrees, a semitone is 18.4mV / 12  = 1.533mV. 0.17mV equals 11cents of error. Over a 14 octave range, the accumulated error will be 155 cents or 1.5 semitones. 

If instead the temperature rose by 25 degrees to 50C, the resistor should be at 1.110 * 560 = 622Ohm. The needed output would be 17.8mV + 0.06 * 25 = 19.3mV. The output from the divider would be 19.67 or 0.37mV off, equaling 24 cents, and over 14 octaves 338 cents, equaling 3.5 semitones.

Without temperature compensation

To get a better understanding of what we are up against, let's see what the offset looks like if we don't use a tempco.

Starting again at 25 degrees, we know that 0.494V in gives 17.8mV out.

But then, at 35 degrees, it STILL gives approximately 17.8mV out, while the exponential converter needs 18.4mV. We have a 0.6mV error instead of the 1mV we would get with the tempco.

Over 14 octaves that accumulates to 8.4mV or 5.5 semitones - or almost half an octave. This is for a 10V change. If the change is more drastic, say 25 degrees, the error will be 0.06 * 25 = 1.5mV/oct for a total of 21mV, or 1.14 octaves. As we have a +/-3 octave tuneability, this should also be within reach. We would, however, need to know the temperature!

Keeping multiple VCFs tracking

With a tempco in place, and assuming that it is somehow affected at least not too much differently than the internal temperature of the expo converter, and also assuming that the VCFs won't drift THAT much from each other in terms of temperature, say +/-5 degrees, we COULD see as little as 0.38 semitones difference (given all VCFs are tuned to the middle freq, we would see a +/-7 oct range to drift in). This would not be perceptible in terms of cutoff but perhaps for resonance. 

WITHOUT the tempco, we have different option - measuring temperature and keeping several lookup tables. Apparently, this is what some Sequential synths do their VCO calibration, making them playable without warmup. 

We would however need a temperature sensor close to the expo converter. It is an exciting thought and I should definitely explore it further, especially seeing as thermistors are hard to get, expensive (2-3USD per chip) and have to be manually soldered.

It may even be an idea to use a temperature sensor for tuning the filters even with the thermistor in place...

A thought about tuning

I started wondering about how to best tune the cutoff. We can send a sine-like wave and see how it is attenuated. This will work up to the maximul DCO frequency which is something like 20kHz, but above that, in the most troublesome territory, we have no built-in source (though we could possibly use a VCO, but they are themselves not completely stable).

But we DO have resonance. If the resonant frequency is directly and proportionately related to the cutoff frequency, could we measure the resonance wave (e.g. just frequency counting) instead?

No comments:

Post a Comment