FAQ & Terms of UseFAQ & Terms Of Use   Wiggler RadioMW Radio   Muff Wiggler TwitterTwitter   Support the site @ PatreonPatreon 
 SearchSearch   RegisterSign up   Log inLog in 

HELP 1VOCT Analog Keyboard Controller w/ Arduino
MUFF WIGGLER Forum Index -> Music Tech DIY  
Author HELP 1VOCT Analog Keyboard Controller w/ Arduino
Kevin Mitchell
Hello! For a few weeks now I've been picking at a controller project of mine. I've been tinkering with modular synth stuff and could really use a CV controller. I've snagged a Fatar synth keyboard and worked out mapping the keys with an arduino nano board and was using a PWM pin as CV output to experiment. But I'm using a 5 octave keyboard (61 keys) and the <5v on the arduino will not be enough for scaling notes C1 to C6 and probably not a clean enough signal to use as CV.

I believe I need a decent DAC to get the job done. The problem here is I'm very new to synths, haven't written original code in years and would not know what DAC device would be ideal for this project. If the fine folks of this forum have any pointers to lend I would very much appreciate it! This week I would like to finish up the circuit with modulation and pitch wheels so I can box everything up!

I aim to design a polyphonic controller with 3 CV outputs. Just stumped on the digital to analog part for a good CV signal!
I would suggest the MCP4812 dac from Microchip. It uses an SPI interface and you should have no trouble finding example code and circuits using it. You will need an amplifier after it to get enough voltage to cover the keyboard range.

Datasheet.. p4822.pdf

Code... le1/MCP48x2_example1.ino
Kevin Mitchell
Thanks. I was going to snag the 12bit verson but wanted to know what other DACs would be ideal. These SPI chips seem likely to be my best bet.

I've spent some time last night learning about the operations of opamps - after 3+ years of making stompboxes I'm finally learning the engineering side Mr. Green . From what I understand designing an amplifier shouldn't be difficult.

I guess I'll need a few DAC chips if I want multiple CV outputs.
Kevin Mitchell
I've noticed those MCP DACs have dual configuration. So It would produce two CV signals?

If I aim to have at least 3 CV signals perhaps I should source a quad DAC that works through SPI so the microcontroller pins aren't all tied up - considering how the scan matrix already occupies most of them.

I'm trying to wrap my head around "bits" and how this plays into the DAC's resolution and what I need done. Also I'd have to source examples of the quad DACs I'm seeing. Cheapest being the MAX5250. DATA SHEET
Those MAX chips are expensive, especially the 12 bit ones. 12 bits is worth doing, especially for midi CC and pitchbend.

Running two MCP4822 dacs instead of one, would tie up only one more pin on the MCU. They can share the SPI signals (SCK and SDI) and have a chip select (CS) line each. So four pins total.

The first answer here has an example.. -for-different-slaves

If you are really pressed for I/O, you might be able to use a single CS pin and run it through an inverter to the second DAC, so it is high on one dac and low on the other or vice-versa. I'd test that on a breadboard though, as I haven't tried it myself. You might have some CD4069 IC's sitting around from your guitar pedal building wink
I used two mcp4922 dacs for a teensy project I recently finished that required four CV outputs.
Worked great and they are cheap, but you do need an external reference.
You might also want an opamp with a trimmer behind each CV channel to buffer and scale the signal.
Kevin Mitchell
I've purchased the MAX5250 so I can get started experimenting. Totally should have added 2 MCP4922 chips to the order. But Im curious to see if I can get good resolution with 10bits for 61 keys with room for pitch bend on both low and high notes.

Can anyone share some info on how the note/voltage data is entered to the DAC and how to adjust the output voltage with an amplifier circuit to set it for 1volt per octave CV? Just wondering what worked for others. FYI - this project will have no MIDI data and is just scanning the keys and outputting 3 1volt per octave CV signals and one gate. I will likely redesign some things as I find more use of the controller - such as note priority programming, sequence recording w/ speed & spacing, note data display and some other tricks.

I hope to transfer the code to a smaller MCU such as an ATtiny device when everything is done. I/O pins aren't a big deal since I'm still designing the thing but I do plan on turning this into a standalone board without the arduino. This project is a great learning experience for myself.
On the digital side, you need to scale the 61 keys to 10 bit values. If you work with 64 instead of 61 the numbers will line up nicely....

DAC = ( 1024 / 64 ) * key

..where key is 0-60. The top key would have a DAC value of (1024/64)*60 = 960.

From the data sheet for the MAX5250 table 2, Vout = Vref * (DAC/1024)

Assuming you use an LM-4040 2.5v voltage reference, for the top key you get Vout = 2.5 * ( 960/1024) = 2.34375v

What you really wanted was 5volts, sincce you are using 1v/oct and the top key is 5 octaves up.

If you look at figure 10 in the max5250 datasheet, you see the DAC output setup with a non-inverting opamp amplifier. You need to calculate the resistors to replace the 10k resistors in the diagram. If you go here.. 4375&vout=5&rin=&rf=10

.. there is a non-inverting op amp calculator. If you set the input voltage to 2.34375, output to 5v and one resistor to be 10k, the other resistor is calculated as 8.82k. You can use an 8.2k resistor in series with 1k trimmer. Then once you are done, you press the top key and adjust the trimmer to give 5v.
widdly wrote:
If you are really pressed for I/O, you might be able to use a single CS pin and run it through an inverter to the second DAC, so it is high on one dac and low on the other or vice-versa.

Not recommended because in that case the spi is always active on this device and you could get problems if you program the processor by spi.
Besides that: it is not common use of the spi bus.
Kevin Mitchell
Thank you very much, widdly for breaking that down for me! I've learnt about opamp configurations the other night so I'd have a better idea of how these things work. I should have learnt this stuff long ago meh

So with that setup I'll get notes C0-C5. If I really want C1-C6 (1-6 volts) perhaps I should add an additional non-inverting opamp configuration with higher voltage going to the supply pins.

Here's some math I slapped together;
VR(960/1024)(Rf/Rg + 1) = DACout
to external non-inverting opamp for CV greater than 5v (opamp gets 12v to power)
DACout(Rf/Rg + 1) = Amplified CV for C1-C6 scale
Rf = 10k and Rg = 50k for the external amp
I think amplifying the voltage with a non-inverted opamp config to get +1 volt will be an issue if the DAC is putting out 0 volts (for key 1). I will have to tinker when the part comes in tomorrow.

Do you think getting VR from a resistor divider would be an issue? Though for consistency reasons perhaps it's best to obtain all power references from regulators. I'll draw out a schematic after I play with that calculator and choose resistor values. I hope I'm not misunderstanding anything here.
Personally, I wouldn't bother doing the C1-C6 idea. Usually your VCO has a coarse knob or octave switch built in.

One way to do it would be a dc mixer and mix the DAC output with 1v. You could add in other voltages via a switch to get octave switching.

The LM4040 2.5 referece is a really cheap part. You could do it with regulators and resistor dividers too. It would be a little less accurate though.
Kevin Mitchell
Thank you very much. I'm just curious of how I'd go about getting voltages higher than 5v for a wider scale of notes - instead of relying on the synth module alone to select the tuning/scale.

This weekend I hope to have the time to tinker with the pitch shift and modulation part of the controller.

Today I'll purchase a couple MCP4822 DACs, some LM4040 2.5v shunts and anything else that comes to mind for my parts bin. I aim to etch the control board next week. Also I'll probably hit the lumber yard this weekend to start building the cabinet.
MUFF WIGGLER Forum Index -> Music Tech DIY  
Page 1 of 1
Powered by phpBB © phpBB Group