electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Arduino
mini MIDI to CV converter with Gate and Trigger outputs
Post new topic   Reply to topic
Page 1 of 1 [20 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Wed Oct 09, 2019 3:27 pm    Post subject: mini MIDI to CV converter with Gate and Trigger outputs
Subject description: uses Arduino nano & MCP4725 DAC
Reply with quote  Mark this post and the followings unread

I added a simple MIDI to CV converter to a MIDI keyboard. At the moment it only makes use of NoteOn and NoteOff messages but I might
add Pitch Bend later. The keyboard I used also has some knobs that send out CC messages so maybe I will do something with that too.
I tapped the midi signal of from the keyboard PCB but if you want to use it with a regular MIDI input you can add the circuit with the 6n137
optocoupler. I don't have the right rotary encoder (with a switch) yet so that'll be installed when it arrives. (could take a couple of weeks)

Here's some info, a schematic, the arduino sketch and some photos.
Code:
// * ============================================================================================================================== *
// * DESCRIPTION:                                                                                                                   *
// * ------------                                                                                                                   *
// * This is a very basic MIDI to CV converter originally intended to be added to a MIDI keyboard[*]. It has a 1V/Oct CV output     *
// * with a range of 5 octaves (in semitones) and it will ignore any MIDI notes that are out of this range. The MIDI octave range   *
// * it responds to can be adjusted in the code (low_octave) and can be set between -1 (octaves -1 to 3) and 4 (octaves 4 to 8).    *
// * It can be set higher but then the total range will of course be less than 5 full octaves.                                      *
// *                                                                                                                                *
// * It uses last note priority but doesn't memorize any notes. This means that if you press a key and hold it, then press another  *
// * key the CV will correspond with the last pressed key. But if you release this key it will not return to the CV for the first   *
// * held down key. (the Gate output does however stay on).                                                                         *
// *                                                                                                                                *
// * It also has a Gate output that stays high when at least one note is on and a Trigger output that sends out a short pulse       *
// * whenever a key is pressed (or a new MIDI NoteOn message is received). The length of this trigger pulse can be adjusted in      *
// * the code (trigger_time) but it is not 100% accurate.                                                                           *
// *                                                                                                                                *
// * The first time the arduino is booted it uses preset values to control the DAC. These might work straight away but because      *
// * the DAC uses the supply voltage as a reference and isn't entirely linear it will probably need some calibration.               *
// * There are 2 calibration procedures;                                                                                            *
// * - Quick calibration calculates all the values for the DAC based on 1 setting but is not very accurate.                         *
// * - Note calibration makes it possible to precisely adjust and store the output voltage for each note individually at any        *
// *   given time. (this could also be used for creating non-western tuning scales)                                                 *
// *                                                                                                                                *
// *                                                                                                                                *
// * [*]requires some extra circuitry for an external MIDI connection.                                                              *
// *                                                                                                                                *
// * ============================================================================================================================== *

(there's some more info in the sketch)


mini MIDI to CV [V1.0].gif
 Description:
 Filesize:  53.49 KB
 Viewed:  281 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

mini MIDI to CV [V1.0].gif



MIDI plus CV mod - 01.jpg
 Description:
 Filesize:  99.71 KB
 Viewed:  102 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

MIDI plus CV mod - 01.jpg



MIDI plus CV mod - 02.jpg
 Description:
 Filesize:  136.09 KB
 Viewed:  96 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

MIDI plus CV mod - 02.jpg



MIDI plus CV mod - 03.jpg
 Description:
 Filesize:  151.06 KB
 Viewed:  115 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

MIDI plus CV mod - 03.jpg



MINI_MIDI_TO_CV_V1_0.ino
 Description:

Download
 Filename:  MINI_MIDI_TO_CV_V1_0.ino
 Filesize:  42.66 KB
 Downloaded:  175 Time(s)


_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ixtern



Joined: Jun 25, 2018
Posts: 143
Location: Poland

PostPosted: Mon Oct 14, 2019 1:03 am    Post subject: Reply with quote  Mark this post and the followings unread

Thanks! Nice simple solution and clear understandable software. Although I have Midi2CV from Erica Synths, I am thinking about my own to make.
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Mon Oct 14, 2019 2:33 pm    Post subject: Reply with quote  Mark this post and the followings unread

Very Happy

here's version 1.1 with some small changes:
- replaced digitalWrite for Trigger and Gate outputs with direct PORT manipulation (faster).
- moved the encoder debounce from the adjust_dac_value() function to the read_enc() function.
- added inputs for (DIP)switches to set the octave range.

The switches are optional and if left out the default range (set with low_octave) is used.


mini MIDI to CV [V1.1].gif
 Description:
 Filesize:  56.58 KB
 Viewed:  211 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

mini MIDI to CV [V1.1].gif



MINI_MIDI_TO_CV_V1_1.ino
 Description:

Download
 Filename:  MINI_MIDI_TO_CV_V1_1.ino
 Filesize:  48.76 KB
 Downloaded:  173 Time(s)


_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ixtern



Joined: Jun 25, 2018
Posts: 143
Location: Poland

PostPosted: Tue Oct 15, 2019 4:47 am    Post subject: Reply with quote  Mark this post and the followings unread

Maybe it would be better to separate initial debug sequence with if statement and debug on/off variable (or debug define). Debug is very useful during development and test phases but not needed when code is mature so anyone can set temporary debug preference.

I prefer such approach in my sketches. With if - all debugs are ommited during execution, with define - debugs are not compiled making program smaller (if there are many and complex debugs).
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Tue Oct 15, 2019 10:00 am    Post subject: Reply with quote  Mark this post and the followings unread

I am not sure what 'initial debug sequence' you are refering too.
Almost thought I accidentally uploaded a test version.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
ixtern



Joined: Jun 25, 2018
Posts: 143
Location: Poland

PostPosted: Wed Oct 16, 2019 3:23 am    Post subject: Reply with quote  Mark this post and the followings unread

PHOBoS wrote:
I am not sure what 'initial debug sequence' you are refering too.
Almost thought I accidentally uploaded a test version.

This one (apart from reading data from eeprom):

Code:

// copy data from the EEPROM to the dac_data[] array and print a list of all the values
  Serial.begin(9600);                   // set the baudrate to 9600kbps for the serial monitor
  Serial.println("values for the DAC stored in EEPROM:");
  for (byte n=0; n<=60; n++) {
    read_dac_data_from_eeprom(n);       // copy the EEPROM value corresponding with note n to the dac_data[] array
    Serial.println(dac_data[n]);        // print value
  }
  Serial.flush();                       // wait untill all the serial data has been send
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Wed Oct 16, 2019 6:09 am    Post subject: Reply with quote  Mark this post and the followings unread

oh, that's a feature Laughing
I thought it might be usefull if you calibrated it and wanted to save the dac settings for some reason.
I used it myself to paste into the preset array after calibration, and it could be used to save different scales.
You can take it out of the code but I don't really see a downside to it being there.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Pastor McPurvis



Joined: Nov 09, 2018
Posts: 4
Location: Lake Worth, Florida, USA

PostPosted: Fri Nov 22, 2019 2:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hey PHOBoS,

Just wanted to say thanks! Built this the other week and it is working great.
Basically built it up on veroboard and have it behind a plywood panel (it is the middle panel in the pic below).

Thanks again!


PHOBoS_midicv.jpg
 Description:
 Filesize:  1.46 MB
 Viewed:  57 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

PHOBoS_midicv.jpg


Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Fri Nov 22, 2019 3:34 pm    Post subject: Reply with quote  Mark this post and the followings unread

awesome! cheers
I like the panel designs, makes me curious what the one on the left is.

I am working on a version with an arpeggiator but haven't implemented the latch function yet. All controls are done through
midi CC so it wouldn't require any extra (or changes in) hardware, besides maybe an input for an external clock input.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Pastor McPurvis



Joined: Nov 09, 2018
Posts: 4
Location: Lake Worth, Florida, USA

PostPosted: Fri Nov 22, 2019 3:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

The one on the left is a simple passive multiple I use to split CV, and a power input because I set up my power supply as a bench top unit to use both for testing and power for the rack.

The additions sound great. I'll be sure to keep an eye out for them.

All the best!
Back to top
View user's profile Send private message
bubzy



Joined: Oct 27, 2010
Posts: 593
Location: United Kingdom
Audio files: 63

PostPosted: Sun Jul 12, 2020 1:16 am    Post subject: Reply with quote  Mark this post and the followings unread

hi phobos!
wondering how difficult it would be to implement multiple channel outs?
obviously would require separate DACS for each out but could make sequencing from software more interesting Very Happy

_________________
_Richard_ Smile
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Sun Jul 12, 2020 7:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

hi bubzy Very Happy

you mean multiple CV outs by using multiple midi channels ?

that would be possible and yeah you need more DACs. The nano only has 2 I2C outputs and I don't think you can even change it on the DAC.
You could use a DAC with multiple outputs though. Not exactly sure if tuning would work well as the voltage for every note is stored in the
internal eeprom and there's not much room in there, but that could also be added. Code wise it probably wouldn't be that hard to do.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23280
Location: The Netherlands, Enschede
Audio files: 255
G2 patch files: 320

PostPosted: Mon Jul 13, 2020 4:59 am    Post subject: Reply with quote  Mark this post and the followings unread

Usually you can have like 8 of the same device on one i2c channel with external address selection bits ... that would be a bit hard with a 6 pin device though .. time to have a look at the data sheet [1] ...

Ah, datasheet says the DAC has one external address line A0, so you can have two per i2c interface ...

And then it also says that that it has 8 possible addresses .. hmm .. how .. right .. that comes form the order code [2] ... you can order different combinations of A1 and A2 .. so that makes eight per i2c channel .. so then you could have 16 ananalog outputs Shocked

Hmm .. but you'll have to contact µChip about that, default for (A2, A1) seems to be (0, 0) ... so the other three combinations may be for big customers only ...

Four then I guess on two i2c channels.

[1] https://www.microchip.com/wwwproducts/en/en532229

[2] order codes are: MCP4725 xx T E /CH where xx can be A0, A1, A1 or A2 for address bits (A2,A1) being (0,0), (0,1), (1,0) or (1,1)), T for tape and reel. E for temperature range, /CH for package type.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.

Last edited by Blue Hell on Mon Jul 13, 2020 5:09 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23280
Location: The Netherlands, Enschede
Audio files: 255
G2 patch files: 320

PostPosted: Mon Jul 13, 2020 5:02 am    Post subject: Reply with quote  Mark this post and the followings unread

Hmm .. they seem a bit expensive too?

Edit, stumbled on a bad supplier I guess .. also seeing now that Mouser has A1, A2 and A3 versions as well as A0. Cool

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Mon Jul 13, 2020 5:40 am    Post subject: Reply with quote  Mark this post and the followings unread

you can also use an I2C mux like the 8 channel TCA9548A which you can get on ebay for around 2,-
_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 23280
Location: The Netherlands, Enschede
Audio files: 255
G2 patch files: 320

PostPosted: Mon Jul 13, 2020 6:47 am    Post subject: Reply with quote  Mark this post and the followings unread

PHOBoS wrote:
TCA9548A


Interesing chip, it does bus voltage level translations too.

_________________
Jan
also .. could someone please turn down the thermostat a bit.
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Back to top
View user's profile Send private message Visit poster's website
gabbagabi



Joined: Nov 29, 2008
Posts: 610
Location: Berlin by n8
Audio files: 23

PostPosted: Mon Jul 13, 2020 10:41 am    Post subject: Reply with quote  Mark this post and the followings unread

do you've used the arduino that is ava on tayda ?

https://www.taydaelectronics.com/nano-3-0-controller-compatible-with-arduino-nano-ch340-usb-driver.html

for those who care about insects (as i do alot) they have also this
https://www.taydaelectronics.com/arduino-pro-mini-atmega328p-16mhz-5v.html
a bug and a half cheaper, dunno if it has I2C?
i can imagine the pinout is not equal, so it would need code adaption if i would use the cheaper one?

it seems u have the dac in a red enclosure? is it a kind of smd2dip adapter?

anycase nice compact and extremly usefull circuit this is!
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Mon Jul 13, 2020 11:47 am    Post subject: Reply with quote  Mark this post and the followings unread

Oh, I hadn't noticed Tayda sells arduinos too! Shocked

I'd have to look at the specs for the pro mini but I doubt it is very different. However, it doesn't have a USB port so programming it is a little bit less
convenient. Code will probably work mostly as it is, because the actual pin mapping is done by the IDE. For example in the code the encoder button
is connected to digital pin 4 which is actually pin 22 on the nano and a different pin on the pro mini but it doesn't have to be adjusted. Of course you
will have to connect the button to the correct pin. Maybe the I2C pins are different let me check,..

nope, looks like those are the same too, I guess it makes sense as both boards are based on an ATmega328P.


Quote:
it seems u have the dac in a red enclosure? is it a kind of smd2dip adapter?

Not really an smd2dip adapter as it has some other components on it aswell but similar.
They are designed that way to be used with arduinos and you can plug it in a breadboard.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
bubzy



Joined: Oct 27, 2010
Posts: 593
Location: United Kingdom
Audio files: 63

PostPosted: Tue Jul 14, 2020 10:15 am    Post subject: Reply with quote  Mark this post and the followings unread

welp, i built the single version on breadboard quickly and it works like a charm Smile nice job.
will dig into your code and see if i can play about, maybe get a few mcp4922's running.
does the midi library support polyphony? Very Happy

_________________
_Richard_ Smile
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4862
Location: Moon Base
Audio files: 650

PostPosted: Tue Jul 14, 2020 10:33 am    Post subject: Reply with quote  Mark this post and the followings unread

great to hear it works! Very Happy

Polyphony would work fine. All the midi library does is make it easier to process the midi signals.
Unless there is some sort of polyphonic midi command I am not aware of.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic
Page 1 of 1 [20 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Arduino
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use