Thursday, 19 February 2015

Midi for the Arduino - Build a Midi Input Circuit

Less talking, more building!


In this installment we are going to assemble a Midi Input Circuit and connect it to your Arduino UNO. The Circuit itself is actually quite simple consisting of only a handful of parts.

In the last installment, we looked at a Circuit Analysis of a Midi Input and Output Circuit. If you are new to this series, I suggest you check it out. It will give you a better understanding of what you are actually building. Now, let's put this knowledge to use and start building the hardware.

I am assembling the circuit on a small solder-less breadboard. The video will walk you through the steps of putting it together. Take your time and double check your work. You'll be fine!


Parts List (Click links to view parts on Amazon.com)


Schematic (I find it helpful to have a printed copy when I am building)


In the next installment, we look at the Arduino MIDI Library and write software for this circuit.

15 comments:

  1. Hi
    I have problem with your circuit or program for midi in... I did circuit on the prototype board and maybe it works. I have Arduino Mega 2560. I connected this with TX0 (pin 1 on my board) and I see that tx lead blinking, also it's getting the signal. I think the midi library and function not reading massages. :( Function Serial.write() are writing something received with tx communication port. I dont know what I should do now. Please help me!

    ReplyDelete
    Replies
    1. Hi DJ. If you are building a MIDI input you need to use the RX Pin (Receive) instead of the TX Pin (Transmit).

      Delete
    2. thanks Dave, the arrows on the arduino board misled me.

      Delete
  2. Why did you pull pin 7 to ground with the 4.7k resistor in this version? (really I could use an explanation of the entire thing, but I figured this was the difference between the two circuits)

    ReplyDelete
    Replies
    1. Hi Beni. Check out the following post. It explains the whole thing. http://www.notesandvolts.com/2014/11/midi-and-arduino-circuit-analysis.html

      Delete
  3. Great schematic! Thanks, works like a charme! Is it any problem if i used a 10k resistor instead of 4.7k?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. It is my humble understanding (thanks for this great educational video!) that the higher the resistor,
      the slower the residual capacity inside the transistor will by drained (considering the pin 7 open as connected to an infinite resistor
      should help understanding how the slope shape evolves relative to the resistor value).
      Slower draining of the residual current means rounder slopes and hence higher propagation times.
      Now keeping in mind that some basic circuits don't even connect Q7, it is not surprising that in many applications like yours apprentely; it still works and it should still be ok/better to have a 10k resistor than no pull-down resistor but expect slower propagation delays...

      Delete
  4. Just received my 6n138 opto-couplers, measured various resistors configuration and to reply Timo question 10k gave me poor results as expected, around 5us rise time, whereas suggested 4.7k gave me about 1.35us ; much sharper edge.
    Now the interesting thing is that I tried 3.3k and got 950ns rise time. It seems to be better and yet not too sharp (too sharp edges could cause other problems on a pcb layout from what i could read).

    ReplyDelete
  5. Hi
    How do we process chords as part of midi messages. Since midi is delivered serially presumably the notes are sent immediately (hopefully)one after the other and not at the same time? If so then would need to pay attention to the noteon and noteoff callbacks. Correct?

    ReplyDelete
    Replies
    1. Hi John. Not necessarily. Think of it this way, when you press a note on a keyboard it generates a note on message. When you release the key it sends a note off.

      So lets say you play a C major chord (C E G) on a Midi keyboard that is hooked up to an external synth module. The keyboard sends three note commands in quick secsession NoteOn 60,NoteOn 62,NoteOn 64. The synth module would then react to those 3 messages and play the three notes.

      Those notes remain "stuck" on until you release the keys. Now say you take your finger off the C note. The keyboard sends a NoteOff 60 command and the synth kills the C note. The other two notes continue playing until you remove your fingers from them as well. This way the notes take care of themselves.

      To see this in action, you could play a chord on your keyboard then unplug your midi cable. You will find the notes get stuck on until you reset your synth. Hope that makes sense.

      Delete
    2. Thanks for the quick response, totally understand. Just did a quick test sketch and got it to work utilizing 12 leds and having each one representing a note and getting the callbacks from the midi messages. A little off topic, but would like to start using servos to pluck a string from an instrument (guitar,harp,celeste,etc...). Do you have any experience in this area? Any advice you can give or is it pretty straight forward?

      Delete
  6. This comment has been removed by the author.

    ReplyDelete
  7. Hello, first of all thanks for all that has been taught, excuse me if you do not understand well I am using the translator since I am from Argentina, I have the following drawback, I do not think it is normal, since the synthesizer without midi tube the problem that sometimes I can do oscillators and sometimes do not walk, until I move the knob of the pich, now with the midi I have the problem that I have notes sounding and I have to restart the arduino to reestablish, can you help me with this? Or is it normal? Thank you!

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete