Author |
Message |
capicoso
Joined: Nov 19, 2012 Posts: 128 Location: Argentina
|
Posted: Tue Apr 29, 2014 6:56 pm Post subject:
Arduino midi 2 cv without dedicated dacs Subject description: R2R ladder |
 |
|
Hello. So the last week I designed this midi 2 cv with arduino. It makes use of two R2R 7bit dac. Inexpensive and easy to build. Here in my country it's impossible to get dacs from Microchip or Maxim. The only ones we can get are the 083x dacs, they're very expensive here, and also sometimes it's hard to get them.
So... i decided to build an R2R dac.
It works fine, i didn't match the resistors, they're 1%, I suppose if they're matched to 0,1%(or maybe an array of resistors) it'll be better. But I measured it and it was pretty good.
I share it with you.
I didn't add the clock part yet, although i already programmed it and tested it on another device, if anyone is interested in this feature I'll add it.
Any suggestions are welcome. The next version will be polyphonic
Description: |
|
Filesize: |
224.33 KB |
Viewed: |
3877 Time(s) |
This image has been reduced to fit the page. Click on it to enlarge. |

|
Description: |
|
 Download |
Filename: |
AM2CV.zip |
Filesize: |
1.32 KB |
Downloaded: |
1352 Time(s) |
|
|
Back to top
|
|
 |
DUBmatze

Joined: Feb 18, 2013 Posts: 150 Location: south Germaica (schwabilon)
|
Posted: Wed Apr 30, 2014 12:58 am Post subject:
|
 |
|
thats cool!
what is the voltage range of the cv behind the OPamps? |
|
Back to top
|
|
 |
capicoso
Joined: Nov 19, 2012 Posts: 128 Location: Argentina
|
Posted: Wed Apr 30, 2014 9:02 am Post subject:
|
 |
|
the voltage at the dac output range from 0v to 4,96v. At the opamps output it's 0v-10v |
|
Back to top
|
|
 |
Sebo

Joined: Apr 27, 2007 Posts: 564 Location: Argentina
|
|
Back to top
|
|
 |
Cynosure
Site Admin

Joined: Dec 11, 2010 Posts: 966 Location: Toronto, Ontario - Canada
Audio files: 82
|
Posted: Thu May 01, 2014 11:00 pm Post subject:
|
 |
|
You can also set the PWM outputs to 60kHz and use them with a low-pass filter that has a high cutoff. That gives you an 8bit resolution.
I tested this with a Monotron and it worked well.
But the Monotron is only 0-5V. I don't know how useful 8bits of resolution will be across a 10V range. Have you tested your 7bit solution with an oscillator? |
|
Back to top
|
|
 |
capicoso
Joined: Nov 19, 2012 Posts: 128 Location: Argentina
|
Posted: Mon May 05, 2014 5:01 pm Post subject:
|
 |
|
I thought PWM wasn't accurate, before building this one, I googled a little and the result wasn't very good for PWM, but that was with stock PWM, not at 60KHz.
I tested it with a yusynth vco and it was fine, however, I'll also build one with dac0808 , this one is cheap and not so hard to find here. At least for the note cv, i'll compare them.
Then if everything is fine i'll build it with 595 shifters and make it with at least 2 note cv outs. I need it for my 8x2 sequencer, so i'll do it with different midi channels |
|
Back to top
|
|
 |
Cynosure
Site Admin

Joined: Dec 11, 2010 Posts: 966 Location: Toronto, Ontario - Canada
Audio files: 82
|
Posted: Tue May 06, 2014 4:17 am Post subject:
|
 |
|
capicoso wrote: | I thought PWM wasn't accurate, before building this one, I googled a little and the result wasn't very good for PWM, but that was with stock PWM, not at 60KHz. |
It doesn't behave in a 1:1 ratio, probably in part due to the lowpass filter, so I had to tune the PWM setting for each MIDI note. It took a while, but I only did it across a five octave range.
It was a while ago that I tested it, but I think I got up to the highest A# before the voltage was limited and the tuning went flat. Also, the lowest C had to be set to change the PWM output to a digital OFF because the PWM can never get down to 0V.
It wasn't perfect, but it did the job for a 0-5V range with a Monotron, which isn't too great at staying in tune anyway. |
|
Back to top
|
|
 |
Benjamin AM

Joined: Nov 04, 2010 Posts: 82 Location: Boise
|
Posted: Wed May 28, 2014 8:57 am Post subject:
|
 |
|
Looking forward to this project. I randomly found an Arduino Nano the other day. I assume that it would work for this project. Right? |
|
Back to top
|
|
 |
Benjamin AM

Joined: Nov 04, 2010 Posts: 82 Location: Boise
|
Posted: Tue Jun 03, 2014 1:44 pm Post subject:
|
 |
|
Hey capicoso.
I breadboarded this circuit today and it's pretty great. I am experiencing one problem though, I seem to be getting stuck notes every once in a while. It happens more often when I am playing fast notes. I'm not much of an Arduino buff so I don't know where to begin to fix this issue. Any suggestions? |
|
Back to top
|
|
 |
Cynosure
Site Admin

Joined: Dec 11, 2010 Posts: 966 Location: Toronto, Ontario - Canada
Audio files: 82
|
Posted: Wed Jun 04, 2014 7:37 am Post subject:
|
 |
|
That can be caused by many different things. Here are some steps on how to fix it.
1. Check your midi connection. Make sure that there are no loose wires. If you are using breadboard, then consider soldering together at least the midi portion of it for the remainder of your testing.
2. Optimize your code. If you are doing too much and using up too many cycles in your main loop where the midi is handled, then you will run into this problem. In addition to optimizing your code, also only do things as often as is necessary. For example, you probably don't need to read all of your pots every time your program runs through the main loop. Read just one of the pots every 5 or more times that the loop runs.
3. Connect your controller directly to the arduino. Routing it through a computer and DAW can cause issues. Some DAWs will bunch up midi messages and spit them out in batches. This overloads the buffer in the arduino.
4. Increase the rx input buffer. I think that the default size is 64, but you can increase it to 128. You need to edit a file that the arduino compiler uses. I don't remember the name of the file, but you should be able to find it if you search the arduino forums.
One other thing that probably isn't this problem but that you should consider - your code should handle both NoteOff and notes with 0 velocity as note off messages. |
|
Back to top
|
|
 |
gdavis
Joined: Feb 27, 2013 Posts: 359 Location: San Diego
Audio files: 1
|
Posted: Wed Jun 04, 2014 2:40 pm Post subject:
|
 |
|
Cynosure wrote: |
One other thing that probably isn't this problem but that you should consider - your code should handle both NoteOff and notes with 0 velocity as note off messages. |
I've been wondering if the Arduino MIDI library is smart enough to call handleNoteOff when it receives a 0 velocity or if I need to explicitly check for that in my handleNoteOn function.
Edit: eh, guess not. Looking at midi.cpp source code it just selects the callback function based on the message type. So handleNoteOn better check the velocity and call handleNoteOff if it's zero. _________________ My synth build blog: http://gndsynth.blogspot.com/ |
|
Back to top
|
|
 |
capicoso
Joined: Nov 19, 2012 Posts: 128 Location: Argentina
|
Posted: Fri Jun 06, 2014 10:04 pm Post subject:
|
 |
