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:
1 Answer 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– jose2017年11月01日 13:51:47 +00:00Commented Nov 1, 2017 at 13:51
-
1From yours and CLs comment it looks like I can't rely on the 435, so I'll try the H11L1.jose– jose2017年11月01日 13:59:16 +00:00Commented Nov 1, 2017 at 13:59
-
1I'd be very grateful if you could :)jose– jose2017年11月01日 14:21:34 +00:00Commented Nov 1, 2017 at 14:21
-
1That looks great, I'll order the parts and report back asap!jose– jose2017年11月02日 01:06:25 +00:00Commented Nov 2, 2017 at 1:06
-
1
SoftwareSerial
.