Hello,
Another MIDI receiving problem ...
- I use a CNY17-1 optocoupler (datasheet says 40 to 80% CTR) on the serial port of an arduino pro mini 5V/16 MHz (schematic in attachment).
- I can send messages with the TX/output circuit, no problem, but if I try to decode/receive messages with the RX circuit ... it's a disaster ...
- I use a third party app and a MIDI keyboard but if I check the messages received by the arduino using the simplests sketchs they are wrong
Regarding schematic, if I use a pullup resistor on RX pin it just doesn't work, neither if I put the base at GND with resistor, the only solution to get some bytes received by the arduino is to connect directly CNY17 collector's to Arduino's RX pin
The sketch is the simplest serial repeater :
/*
Here's what I get on third part Midi software :
- emited via PC's MIDI output on Arduino's RX :
[Midi-Out] - 90 3C 40
- received by Arduino and transmitted on PC's MIDI input :
[MIDI-In1] - 90 00 30 (Note On)
*/
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(31250);
}
void loop()
{
while (Serial.available())
{
digitalWrite(LED_BUILTIN, HIGH);
Serial.write(Serial.read());
}
digitalWrite(LED_BUILTIN, LOW);
}
Or displaying in a putty console (@31250 bauds), using the RX of a FTDI USB tool :
/*
Here's what I get on putty for each key pressed (example) :
RECV 0
RECV 0
RECV 30
*/
void setup()
{
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(31250);
}
void loop()
{
while (Serial.available())
{
digitalWrite(LED_BUILTIN, HIGH);
Serial.print("RECV ");
Serial.println(Serial.read(), HEX);
}
digitalWrite(LED_BUILTIN, LOW);
}
The power supply of the pro mini is the +5V/GND of the FTDI/USB module
I've tested a serial repeater connecting RX/TX in putty, I get the chars I type
I've tested the timing of the quartz with classic blink, the internal led blink at the right frequency (1 s)
I've also tested the schematic with a 4N25, no success neither
If anyone can point me in the right direction...
edit : I've also tested with SoftwareSerial on port 2/3