MIDI Troubles

Status
Not open for further replies.

Ando_Shy

Member
Hello,
I am writing because I spent several hours today trying to get 5-pin MIDI to work with my Teensy 3.2, I followed the schematic located at the PJRC MIDI Library page precisely and am using the code provided for receiving MIDI messages on the same page and it simply does not work. I have the schematic bread boarded, and I even soldered a version of the same schematic (in case my breadboard is getting old), I've tried swapping out the Teensy 3.2 with a brand new one I had in stock, I've switched up the photocouplers with other models and have tried tweaking details on the schematic as per suggestions located on other forums. On the software side of things I have all my libraries and my Arduino IDE (1.8.5) and Teesyduino (1.41) up to date (MIDI Library 4.3.1).
In spite of all my efforts I can not get a single MIDI message to register (I've tried changing the MIDI source as well just for info). The code just loops through its inactivity message. I've looked through the documentation for the code provided on the site and there doesn't seem to be a problem there either. I've tested all the lines with my multimeter and everything seems alright although I do not have an oscilloscope to check logic.
Basically I've run out of steam and ideas but would really like to get cracking on a project using 5-pin MIDI input. Can anyone offer me any help? Is there an issue with the newest versions of the Arduino IDE or the MIDI Library? Any thoughts or suggestions would be greatly appreciated as I've basically hit a wall...
Just for reference the code and schematic I am using can be found here https://www.pjrc.com/teensy/td_libs_MIDI.html
 
If the circuit follows the schematic my guess would be that perhaps the connector was wired backwards. I’ve had no issue in the past using the MIDI library.
 
It should not be too difficult to do classic circuit debugging. Feed a continuous midi data stream to the DIN input. Take your oscilloscope and check the incoming signal step by step (first across pins 4 and 5 of the DIN plug, second pins 2 and 3 of the 6N138, third across pins 6 and 7 of the 6N138, fourth between Teensy Pin0 and GND), and see where it gets lost. That's how circuit builders work.
 
I don’t have a scope... as I mentioned in the original post, I was kinda hoping to find some direction to trouble shoot this without dropping cash on test equipment as it would seem MIDI should be pretty straight forward at this point (being it’s a nearly 40yo protocol). Still I appreciate the input.
 
The error is for sure not in the code, since the midi examples on the PJRC website have recently been reworked and thoroughly tested.

Thus, the problem is definitively in the hardware of your peripheral circuit or in the wiring. Can't understand how people try to build circuits without having the most elementary tools like an oscilloscope or at least a cheap logic analyzer at hands, although these would have helped you to find the problem within 20 seconds :rolleyes:
 
The answer is a finite supply of money, and I have built many projects including an analogue modular synth, DMX controllers, arduino and teensy based stuff, as well as wireless transmission projects without any need for a scope up to this point so please don’t patronize me.
 
Thanks Larry, I have already tried slapping a resistor on pin 7 as described in the link, but when I get the chance I’m going to go through the data sheet again and try playing with the resistor values.
 
It prints «*MIDI Input Test*» and then «*Inactivity*» every 10 seconds after as it should. I see no fault in the code as written. If it is a code related issue I would guess that it would be more something going on in the MIDI Library or with arduino/teensyduino not compiling properly, but I tend to think it is more of a hardware issue as the code returns its status properly and when I input random bytes into the rx line it does return the value in the serial monitor (although obviously it’s not valid MIDI data).
 
Are your Teensyduino libraries stock and current? As noted this code and that schematic have worked for many people so I wouldn't go chasing zebras.

Until Paul got around to updating the web page recently the most common problem was using the 220 ohm resistors from the 5 volt version for 3.3-volt Teensys.

Other than that the common problems (most of which you're eliminated already) are:

  • Trying to supply the optocoupler with 3.3v instead of 5v.
  • Pulling up to five instead of 3.3 (which should work until it fries your Teensy unless you're using a 5 v tolerant model)
  • Sending to Serial instead of Serial1
  • Naïve wiring errors (crossing Tx and Rx for example)
  • Faulty testing logic (thinking your test system is doing one thing when it's doing something else)
  • Bonehead - 'OMG I can't believe I didn't power the positive rail on the breadboard' type errors

Sounds like you're fairly adept at electronics so my money is on the last category.

The error is somewhere so blatant you're failing to see it. You could post a photo and see if someone else can spot it.
 
So boneheaded mistake wins it! Actually I gotta give props to vjmuzik he hit the nail on the head with the first post. The pins on the connectors were flipped, not sure why it didn't work when I tested that last night but I was tired so I might have been making other mistakes at the same time... Anyways I was following the pinout for a male MIDI connector (as opposed to female) so yeah that was ultimately my problem.
Thank you for the help everyone.
Works like a charm now with the 6N138.
 
Status
Not open for further replies.
Back
Top