Closed wraybowling closed 5 years ago
You probably want something like the circuits on the bottom of page 2 here! https://mutable-instruments.net/modules/clouds/downloads/Clouds-v30.pdf
Maybe confusing at first glance, but each circuit scales and offsets various input CV ranges to an output range of 0-3.3V. He's labeled the supported input range for each of the variations of the circuit.
It's called an inverting op amp circuit, where the gain is -(feedback resistor value/input resistor value) (see: https://www.electronics-tutorials.ws/opamp/opamp_2.html). You add multiple inputs to this circuit, and it's called a summing amplifier (https://www.electronics-tutorials.ws/opamp/opamp_4.html). In this case it adds a -10V offset (derived from the -12V eurorack power supply rail) with the CV signal.
Take for example the +/-5V inputs (IC4B, IC4C, IC4D): The -10V offset has a gain of -(33k/200k), so the output is 10*(33/200)=+1.666V. This is added to the CV input, which is scaled by -(33k/100k), so the input range of +/-5V yields an output of +/-1.666V. Add this to the offset of +1.666V and the overall range is then 0-3.3V. If something outside +/-5V is applied to the CV input, the output is simply hard clipped to 0-3.3V, since the supply pins of the op amp (on the very bottom right of page 2) are tied to ground and +3.3V.
You of course would ideally have an output range of 0-5V, but you can still use this circuit almost exactly, you'd probably just want to swap the 33k resistor with a 50k resistor. This would give you an offset of -10-(50k/200k)=2.5V, and a CV range of +/-5-(50k/100k)=+/-2.5V. Add these two together and you get 2.5+/-2.5V, or a range of 0-5V!
The capacitor makes this also act as a low-pass filter to cut off high frequency noise from your ADC. Probably best to add this too. The cutoff is 1/(2piR*C) Hz, which would be 3183Hz if you make the feedback resistor 50k, which would probably still be cool. If you wanted a higher cutoff you could decrease the value of the capacitor! (See: https://en.wikipedia.org/wiki/Low-pass_filter#Active_electronic_realization)
Also worth noting that as this is called an inverting amplifier, it inverts the polarity of your CV signal... which is an issue, but this is easy to account for in software!
(if you don't feel like digging in to this, let me know, and I can probably whip something up in kicad and submit a pull request if you tell me what input CV voltage range you want to support :smile:)
Oh, and yeah, this of course takes away attenu(verting/ation)... most MI modules do that in software with a pot for each on a separate ADC channel, so you can control the response curves, etc. But you could also do that in hardware if you're so inclined! Thoughts?
Hey @brianleu Thanks for the input! I'm also considering switching the ADC to a MCP23017T-E/SS 16-bit Input/Output Expander so that I'll have more digital bits to squish in software.
Looking at the MI schematic, he's got the luxury of telling the user that some inputs are meant for audio and some are meant for CV. I don't have that luxury. So after speaking to a bunch of folks about it, I think the best thing will be to account for a wider spectrum (-10 through +10), increase resolution, and scale in software. Maybe i can find a way to cram tiny re-calibrate buttons next to each input, capture the min and max, and then map those values to a normalized -1.0 to +1.0 float
Seems good to me! Right, I know some things like V/oct can be fixed 0 to +8V, but if you have generic inputs that doesn't get you too far. So designing for +/-10V in hardware and allowing software calibration to a range within that sounds reasonable!
The MCP3008 seemed really happy with 5V for power and reference. Sometimes eurorack goes into 12V (10-ish?) and negatives (positives?) which the MCP3008 is thankfully tolerant of (YAY!), but perhaps there's a way to tone down those stronger and plus-minus signals auto-magically since lots of oscillators use them.
Or not, and I need to include a switch for every input. :/