Go Down

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

RuggedCircuits

Measuring DC current won't be so helpful since there will be no current flowing when there is no transmission coming in. And when there is, the current will be oscillating and your meter will be confused. Putting an in-line series resistor (10 ohms?) and using differential measuring mode on a scope will give a clearer picture.

The SFH618A-4X certainly gives nicer results, but has a slower-than-expected turn-off (the high bits should really be squarer). I'm also a bit confused about the timing. Looking at the reception that starts at almost exactly 250us into the data record (falling edge), I would have expected it to be over in 10 bit periods (start bit + 8 data bits + stop bit), which at 31250 bps would be 320 microseconds, or 6.4 divisions of 50us on the scope. Well, it looks like another transmission is coming in much earlier than that, as there's a falling edge just about 5.8 divisions later. Could the MIDI baud rate be wrong?

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

nickgammon

You might not have chosen the start of a byte. The logic analyzer appears to confirm things are OK:



From the start of one byte to the next is 319.75 uS.
Please post technical questions on the forum, not by personal message. Thanks!

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

nickgammon


Measuring DC current won't be so helpful since there will be no current flowing when there is no transmission coming in. And when there is, the current will be oscillating and your meter will be confused. Putting an in-line series resistor (10 ohms?) and using differential measuring mode on a scope will give a clearer picture.


OK, then.



That's with 10 ohms, and since that side didn't have an earth reference I just clipped the ground to one side and the probe to the other. I calculate:

Code: [Select]
current = .080 / 10 = 8 mA

Is that right? So that looks OK.
Please post technical questions on the forum, not by personal message. Thanks!

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

RuggedCircuits

Everything looks right then. In hindsight 100% CTR isn't really good enough since 8mA*330ohms = 2.64V of voltage drop, down from 5V means that the signal is only expected to go down to 5V-2.64=2.36V, and you observed it going down to 2.0V with the 4N35. So either a slightly bigger resistor (500 ohms should get down to 1V) or a higher CTR isolator (like your SFH618A-4X) would be the way to go for greater robustness.

--
The MegaRAM shield: add 128 kilobytes of external RAM to your Arduino Mega/Mega2560

nickgammon

It's always gratifying when theory and observation meet up, is it not?

Back to the 4N35 and a 560 ohm resistor gives this:



Pretty reasonable wave-form and it comes down to 200 mV.

I'll amend my suggested circuit to incorporate that.

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

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

RuggedCircuits

That's a good looking waveform! Hopefully the 4N35 you have is representative of the norm and lot-to-lot variations (and manufacturer-to-manufacturer variation) won't affect things too much.

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

crx091081gb

Nick were your problems anything to do with running status? I've been thinking perhaps my code isn't handling this..

http://home.roadrunner.com/~jgglatt/tech/midispec/run.htm

nickgammon

Yes that was exactly it. I was getting multiple bytes with the low-order bit set. I guessed, and tests confirmed, that I was getting multiple note-ons in a row. And to save switching to note off, they were sending note-on with a velocity of zero.
Please post technical questions on the forum, not by personal message. Thanks!

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

crx091081gb

Just confirmed it was my crappy implementation of running status that was responsible. I'm surprised this doesn't come up more often. I'm just surprised that my modern DAW doesn't take advantage of running status to try and keep the MIDI bus as free as possible but then if modern computers could do MIDI with sub millisecond accuracy then I wouldn't have to use an Atari in the first place.

Ho hum.

nickgammon

Ah well, in chasing the hardware bug we both learned something about both hardware and software. So, that was time well spent. :)
Please post technical questions on the forum, not by personal message. Thanks!

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


Andy2No

Coming slightly late to this discussion; the problem appears to be getting a good low level, with an optoisolator output.

I've seen a circuit that gets around that, though I didn't realise at the time.  It just adds a PNP transistor stage, acting as an inverter.  The signal then needs inverting again, I guess, but you could probably just do that in software.

I have a schematic, as an image (saved a while ago - I've forgotten where from). I don't see any way to attach it here though.  

I expect you can picture it anyway.  The emitter of the PNP transistor is connected to Vcc, the collector connects through a resistor to ground.  The base is fed via a resistor from the output side of the optoisolator.

If the output of the optoisolator is off, the base of the PNP transistor is at Vcc, so the transistor is off (output low, close to 0V thanks to the collector resistor connected to ground).  If the optoisolator output is on, it only needs to drop by a little over 0.6V, to turn the PNP transistor on (output high, close to Vcc - 0.2V or so).  So, even a dip of 1V for a zero, should be fine, depending on the base resistor value, and the gain of the transistor.

The diagram showed a PC817 optoisolator, with a 390 Ohm series resistor on the output side, and the same value resistor as the base resistor of the PNP transistor, shown as a BC640.  The collector resistor is shown as 1k5 Ohms.  Almost any small PNP transistor would do, I expect, and the resistor values aren't likely to be at all critical.

Go Up