IMPORTANT: your arduino might not start if it receives data directly after a reset, because the bootloader thinks you want to uplad a new progam. you might need to unplug the midi-hardware until the board is running your program. that is when that statusLed turns on.

#####################################################################################################################################################SOMETHING ABOUT MIDI MESSAGES midi messages start with one status byte followed by 1 _or_ 2 data bytes, depending on the command

example midi message: 144-36-100 the status byte "144" tells us what to do. "144" means "note on". in this case the second bytes tells us which note to play (36=middle C) the third byte is the velocity for that note (that is how powerful the note was struck= 100)

example midi message: 128-36 this message is a "note off" message (status byte = 128). it is followed by the note (data byte = 36) since "note off" messages don't need a velocity value (it's just OFF) there will be no third byte in this case NOTE: some midi keyboards will never send a "note off" message, but rather a "note on with zero velocity"

do a web search for midi messages to learn more about aftertouch, poly-pressure, midi time code, midi clock and more interesting things.#####################################################################################################################################################

HARDWARE NOTE:The Midi Socket is connected to arduino RX through an opto-isolator to invert the midi signal and seperate the circuits of individual instruments.connect 8 leds to pin2-pin9 on your arduino.

Also, with the latest version of the bootloader (i.e. the one that comes on the Diecimila or that you burn onto an NG from Arduino 0009) you shouldn't need to disconnect anything or stop sending data when you reset. It's smart enough to timeout if you give it bad data.

leKuk

thank you mr. mellis!if there are enough people interested, i'll silkscreen it and sell t-shirts of it. 12 euros plus shipping :-)i could do acrylic on canvas as well.

nice to hear about the smart bootloader. i wonder if it would be possible to fully "circumvent" the bootloader in a future version. maybe if pin 13 was connected to +5v the board would just start the user program. still the new version is a great improvement. thank you for that as well. now i just need to find out the easiest(cheapest) way to burn a bootloader on os x.

I like the idea of connecting pin 13 to +5V to skip the bootloader. You might need to disconnect it to upload code, but that's better than needing to disconnect RX just to reset the board. Especially because pin 13 is probably only rarely used as an input (although it is one of the SPI pins, which might mean that it gets tied high sometimes).

Daniel

PS: what's the 100K resistor for? It doesn't seem to make sense electrically, as it's connected to the base of the transistor, which would need a positive voltage to turn it on. Is there any difference if you just ground that pin, or leave it unconnected?

leKuk

the 100k resistor is for a cleaner signal. the 4n28 contains a phototransistor, the resistor to ground helps discharge the base. it wouldn't work reliably until i found this solution somewhere. there might be better suited optocouplers though.

leKuk

there should some way to get rid of it, it doesn't make sense electrically.

Anyway... have you tried a PC900? that's the opto with a digital output.

actually i used a 4n28, because i use them for anything ;-) i got them quite cheap, and still have plenty lying around. on the other hand, i like the idea of having "standard parts". having found the 100k-solution, even more binds me to my little 6-leggers, as i begin to get a feeling for what they can do, and what they can't. :-?still i put the pc900 on my shopping list.

i found this pdf, explaining the base resistor: http://www.jaycar.com.au/images_uploaded/optocoup.pdfon page 2 it says:

Quote

(alternatively...) " tie the base down to ground (or the emitter) via a resistor Rb to assist in removal of stored charge. this can extend the opto's bandwidth usefully (though not dramatically)"..."typically you start with a resistor value of 1mOhm and reduce it gradually down to about 47kOhm to see if the desired bandwidth can be reached."

i know i shouldn't believe everything i read on the internet. but it made sense to me, and worked from the beginning. i'm not sure though, whether i tried much values between 1megaOhm and the 100k right now, it does not work without the 100k resistor (on a bread board that is).

thank you for questioning though. i already forgot about the resistor.

I like the idea of connecting pin 13 to +5V to skip the bootloader. You might need to disconnect it to upload code, but that's better than needing to disconnect RX just to reset the board. Especially because pin 13 is probably only rarely used as an input (although it is one of the SPI pins, which might mean that it gets tied high sometimes).

I nerver dared to ask for this, because I always thought this idea was put down a long time ago when I didn't even knew the Arduino existed!This would be my : "top notch, favourite,I waited for this all my life" enhancement to the Arduino. Acutually it's the only one that comes to my mind!Let's go, hunt that startup-delay down with an on-board jumperEberhard

leKuk

tr909,as you wrote, the diode is to protect the optocoupler from reverse voltage. i didn't test it without, but it should work.

other optocouplers should works as well, as long as they aren't much slower. there should be graphs or numbers in the dateasheet. i used a 4n28 because i once bought a couple of them for another project.

it might be, that my drawing of the midi socket is misleading, or rather that it shows the plug, not the socket. i'm sorry for that. it was a quick drawing when it worked for me. i noticed it some days ago when building another device, but forget to get deeper into it. simply try reversing TX and ground on the socket. please remember the diode in that case because of GOTO LINE 1.

i started on a midi library + real instructions with real images, but this will take me a while. please let me know if you could get it working.

ccgibson

hello everyone, first time posting in these forums so hopefully I won't ask to many silly questions

I've been trying to get kuk's midi input circuit going but I'm having problems, and the most frustrating thing is that it's unclear to me how to debug this. I'm a novice at this stuff, and I'm trying to use midi input with the arduino for an art project / interactive music installation so any guidance would be greatly appreciated.

As of right now, I'm never getting Serial.Available on the RX input pin (using digtial pin 0).

Some of the steps I've tried:1) I've verified my input pin works using a simple potentiometer. I can get Serial.Available to read an input byte with that set-up2) I've tried both midi plug wiring options as described in this thread.3) I've tried the circuit with and without the diode.

Now I had access to several 2W resistors. These things are funny looking becuase they are so fat. Is it possible these could be overbuilding the circuit and causing it to fail?

I do not have access to a scope, but I do have a multimeter. Are there any obvious debugging points that I should try?