Go Down

Topic: MIDI input works but not for all MIDI signals (Read 15947 times) previous topic - next topic

crx091081gb

I made this MIDI to CV box and for years it worked just fine receiving MIDI from my computer's M4UXL USB controlled 4 in / 4 out MIDI box. Then I decided to go back to my roots and use my Atari and the damn thing doesn't work with it, every fourth or fifth MIDI note seems to get through but the rest don't. I'm guessing this is something to do with the way I wired the MIDI input, I used an opto isolator and left the shield ground unconnected at the input as per the MIDI spec.

Any ideas why it would work for one MIDI generating device but not another?

RuggedCircuits

What did you use for a pull-up resistor at the MIDI input? Lots of people use a popular schematic on the 'net that's not robust -- the resistor is too large. Your pullup resistor should be <1k, and something like 220ohms-330ohms is best. It could be the optoisolator is "on the edge" with respect to forward current on the LED side and the M4UXL just puts out more current than the Atari does, which shows up on the isolated side as marginal signals.

Just a theory.

--
The Flexible MIDI Shield: MIDI IN/OUT, stacking headers, your choice of I/O pins

nickgammon

#2
Apr 04, 2012, 02:59 am Last Edit: Apr 12, 2012, 02:53 am by Nick Gammon Reason: 1
Like this one I drew up yesterday?



Are you saying that the 1.8K resistor should be 330 ohms?

(edit) Fixed image to change 1.8K to 330 ohms.

(edit) Changed on 12th April 2012 to reflect discussion below. Optocoupler changed from TLP521-1 to one with 100% CTR (current transfer ratio) (4N35) and resistor changed from 1.8K to 560 ohms.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

RuggedCircuits

Yes. Here are the suggested schematics from the MIDI Manufacturer's Association (which suggests 280 ohms):

http://www.midi.org/techspecs/electrispec.php

I don't know why people keep rolling their own when this circuit has been around since 1985 :)

--
The Ruggeduino: compatible with Arduino UNO, 24V operation, all I/O's fused and protected

nickgammon

Well, I don't know if that was better ...

Here is a single bit, using 330 ohms in the circuit above:






And how it was before, with 1.8K:



It seems to me that the 1.8K gives a better looking bit.

(Cursor B was about a pixel out - it was supposed to be on 0V).
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

RuggedCircuits

Now the other factors come into play. The MMA does not specify an optoisolator but its CTR (current transfer ratio) can be important. Your TLP521-1 has (in its least expensive rating) a 50% CTR. You may need to find one with a higher CTR. For example, an Avago 4N35-000E has a 100% CTR and will probably do much better.

You can test this theory by (temporarily) lowering the 220ohm resistor on the input side (could be dangerous if what's driving it can't handle the current), or driving the input side yourself with a controlled voltage source to see at what input current level the output starts looking nice again.

--
The QuadRAM shield: add 512 kilobytes of external RAM to your Arduino Mega/Mega2560

nickgammon

Just so I understand this, are you saying that with the 330 ohm resistor, the fact that the bit only goes "halfway down" is because the optcoupler is only driving it 50%?

And therefore, if connecting up a different MIDI device which puts out less current, it might not even go that far, and thus I would not get 0 bits when I expect them?
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

RuggedCircuits

Correct. Either that or the device driving the input side of the optoisolator cannot supply enough current to sustain ~8mA of current through the LED.

--
The Aussie Shield: breakout all 28 pins to quick-connect terminals

nickgammon

From what I've been just reading the frequency response suffers on the higher CTR designs.

My local supplier doesn't have Avago 4N35-000E in stock, does this look like a reasonable alternative?

VISHAY - 4N35 - OPTO COUPLER

http://au.element14.com/vishay/4n35/opto-coupler/dp/1328375

Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

RuggedCircuits

Yes, that looks appropriate; it also has a 100% CTR though upon further reflection you might want something even stronger. I miscalculated the typical input current -- with 5V in, 3 220 ohm resistors (two on the MIDI OUT, one on the MIDI IN), and 1.4V LED voltage drop that gives about 5mA. It *should* be OK, but if you want to be super-safe how about this 200% CTR device:

http://www.digikey.com.au/product-detail/en/PS2501-1-L-A/PS2501-1-L-A-ND/990595

--
The Rugged Circuits Yellowjacket: 802.11 WiFi module with ATmega328P microcontroller, only 1.6" x 1.2", bootloader

crx091081gb

Cheers Rugged, Nick. I was using the diagram off this post from way back when http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/ and you're right 3.3k is way higher than the MIDI spec, I'm soldering a new one in now. Hopefully that's it.

crx091081gb

Hmm well I swapped it and just like Nick when I looked on the scope I didn't get a very low bit and it didn't work (with anything). It seems 1.5k is as low as it can go before the Arduino doesn't recognise the bit.

I checked the opto-isolator (it was a Vishay ILQ74 one that I picked up from Maplin purely because it was the only one they had) and it's CTR is 35% so maybe that's part of the problem.

http://www.datasheetcatalog.org/datasheet/vishay/83640.pdf

I'll try and find a better one...

nickgammon

I think for me, until I get better optoisolators, I have to go back to the earlier resistor. I'm going to order some others after Easter. In my particular case, it worked with the MIDI device on the bench, so there is no rush. But it sounds like the better isolator, and proper resistor, would give better and more reliable long-term results.
Please post technical questions on the forum, not by personal message. Thanks!

More info: http://www.gammon.com.au/electronics

crx091081gb

#13
Apr 06, 2012, 12:38 am Last Edit: Apr 06, 2012, 12:42 am by crx091081gb Reason: 1
Yeah I'm going to go back to the 3.3k one till I can get a better one.

One more question though, when I use the Atari for input the bits still seem to go as low on the scope as they do for the other MIDI signals that do work. Does this rule out the current being too low from the Atari? Or could a low current cause some change in the rise and fall of the signal that screws with the UART?

Could it be some variation in baud rates that other gear is more lenient with (unlikely I know) or some extra junk data that the Atari's putting out (also probably unlikely).



RuggedCircuits

If the bits go as low as necessary with the Atari then it's likely not an electrical problem. It could be a timing problem. The MIDI baud rate is 31250 bps, and that's not always exactly achievable using standard crystal frequencies and clock dividers.

Can you use your oscilloscope to measure the exact bit period?

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, speaker, microphone, light sensor, potentiometer, pushbuttons

Go Up