Pages: [1] 2 3 4   Go Down
Author Topic: 'midi in" project....  (Read 12503 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello,

i've been working on this project for a month or so now, and not really getting anywhere with it. in the past i've mainly used my arduino board for LED control and for switching reed relays on and off, but now i'm trying(unsuccessfuly) to get arduino to listen to incoming midi messages from an external sequencer.

having looked arround the web, i've decided to use a common schematic that is also available from Toms site.



its the top schematic, for midi in.

i have a bread board with the parts set up, and the serial out from the 6n138 chip is connected to the RX pin of my arduino board.

at the moment, all i'm trying to do is get the board to listen for a midi signal and switch on pin 13, where i have an led connected, but so far its just not working.

i have tried loads of different variations of code, heres an example, which was modified from the basic serial read tutorial.

Code:
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the data from the serial port

void setup() {
  pinMode(ledPin,OUTPUT);   // declare the LED's pin as output
  Serial.begin(31250);        // connect to the serial port
}

void loop () {
  // read the serial port
  val = Serial.read();


  if (val != -1) {
    if (val == 0x90, 0x01, 0x45 ) { // note on, channel 1, note value 1, velocity 45
      digitalWrite(ledPin, HIGH);
      delay(200);
      digitalWrite(ledPin, LOW);
    }
  }
}

i have a midi signal being sent from ableton live, through my usb midisport 2x2 and into the bread board. from there it goes through the 6n138(and the relevant diodes and resistors) to the RX pin of the arduino board. the board isnt connected via usb, and is powered from a wall adaptor.
the RX and TX leds on the board are lighted up(but very dim) but i just cant seem to get any sort of response. i can see that the Midisport is receiving the signal from ableton as its got indicator leds to show when a signal is received and sent.

so, does any one have any ideas or tips that might get this working? it would be greatly appreciated!!

thanks,

bod.
« Last Edit: July 08, 2006, 05:36:45 am by bod » Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,

i've no experience with midi (except for usb-keyboard i use). but i like the idea of "arduino<>midi"...
i cannot say anything about your hardware setup. but since you say it's a proven setup...

for the rx and tx leds: it's normal that they are lid, when you are powering the board from en external supply (not usb). still the rx led should blink on incoming data!

did you try your code without that if-clause in your loop? it would be nice to know if your board receives anything at all before you start to interpret tha data.

if it does, i'd figure out a way to see _what_ it receives. (maybe more leds?)

what about the start and stop bits of a midi message? are they compatible with arduino's serial communication?

after all it would be nice to have arduino connected to your computer via usb for debugging. but since you're using the rx/tx for your midi communication this might not work :-/


i'd really like to see you having success, so keep us updated!

best,
kuk
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

by the way:

are you sure about your if-code?


if (val == 0x90, 0x01, 0x45 ) { ...}

i don't know this syntax.
"val" is (only) one byte of data or "-1".

if you're not sure, try

if ( (val==0x90) | (val==0x01) | (val==0x45) ) {...}

since you want to check if "val" is equal any of your values.



Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

to be honest i didnt expect that code to work anyway for the same reason that val is only one byte, not a string of bytes.

my main problem at the moment is to actually receive any sort of signal from the rx pin. when i connect the circuit up, the rx and tx leds on the board dim to half their brightness, and there seems to be no signal at all being recieved by the board when i send a midi note from the midisport interface. maybe i've screwed up the hardware side of things, but i've checked it a million times.  :-?

i used to use MAX to convert midi notes to ascii characters to send over to the arduino board to activate reed relays, but i'm sure there must be a way to get arduino to do this itself.

think i'll go and bang my head against the wall a bit more.....
Logged

Forum Administrator
Offline Offline
Newbie
*****
Karma: 3
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Some debugging tips

remove the chip from the arduino board and just open a terminal emulation program on the computer trying to setup a speed of 31250 baud when themidi data comes in you shoud see the caracters show up on the screen.

this will show you if the data is actually coming through the midi interface

then put the chip back in

