Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 16 of 16

Thread: [queued] (yet another) MIDI to CV Converter!

  1. #1

    [queued] (yet another) MIDI to CV Converter!

    I'm sure this project has been done countless time, but this one is mine, and comes in a nifty 3D printed case!

    Click image for larger version. 

Name:	IMG_1630.JPG 
Views:	64 
Size:	246.6 KB 
ID:	12427

    It's a multi-channel USB MIDI to CV converter based on the Teensy 2.0, the perfect interface between your computer or iPad and an analog synthesizer. It can independently drive up to three oscillators with 1V/octave CV inputs. This device has the following features:
    • Three channel Note CV output (88 keys, 1V/octave, MIDI channels 1-3) using a 12-bit DAC
    • Configurable note priority for each channel (Top Note, Bottom Note, or Last Note Priority)
    • 5V Gate/Trigger outputs, where each channel can be independently configured to either output a gate (output high for entire length of time that note is on) or trigger (20 msec pulse each time a new note is initiated)
    • Velocity CV output (0 to 4V) for each channel
    • Pitch Bend CV output (0.5 +/- 0.5V), which can be configured for channel 1, 2, or 3
    • Control Change CV output (0 to 4V), which can be configured for channel 1, 2, or 3
    • OLED user interface, used for setting parameters and saving to EEPROM


    I've posted the entire project on Github (code, STL files for 3D printed case, Eagle files for PCB) at: https://github.com/elkayem/usbMIDI2CV_MC

    Here are a few more pics:

    Click image for larger version. 

Name:	IMG_1631.JPG 
Views:	57 
Size:	199.7 KB 
ID:	12428 Click image for larger version. 

Name:	IMG_1623.JPG 
Views:	67 
Size:	142.1 KB 
ID:	12429 Click image for larger version. 

Name:	IMG_1639.JPG 
Views:	60 
Size:	84.5 KB 
ID:	12430 Click image for larger version. 

Name:	IMG_1622.JPG 
Views:	55 
Size:	154.1 KB 
ID:	12431 Click image for larger version. 

Name:	IMG_1619.JPG 
Views:	61 
Size:	139.4 KB 
ID:	12434Click image for larger version. 

Name:	IMG_1627.JPG 
Views:	63 
Size:	125.3 KB 
ID:	12432 Click image for larger version. 

