4N25 optcoupler

Will the 4n25 opto work for the standard MIDI in circuit? (I'm sure you all know the one).

Not been able to find info online.

Yes it will work but a 6N138 produces a much better output signal.

Cheers. I’ll get one of those in the coming days, but please could you advise on the diagram for wiring up a MIDI in circuit using the 4N25? unable to find information on this specific chip.

Just use it like the 6N138 chip, the only change I would make is to use a 10K pull up to +5V in place of the 680R normally used.

Thanks for your quick response.

I am unable to see how the two equate as the 4N25 I have is 6 pin and the 6N138 is 8 pin.

Regards

They are the same thing, just get the data sheet for the two devices and see how they relate.

I’m following this tutorial. i’ve found the data sheets, and I’m looking at them now. It seems the extra pins are needed. Does this mean that the 4N25 is not compatible?

http://www.vishay.com/docs/83605/6n138.pdf

6N138 4N25 2 1 3 2 6 5 5 4 8 6 7 - do not connect

No luck. Circuit built okay but no response from the board (mega) and the 4N25 gets noticeably hot. I have a spare in case it's fried - but what would you advise?

Replace the 220 resistor from 5v with a 10k?

Code I’m using is here:

#include <MIDI.h> // Add Midi Library

#define LED 13 // Arduino Board LED is on Pin 13

//Create an instance of the library with default name, serial port and settings
MIDI_CREATE_DEFAULT_INSTANCE();

void setup() {
pinMode (LED, OUTPUT); // Set Arduino board pin 13 to output
MIDI.begin(MIDI_CHANNEL_OMNI); // Initialize the Midi Library.
// OMNI sets it to listen to all channels… MIDI.begin(2) would set it
// to respond to notes on channel 2 only.
MIDI.setHandleNoteOn(MyHandleNoteOn); // This is important!! This command
// tells the Midi Library which function you want to call when a NOTE ON command
// is received. In this case it’s “MyHandleNoteOn”.
MIDI.setHandleNoteOff(MyHandleNoteOff); // This command tells the Midi Library
// to call “MyHandleNoteOff” when a NOTE OFF command is received.
}

void loop() { // Main loop
MIDI.read(); // Continuously check if Midi data has been received.
}

// MyHandleNoteON is the function that will be called by the Midi Library
// when a MIDI NOTE ON message is received.
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOn(byte channel, byte pitch, byte velocity) {
digitalWrite(LED,HIGH); //Turn LED on
}

// MyHandleNoteOFF is the function that will be called by the Midi Library
// when a MIDI NOTE OFF message is received.
// * A NOTE ON message with Velocity = 0 will be treated as a NOTE OFF message *
// It will be passed bytes for Channel, Pitch, and Velocity
void MyHandleNoteOff(byte channel, byte pitch, byte velocity) {
digitalWrite(LED,LOW); //Turn LED off
}

and the 4N25 gets noticeably hot

Suggests that the circuit is not right. Can you post a photograph of it?

Attached. Regards.

It is difficult to make out where these wires go as they just go out of shot. However Pin 5 of the opto should go to the RX input of the arduino and there is nothing connected to it but the pull up resistor. Who's value is obscured by the wires.

Also pin 2 of the 4N25 should go to ground ( of the MIDI input) , it appears to go nowhere apart from the diode.

What's the diode doing in there (image1.jpg)?

glocka: Will the 4n25 opto work for the standard MIDI in circuit? (I'm sure you all know the one).

Is that the "standard MIDI diode"?

Diodes like that are supposed to protect the LED inside the optocoupler against reverse polarity. I have no idea if glocka put it in there for that reason or for something else, nor do i know if it's smart to do so in a MIDI setup.

Well, I guess it [u]is[/u] the "standard MIDI diode".

|500x317

Is it an AC signal into it?

Anyway, it'd be a good idea if they OP would show his circuit; diagrammatically, not verbally.