on the other hand the "if" syntax you have will not work...
you need to check for 0x90 only and then have more nested if statements to check if the sequence is correct.

i think you should be able to read data from the midi interface...

let us know your progress

massimo


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ah, cunning!

so if the atmega8 chip isnt there, will the board route the signal from the rx pin through to the usb connector?

i'll give it a go anyway.

cheers!
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

typical! dont you just hate it when you run out of usb cables......  >smiley-sad

i'll give this a shot when i get back from work tomorrow armed with a couple of extra cables! i've set up Terminal in OSX to listen to incoming serial data, so it should be able to tell me whats coming in, or not as the case maybe.

« Last Edit: July 09, 2006, 02:16:16 pm by bod » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
shrz
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi,

i use the same shematics, and it works.
But i spend a lot of time, searching for the reason why nothing happens: finally (Oh Lord!) i confused the direction of the midi jack! (its not easy to be supid like this...)
in this shematics, you don't see the the jack, the part on your breadboard.
its the connector, the cabel wich is shown.
perhaps this helps.
sometimes life is happy:)
greetz
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

right, i removed the chip, connected the midi device and the board together, plugged the board into the usb port, opened terminal and set up as per required to listen to serial communication, and still nothing. think i may have a hardware problem, as woo_oow seems to have got it working.

i'm using:

220R 1/4 watt resisitor
270R 1/4 watt resistor
1n194 diode
6n138 opticoupler darlington output.

all the parts came from Farnell.com, maybe i bought something incompatible..... :-?


cheeers for the tips so far guys, back to the drawing board.
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so have you tried to flip connection 3 and 5 on the midi jack?

as woo_oow suggested the schematics might show the socket not the jack (or the other way around).

give it a try.
Logged

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

and...

you're writing taht you're using a 1n194 diode. the schematics mention a 1n914. i guess this is just a typo though.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 41
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

oops, that was a typo!

tried flipping the connections loads of times, i'm going to rebuild it all from scratch this week end and see if it helps.  >smiley-sad
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've gotten the same schematic to work with PIC processors but could never get it to work with Arduino. I posted about this a few months back but didn't get a response...  http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1145948129

There's a slightly simpler program there than the one you posted testing for note on messages.

I don't know if this would help at all but I posted a blog entry about getting MIDI Input to work with the PIC. There's a labeled picture of the final breadboard:

http://saturatedsog.blogspot.com/2006/03/sog-2-midi-input-with-pic.html
« Last Edit: July 24, 2006, 11:18:17 am by bigbadotis » Logged

http://www.charlie-roberts.com/midiStroke
Free software for MIDI control in OS X.

berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi bigbadotis,

do you have any idea why you're setup works with a pic mc but not with arduino? this doens't make sense, does it? still this thread seems to prove there's something we don't know yet.

as is wrote earlier, i'm not into midi right now, but want to start a similar project next month.

maybe the problem lies in the serial byte format. arduino uses 8-N-1 (which means eight (smiley-cool data bits, no (N) parity bit, and one (1) stop bit). does anyone know for sure what format midi uses?

does receiving data make the rx-led blink on your arduino board? how does it behave?

maybe the logical current levels (of the 6n138 output) are not "clear" enough for the atmega8 but for the pic. logical 0 might be too high or 1 too low. i don't know about differences in tolerance :-/

+5V and ground of the 6n138 are connected to the arduino board, right?

we should get this working. maybe just connect an LED to the output of the 6n138 to start the debugging. maybe that one is broken??? (not the one that works with the pic though)






Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
do you have any idea why you're setup works with a pic mc but not with arduino? this doens't make sense, does it? still this thread seems to prove there's something we don't know yet.

nope, I was never able to figure it out.

I'm in the process of moving, so I can't help out very much with this now (everything is in boxes), but I definitely think it's worth figuring out and creating some type of tutorial for.
Logged

http://www.charlie-roberts.com/midiStroke
Free software for MIDI control in OS X.

Pages: [1] 2 3 4   Go Up
Jump to: