1

I'm trying to read MIDI notes using an ATtiny85 via SoftwareSerial; so far, I've got no success at all.

  • The ATtiny is using the internal clock, 8Mhz, 5V.
  • The MIDI keyboard sends clean note on/off messages (tested with a MIDI monitor).
  • I've tried several test programs, particularly Nick Gammon's, as described here.
  • I've followed Nick's schematics to build the connector, and I can confirm his program works with an Arduino, but not with the ATtiny.
  • I calibrated the Tiny with OSCCAL - still no luck.
  • As far as I can tell, midiSerial.available() is always 0, in every program I've tried.
  • SoftwareSerial works fine for the purpose of MIDI out.

That's as far as I've got. I'd appreciate any pointers, especially if anyone else could try Nick's code and see if it works.

EDIT

There was an issue with my local version of SoftwareSerial. I had commented out code so that I could use pin change interrupts in my MIDI out program, but those interrupts are essential for MIDI input. Once I uncommented the code, all the programs I tested worked, so it is indeed possible to receive MIDI using an ATtiny.

That said, I've tried four keyboards as inputs and only one has worked so far, a Korg 01/W proX. The same happens when I load the MIDI code directly in the Arduino, so based on the answers below I will try a different optocoupler, and post my results here for the sake of improving on the answer.

Here's the schematics I was talking about:

MIDI connections

  • 2
    The schematic is wrong: pin 2 at the receiver must not be connected to ground, and the optocoupler is not reliable at MIDI speeds. See 4N35 opto-isolator for MIDI input does not work? – CL. Nov 1 '17 at 8:09
  • You posted a link to a page that have a link to another page that contains the info your talking about. – user31481 Nov 1 '17 at 8:18
  • true- I've just added the schematic above. The code is relevant because the author claims it's been tested, but it's one of several I've tried with identical results, so I don't think it is as central to the question. – jose Nov 1 '17 at 13:48
  • Your link now points to a better schematic … – CL. Nov 2 '17 at 21:03
  • 1
    You might try NeoSWSerial. It has a configuration option to avoid the PCI vector problem, and it now supports the MIDI baud rate. It is MUCH more efficient than SoftwareSerial. – slash-dev Nov 3 '17 at 13:22
1

I have done tests with a normal Arduino with software serial and missed quite a bit of messages, so I would advice to use hardware serial's instead.

For MIDI Out probably it works, but for MIDI In I have bad experiences. Especially when it comes to many messages, like aftertouch/pitch bend etc.

Also, I tried some optocouplers which didn't work well (like 6N137). I now use H11L1 optocouplers (they are white compared to most black ICs) and work perfectly.

You already checked the clean note on/note off ... are you sure it doesn't send active messages?

Below the schematic as I use it.. It does not matter if an STM32 or Arduino is used. Actually I haven't checked if H11L1 are 3.3V or 5V but they seem to work on both.

schematic

simulate this circuit – Schematic created using CircuitLab

  • Yes, no other messages at all. – jose Nov 1 '17 at 13:51
  • 1
    From yours and CLs comment it looks like I can't rely on the 435, so I'll try the H11L1. – jose Nov 1 '17 at 13:59
  • 1
    I'd be very grateful if you could :) – jose Nov 1 '17 at 14:21
  • 1
    That looks great, I'll order the parts and report back asap! – jose Nov 2 '17 at 1:06
  • 1
    DIN connector number the pins differently. R4 must be a pullup on the output signal. (And this schematic would be much more readable if you didn't try to connect all VCC and GND signals together; see, e.g., this page.) – CL. Nov 3 '17 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.