|
Hey.
The only problem I found that i'll fix it when i have time, is that when you play in legato, for example, note 60 and then 62 without releasing 60, when you release 62, it'll still send the voltage for 62 and not 60. I didn't mind because this is for my sequencer, and it's monophonic so this never happens. But i'll fix it when asap and also add the clock out.
Glad you like it Benjamin. Could you be more specific with your problem? Maybe it's because the bug I mentioned earlier? The legato thing. The gate gets stuck? Or the cv out? When it's stuck on a note and you play another one does it change?
It should work with arduino nano yes, if it's the atmega328 one 100% sure. If it's the 168 i'm 99.9% sure . The ram on the 168 is only 1k, my code uses very little though.
The file to edit the input buffer is the hardwareSerial if i remember correctly, however, look at your ram usage.
By the way, acording to my code, it should handle both noteoff and noteon velocity 0.
this responds to note off message:
Code: | if(data == 128){
notaGate = LOW;
state = 1;
} |
and this to velocity 0:
Code: | if((gate == HIGH) && (velocity == 0)){
gate = LOW; // note on velo 0 = noteoff
for(int output = 9; output < 16; output++){
digitalWrite(output, LOW);
} |
I'll fix the legato thing and add the midi clock soon. The subdivision of the clock will be selectable by editing a variable in the code, or if someone wants, edit it and use a rotary switch.
My sequencer now is going to be duophonic, so i'll need to make a duo midi2cv. I'll update it when i have it(not so soon), however, it'll be especially to be driven with sequencers, so no keyboard poly, differents midi channels. Once that's done, I may make one polyphonic for keyboard.
thanks for the feedback
edit: For me, it's better to not use the midi library, the code is very simple, it's even more simple than the midi library, works better, less ram, less flash, etc. My sequencer has the option for midi thru, first I did it with the midi library, it made the performance sluggish, without the library went good. |
|
Back to top
|
|
 |
Benjamin AM

Joined: Nov 04, 2010 Posts: 82 Location: Boise
|
Posted: Thu Apr 16, 2015 4:47 pm Post subject:
|
 |
|
@capicoso- I came across my abandoned breadboard the other day and started thinking about Midi possibilities. I'm curious if you modified the code within the last year? |
|
Back to top
|
|
 |
capicoso
Joined: Nov 19, 2012 Posts: 128 Location: Argentina
|
Posted: Thu Jun 11, 2015 9:02 pm Post subject:
|
 |
|
Benjamin AM wrote: | @capicoso- I came across my abandoned breadboard the other day and started thinking about Midi possibilities. I'm curious if you modified the code within the last year? |
hey, sorry for the delay. I'm now doing a duophonic midi 2 cv with mcp4922 for my sequencer and I remembered about this.I just wrote a new sketch, I don't have the hardware to test it, but i tested it with oscilloscope. Check your inboxes. I'll appreciate the feedback |
|
Back to top
|
|
 |
jbeuckm

Joined: Nov 30, 2008 Posts: 165 Location: Stockholm
Audio files: 9
|
Posted: Fri Jun 19, 2015 9:24 am Post subject:
|
 |
|
I'm currently improving my atmega328->4822 mono midi-cv, but this 4-voice one works pretty well too. one of my updates will be to install the ICP header for quick software updates. another is to redo the gate outputs - modify these if you build...
https://github.com/jbeuckm/atmega_midi_cv_polysynth |
|
Back to top
|
|
 |
Benjamin AM

Joined: Nov 04, 2010 Posts: 82 Location: Boise
|
Posted: Tue Jun 23, 2015 4:42 pm Post subject:
|
 |
|
capicoso wrote: | Benjamin AM wrote: | @capicoso- I came across my abandoned breadboard the other day and started thinking about Midi possibilities. I'm curious if you modified the code within the last year? |
hey, sorry for the delay. I'm now doing a duophonic midi 2 cv with mcp4922 for my sequencer and I remembered about this.I just wrote a new sketch, I don't have the hardware to test it, but i tested it with oscilloscope. Check your inboxes. I'll appreciate the feedback |
I took this off my breadboard the day before this response. Dang! I'll have to start over. Is the clock feature implemented? |
|
Back to top
|
|
 |
braincell
Joined: Jun 24, 2015 Posts: 14 Location: UK
|
Posted: Wed Jun 24, 2015 12:58 pm Post subject:
|
 |
|
I looked at the poly which looks cool , how easy would it be to convert to mono ?
lee |
|
Back to top
|
|
 |
Dodecasonico
Joined: Jul 12, 2015 Posts: 4 Location: México
|
Posted: Sat Apr 30, 2016 9:35 am Post subject:
|
 |
|
Can I put this on a +\- 15 PSU ?? |
|
Back to top
|
|
 |
borodat
Joined: Oct 02, 2017 Posts: 1 Location: Черкассы
|
Posted: Sat Aug 25, 2018 6:55 am Post subject:
Re: Arduino midi 2 cv without dedicated dacs Subject description: R2R ladder |
 |
|
Dear Capicoso !
I am very grateful for your post "Arduino midi 2 cv without dedicated dacs" !
Can i very much ask for your help?
Long notes Gate work fine, but short notes (staccato) cause the Gate to "hang" in the open state, and the Gate no longer responds to notes (midi cv in this situation continues to work fine!).
I use Arduino UNO and an optoisolator PC900V.
Thanks in advance ! It's a matter of life or death))
With great respect... |
|
Back to top
|
|
 |
|