Name:	IMG_1628.JPG 
Views:	55 
Size:	121.3 KB 
ID:	12433

  2. #2
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    879
    Code:
    //    noteMsg = 87 -> 4096 mV
    // DAC output will be (4095/87) = 47.069 mV per note, and 564.9655 mV per octive
    // Note that DAC output will need to be amplified by 1.77X for the standard 1V/octive
    So you do this with fixed resistors in an op amps feedback path.

    Doesn't this leave intonation dependant on the accuracy of the resistors with no adjustment in hardware or software to tune performance?

  3. #3
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,461
    Normally, a "norm" pitch CV output should be internally adjustable with 10turn trim pots for offset and gain of the analog output stage, so that midi note 60 corresponds exactly 0.0000V, midi note 0 to -5.0000V, and midi note 127 to 5.5833V.

    What I did several time ago on another MCU platform was using 2 14bit PWM outputs for pitch CV. 14bit allowed me to handle the note value and the corresponding cents. One output was fixed at 60 << 7 plus or minus a digital offset correction. The second output got the true CV. Both outputs were connected to a differential amplifier, followed by a 4th order active Sallen-Key filter with fine-tunable gain. Up to there, I used 3 of a quad op-amp, so that one was left over as a voltage follower buffer at the CV output.

  4. #4
    Quote Originally Posted by oddson View Post
    So you do this with fixed resistors in an op amps feedback path.

    Doesn't this leave intonation dependant on the accuracy of the resistors with no adjustment in hardware or software to tune performance?
    Take a look just a little bit further in the code snippet you shared. You will clearly see that I do provide a means to tune in software. This is also detailed in the instructions I provided. I prefer to measure and tune this way and save on the trimpot in hardware.

    Code:
    // Rescale 88 notes to 4096 mV:
    //    noteMsg = 0 -> 0 mV 
    //    noteMsg = 87 -> 4096 mV
    // DAC output will be (4095/87) = 47.069 mV per note, and 564.9655 mV per octive
    // Note that DAC output will need to be amplified by 1.77X for the standard 1V/octive 
    #define NOTE_SF_CH0 47.069f // Can set three scale factors independently based on as-measured values
    #define NOTE_SF_CH1 47.069f
    #define NOTE_SF_CH2 47.069f

  5. #5
    Quote Originally Posted by Theremingenieur View Post
    Normally, a "norm" pitch CV output should be internally adjustable with 10turn trim pots for offset and gain of the analog output stage, so that midi note 60 corresponds exactly 0.0000V, midi note 0 to -5.0000V, and midi note 127 to 5.5833V.

    What I did several time ago on another MCU platform was using 2 14bit PWM outputs for pitch CV. 14bit allowed me to handle the note value and the corresponding cents. One output was fixed at 60 << 7 plus or minus a digital offset correction. The second output got the true CV. Both outputs were connected to a differential amplifier, followed by a 4th order active Sallen-Key filter with fine-tunable gain. Up to there, I used 3 of a quad op-amp, so that one was left over as a voltage follower buffer at the CV output.
    Thanks, very useful info! I wasn't aware there was a convention on middle C volt output. I am using only a single sided supply, and limited myself to the 88 notes on the keyboard with A0 (Note 21) = 0V and C8 (Note 108) = 7.25V. I really didn't need to produce negative CV voltages, as the coarse trim on my three VCOs go down to -9.5 V when I turn the coarse tuning knobs all the way to the left. I usually tune the VCO knobs so A4 on my keyboard outputs 440 Hz. My coarse knobs are sitting somewhere between 1/3 and 1/2 of full rotation when I do that.

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,461
    Middle C = 0.000V is not an official convention, but an unofficial standard introduced by R. Moog in the middle of the 1990ies.

  7. #7
    Quote Originally Posted by Theremingenieur View Post
    Middle C = 0.000V is not an official convention, but an unofficial standard introduced by R. Moog in the middle of the 1990ies.
    Seems like something that should be standardized.

    I can’t help noticing your username and the instrument you are playing in your photo. I would love to BUILD (not buy) a Theremin. There are numerous designs out there on the internets, I’m sure some better than others. Any advice?

  8. #8
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    1,461
    Quote Originally Posted by elkayem View Post
    I can’t help noticing your username and the instrument you are playing in your photo. I would love to BUILD (not buy) a Theremin. There are numerous designs out there on the internets, I’m sure some better than others. Any advice?
    These beasts are difficult to build and to master, at least if you want to go beyond the first *wooooooooeeeeeeeeooooo*

    As a start and to familiarize with that technology, I recommend building a simple pitch-only Theremin first before moving over to more complex things. There is an easy to build circuit which I developed and published a few years ago here: http://thereminworld.com/Forums/T/29...eremin-circuit

  9. #9
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    879
    Take a look just a little bit further in the code snippet ....
    Opps... I stuck the "or in software" phrase in as it occurred to me while typing. I meant to go back and check whether you had...

    I had assumed a high voltage DAC to output modular-level voltages would be the obvious choice so I was surprised to see gain in your schematic especially with no trim pot.

    But now I'm glad I asked as I've learned a bit from Th's reply.


    ...oh, very impressive build btw.
    Last edited by oddson; 01-03-2018 at 12:21 PM.

  10. #10
    Quote Originally Posted by Theremingenieur View Post
    There is an easy to build circuit which I developed and published a few years ago here: http://thereminworld.com/Forums/T/29...eremin-circuit
    Oh WOW! Now you’ve got me excited. Your design is exactly what I was hoping for! Now I have my next project. Off to Mouser and eBay to procure some parts...

  11. #11
    Quote Originally Posted by oddson View Post
    I had assumed a high voltage DAC to output modular-level voltages would be the obvious choice so I was surprised to see gain in your schematic especially with no trim pot.
    I would have preferred to use a higher voltage DAC were it not for cost. The 12-bit, 2-channel MCP4822 is hard to beat at $3/chip from Mouser.

    Your post has me thinking, maybe I should make the calibration adjustable in the UI and stored in EEPROM rather than hard-coded through a #define statement. It really only needs to be done once, so not a problem for me at compile time. But I can imagine it might be more of a pain if someone just wants to upload the hex file. An easy feature to add...

  12. #12
    Senior Member
    Join Date
    Nov 2012
    Location
    Boston, MA, USA
    Posts
    1,100
    Quote Originally Posted by Theremingenieur View Post
    Normally, a "norm" pitch CV output should be internally adjustable with 10turn trim pots for offset and gain of the analog output stage, so that midi note 60 corresponds exactly 0.0000V, midi note 0 to -5.0000V, and midi note 127 to 5.5833V.
    Unfortunately the voltage required for C4 on an as-shipped oscillator varies, as does the voltage output by many MIDI to CV units:
    https://learningmodular.com/matching...-your-modular/

    It is also possible that pitchbend will take you outside that 10.66 octave voltage range.

    In practice though most oscillators have a wide tuning range, and not being able to fully express a large pitchbend in the sub-bass or the only-teenagers-can-hear range is not a significant problem in practice.

    I do agree though that longterm voltage stability for pitch CV is poorly addressed in most MIDI to CV products, which is where a custom Teensy-based solution can shine above the alternatives.

  13. #13
    Oddson, you've inspired me to add the ability not only to configure the scale factor calibration at compile time, but through the user interface (and stored in EEPROM). My own build required calibration of only a few tenths of a percent. Even with 1% metal film resistors setting the gain, that's pretty good. Updated code pushed to Github.

    Click image for larger version. 

