Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: MIDI Troubles

  1. #1
    Junior Member
    Join Date
    Feb 2018
    Posts
    8

    MIDI Troubles

    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

  2. #2
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Location
    Florida
    Posts
    343
    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.

  3. #3
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    I have already tried the connector wired in both possible configurations with no change in the result.

  4. #4
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,530
    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.

  5. #5
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    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.

  6. #6
    Senior Member+ Theremingenieur's Avatar
    Join Date
    Feb 2014
    Location
    Colmar, France
    Posts
    2,530
    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

  7. #7
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    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.

  8. #8
    May be take a closer look to your optocouplers.
    See also (if not done up to now) to https://forum.pjrc.com/threads/45416...-on-MIDI-input there are some considerations about this topic.

    good luck

  9. #9
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    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.

  10. #10
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,164
    To confirm; the receiving test code prints "MIDI Input Test" but nothing else?

  11. #11
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    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).

  12. #12
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    And for the record I have some Vishay 6n138 and 6n137 optocouplers if anyoneís had better luck with the latter

  13. #13
    Senior Member oddson's Avatar
    Join Date
    Feb 2013
    Location
    Isle in the Salish Sea
    Posts
    1,164
    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.

  14. #14
    Senior Member Blackaddr's Avatar
    Join Date
    Mar 2017
    Location
    Canada
    Posts
    227
    Is your diode across pins 2/3 of the 6N138 backwards? Lost an afternoon on that one many years ago.

  15. #15
    Junior Member
    Join Date
    Feb 2018
    Posts
    8
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •