Go Down

Topic: Midi Input (Read 3671 times) previous topic - next topic

Grumpy_Mike

Quote
I am not sure if I am doing this right. Pin 13 doesn't go high when I press a keyboard key.
Well with that code it will only go high for less than a millisecond before it puts it low again.

I didn't say set it high, I said:-
change the state of the led

Code: [Select]

int incomingByte = 0;
boolean ledState = LOW;

void setup() {
        Serial.begin(9600);     
        pinMode(13,OUTPUT);
     }

void loop() {
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();
               ledState = !ledState;
               digitalWrite(13, ledState);
          }
}


If the input hardware is working then then LED will change state on every key press.

Chole

So the led stays low on button presses, so obviously I'm doing something wrong or there is a problem with the hardware. Even though I managed to output to the keyboard, I wonder can the out port on the keyboard be faulty.

Grumpy_Mike

#17
Jun 05, 2016, 02:52 pm Last Edit: Jun 05, 2016, 02:53 pm by Grumpy_Mike
Quote
I wonder can the out port on the keyboard be faulty.
OK so now we can do some tests to find out.
First off make a logic test probe, sounds complex but is just a resistor and an LED, like this:-



Now connect this to the output of your keyboard, try it both ways round. You should see a flicker when you press a key.
Now put that in parallel with the input side of your opto isolator. With A to the anode of the opto's LED and B to the cathode. Again it should flicker to show the signal is getting that far.

Finally connect it to the output transistor of the opto. With A to +5V and B to the RX input of the Arduino. You should see a flicker on a key press.

If any of these fails then you know the signal is not getting that far and look to the wiring, connections and components from that point, to the last point where it worked.

Chole

Now connect this to the output of your keyboard, try it both ways round. You should see a flicker when you press a key.

So A goes to pin 4 or 5 on the midi connector and b to ground?

Grumpy_Mike

Quote
So A goes to pin 4 or 5 on the midi connector and b to ground?
No there is no ground on a MIDI output.

Connect between the two MIDI signals, that is the middle pin either side of the center.

Chole

No there is no ground on a MIDI output.

Connect between the two MIDI signals, that is the middle pin either side of the center.
Alright the led flickers constantly, but when I press a key it flickers more bright.

OK so now we can do some tests to find out.

Now put that in parallel with the input side of your opto isolator. With A to the anode of the opto's LED and B to the cathode. Again it should flicker to show the signal is getting that far.

Finally connect it to the output transistor of the opto. With A to +5V and B to the RX input of the Arduino. You should see a flicker on a key press.

If any of these fails then you know the signal is not getting that far and look to the wiring, connections and components from that point, to the last point where it worked.
I am supposed to put the probe while the whole circuit is still in place right? If i put a and b on pins 2 and 3 of the optocoupler it doesnt flicker. I tried rearanging a and b, the leads from  midi pins 4 and 5 to the opto and the diode, nothing changed.

Grumpy_Mike

You are trying to track down the fault.
You have established that data is coming from your keyboard.

If yo get nothing connecting the probe LED to the back of the input socket then remove the diode, still noting remive the opto. Still nothing then your cable or socket is faulty.

Chole

So, i removed the diode to test the input side of optoisolator. The led flickers only when everything is the other way around:  A side of the Led probe to pin3 (anode) and B to pin 2 (cathode), and when the leads from the midi conector are the opposite then they should be: pin 5 midi to pin2 opto and pin 4 midi to pin 3 opto.

Grumpy_Mike

Quote
The led flickers only when everything is the other way around:
That sounds to me like the classic MIDI pins are the wrong way round. There is confusion as to whether the pins are numbers looking into the plug or looking into the socket. So reverse the connections to the socket and see what happens.

Chole

I already checked that and made sure I'm looking at it right. I already tried reversing them, this is the only way the led flickers. When I put the diode in the right way, led stops flickering and if I reverse it so that the black part (cathode i guess) is to pin 3  on optocoupler it flickers again.

Grumpy_Mike

If the fitting of the diode stops the serial signal either the diode, or connections are the wrong way round.
The job of that diode is to protect the LED in the opto from reverse voltage and if fitting it stops the signal then the signal is inverted.

Chole

If the fitting of the diode stops the serial signal either the diode, or connections are the wrong way round.
The job of that diode is to protect the LED in the opto from reverse voltage and if fitting it stops the signal then the signal is inverted.
Ok, I understand that, but the midi connections on input side of optocoupler are reversed and so if I put the diode according the schematics led stops flickering. If the diode is reversed aswell the led flickers. Led flickers if the input side is completely reversed. Reversing it to the proper place according to the schematics stops flickering.

Chole

#27
Jun 07, 2016, 02:40 pm Last Edit: Jun 07, 2016, 05:51 pm by Chole
The little circle in the up right corner on optoisolator should designate pin 1 right? If the input side of opto is arranged according to schematics led doesnt flicker but if I reverse just the optoisolator so input is connected to pins 6 and 7 the led flickers? Should that happen, or am I starting to be desperate here for finding reasons why doesnt this work.

EDIT: I got input side of opto working according the schematics, but now dont have any response with the probe on the output side of opto. 5v and rx pins do not flicker, tried reversing.

Grumpy_Mike

Quote
The little circle in the up right corner on optoisolator should designate pin 1 right?
Correct.
this is when looking down on that spot. The pins are numbered anti clockwise from this point.


Quote
if I reverse just the optoisolator so input is connected to pins 6 and 7 the led flickers?
The LED flickering means that something is not shorting an output, so there are lots of useless configurations where the LED will flicker.

Chole

The LED flickering means that something is not shorting an output, so there are lots of useless configurations where the LED will flicker.
I'm supposed to test the output of opto with the probe at 5v and rx. Got no repsonse, reversed either way. The signal stop in the optocoupler?

Go Up