Name:	IMG_1644.JPG 
Views:	42 
Size:	93.2 KB 
ID:	12536

  14. #14
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Essonne, France
    Posts
    154
    This is a really nice project. I am going to implement something similar for a project I'm working on, instead using the 3.6 and the internal DACs with a split supply powered mux and a S&H circuit to have more outputs (like 8) using the 2 DACs.

    I was wondering though if you're having any ground loop issues in your project. In my design the device would be not powered by USB but from an external supply (ideally the supply of an eurorack system), but even if I'm not taking the VBUS from USB I should still connect the USB ground to my device's ground otherwise data communication would not be reliable, but that will make a ground loop (PC -> USB cable -> my device's ground -> eurorack supply ground).

    How did you handle the grounds of the CV outs?

  15. #15
    Quote Originally Posted by MickMad View Post
    How did you handle the grounds of the CV outs?
    I did not have any ground loop issues. I primarily use my iPad so don't need to worry about the USB ground. At least one ground is required for the CV out, and the others can be disconnected if there are issues. You might look into a USB ground loop isolator if you have issues.

  16. #16
    Senior Member MickMad's Avatar
    Join Date
    Feb 2013
    Location
    Essonne, France
    Posts
    154
    Quote Originally Posted by elkayem View Post
    I did not have any ground loop issues. I primarily use my iPad so don't need to worry about the USB ground. At least one ground is required for the CV out, and the others can be disconnected if there are issues. You might look into a USB ground loop isolator if you have issues.
    I was thinking of adding a USB data lines isolator but current technology only allows for cheap USB isolation up to Full Speed rates (12 Mbps) while I would really like to be able to use the High Speed USB port on the Teensy in the future.

    Anyway I took a look at your schematic for clarity, I'll just try to tie the USB ground to my signal ground and see what happens thanks for the feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •