Pages: 1 [2] 3 4   Go Down
Author Topic: 'midi in" project....  (Read 12604 times)
0 Members and 1 Guest are viewing this topic.
berlin
Offline Offline
Sr. Member
****
Karma: 0
Posts: 293
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey there,

just wanted to know if anyone has some good news regarding this matter.
i'd really like to help out and try my luck with midi-in for arduino. but i don't want get stuck at the same point.

does anyone know a different midi<>microProc circuit or has an idea why the above wouldn't work?
after all this shouldn't be an issue!?!

best, kuk_
Logged

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

i got this circuit working recently with a pic to see if it was an issue with the parts i was using but it wasnt, so still no joy on the arduino side of things.  smiley-razz
Logged

Montréal, Québec, Canada
Offline Offline
Newbie
*
Karma: 0
Posts: 13
Alexandre Quessy
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is a bit off-topic, but I was wondering if anyone had a schema to interface an Arduino with a MIDI out port. This way, we could send data to a computer using not so many resources as when we use the serial port emulation.

An other interesting project would be to interface it with an Ethernet port. Then, it could be powered over Ethernet, and send and receive data.

USB is good, but Ethernet and MIDI can be very interesting too. But this is getting much off-topic.  smiley-wink
Logged

Alexandre Quessy

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

Quote
wondering if anyone had a schema to interface an Arduino with a MIDI out port.

http://www.tigoe.net/pcomp/code/archives/bx-24/000292.shtml#000292

it's usually much less finicky to do MIDI output than MIDI input...
Logged

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

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

although i did not have a try on the midi in circuit posted above, i searched a bit in the net and found this pdf:
http://www.keyboardpartner.de/hammond/diagrams/MINIvice1.pdf
it's a circuit based on the atmega8, and uses a slightly different midi input circuit. maybe it's worth a try to use this circuit?
it has a 1,2k resistor between VCC and the optocoupler (which is a cny17 - has a different pinning than the 6n138).
Logged

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

ok,

i'm working on it now. i'm starting with midi-in on arduino, simply because i don't have midi-in interface but a keyboard with midi-out.

i'm trying my luck with a 4n28 optocoupler. so far i have an LED blinking when i hit a key on the keyboard. the led circuit is seperated from the midi circuit by the 4n28.
(actually its always blinking and just gets brighter when i hit a key !? any idea, someone?).

i wanted to route the serial midi signal through an arduino with the atmega taken out (tip from massimo). the problem is that zterm (my serial read/write application of choice) doesn't allow 31250 bps. so debugging the optocoupler setup won't work this way :-(

the question now is whether arduino serial settings (8-n-1) are compatible to midi-serial-communication which is 10-bit long. containing one start bit and one stop bit.
are arduino's settings changable using "secret power"-c ? or should it just work? i'm only understanding half of this.

/ kuk

Logged

Bremen, Germany
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

hi, did you read this one as well?

http://www.tigoe.net/pcomp/code/archives/arduino/000738.shtml#000738
Logged

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

i got it working.
partwise.
that means im only able to read the second byte of the midi byte stream. like:
if (serbyte == 61) {
    digitalWrite(ledPin2, HIGH);
    }
  if (serbyte == 73) {
    digitalWrite(ledPin2, LOW);
    }
  
 if (serbyte == 62) {
    digitalWrite(ledPin3, HIGH);
    }
  if (serbyte == 74) {
    digitalWrite(ledPin3, LOW);
    }

..... and so on
that means its just the note number wich is recognized, neither channel nor volume/noteOn/noteOff bytes.
in this code example i use one note to turn on the LED, anotherone to turn it off...
but im already a little bit happy, like this i can read notes. only problem at the moment: there must not be some other midisignals on the wire if yes--big trouble! because theres no channel separation.



greets
woo
Logged

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

cool. nice to know, you're working on it, too.

i had similar semi-satisfying results. since i couldn't get that optocoupler from the schematics i created a similar circuit with an 4N28 (which is basically slower i think). Still it worked until i blew it up by not spending attention to the wiring :-( .

stupid over-sensitive electrical devices smiley-razz

but i got myself some more of those 4N28 yesterday.

concerning the midi messages, i lost several hours waiting for a "Note off" (i mixed up "note on" and "note off", because of a wrong table somewhere on the net). which is never sent by my keyboard. instead most midi devices send a "note on with zero velocity" to stop a note...
maybe you're experiencing something similar?

//kuk







Logged

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

oh, here is the code i'm working on.
Code:
/* ################################ Basic Midi-in for arduino 0.1
 * reads midi-data from the serial line and lights individual LEDs for "Note on" messages
 * i am still working on the best wiring:
 * it's based on a 4N28 optocoupler to seperate circuits and invert the logic levels
 * the main problem here is the speed of the optocoupler to retain a clear digital signal.
 
   BUT IT WORKS!
  
   22/09/2006, kuk
 
   kuki_AT_milksoup.net
 */



//######################### DEFINE PINS ON ARDUINO
int led1 = 2;
int led2 = 3;
int led3 = 4;
int led4 = 5;
int led5 = 6;
int led6 = 7;
int led7 = 8;
int led8 = 9;
int midiEnable = 10; //this one "powers" the 4N28 to avoid having it on all the time, which interferes with bootloading
int statusLed = 13;

//######################### DECLARE VARIABLES
byte incomingByte;
byte action = 2; // 0=note off , 1= note on
byte note;
byte velocity;

//######################### SETUP EVERYTHING
void setup() {
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  pinMode(midiEnable,OUTPUT);
  Serial.begin(31250);        //midi baudrate
  
  //turn midi input on
  digitalWrite(midiEnable, HIGH);
  
  //do fancy startup signal
  blink();
  blink();
}


//######################### MAIN LOOP
// read serial data, and collect bytes that belong to the same midi message
void loop () {

      if (Serial.available() > 0) {
            //blinkfast();
            incomingByte = Serial.read();

                // collect data: we receive at least 3 bytes when a key gets hit: 1 statusbyte(channel & on/off/etc), and 2 databytes (key + velocity)
                if (incomingByte== 144){ // note on message channel 1
                  action=1;
                  blink();
                }else if (incomingByte== 128){ // note off message channel 1
                  action=0;
                  //blink();
                }else if (incomingByte== 208){ // aftertouch message channel 1
                 // not implemented yet
                }else if (incomingByte== 160){ // polypressure message channel 1
                 // not implemented yet
                }else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
                 note=incomingByte;
                 playNote(note, 0); //turns off the corresponding LED
                 note=0;
                 velocity=0;
                 action=2;
                }else if ( (action==1)&&(note==0) ){ // if we received a "note on", we wait for the note (next databyte)
                 note=incomingByte;
                }else if ( (action==1)&&(note!=0) ){ // ...and then the velocity data byte
                 velocity=incomingByte;
                 // now we have our bytes complete, let's make some visual noise
                 playNote(note, velocity);
                 //reset values
                 note=0;
                 velocity=0;
                 action=0;
                }else{
                 //nada
                }
      
      }

}

void blink(){
    digitalWrite(statusLed, LOW);
  delay(500);
  digitalWrite(statusLed, HIGH);
  delay(500);

}

void blinkfast(){
    digitalWrite(statusLed, LOW);
  delay(200);
  digitalWrite(statusLed, HIGH);
  delay(100);

}


void playNote(byte note, byte velocity){
  int value=LOW;
  if (velocity >10){
      value=HIGH;
  }else{
   value=LOW;
  }
  
  switch (note){
   case 60: //mid-C
    digitalWrite(led1, value);
    break;
   case 62: // D
    digitalWrite(led2, value);
    break;
    
    
  }
  //blink();
 
}


Logged

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

i just finished building the midi in circuit with the 6n138 on breadboard and tested it with your code, kuk.
seems to work fine.  ;D
Logged

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

yeehah,

:-D

i'm short on time right now, but i will post my schemetics (with 4n28) this evening, too. i got it working pretty reliable now!


//kuk
Logged

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

« Last Edit: September 25, 2006, 03:32:43 pm by leKuk » Logged

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

as i reported the circuit with the 6n138 worked here on breadboard. but now i soldered the circuit on stripboard and nothing is working anymore smiley-sad
i tested the optocoupler (0V on the input -> LED light up on the output. seems to work). no idea what might be wrong now.

update: working now again! smiley-wink
 8-)
« Last Edit: October 23, 2006, 11:59:33 am by haesslich » Logged

Lyon, France
Offline Offline
Newbie
*
Karma: 0
Posts: 8
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hello
I've been trying for sometime to implement a midi input on Arduino : I'm planning to build a midi module out of the MEGADRIVE (Genesis) sound chip
BUT
I stuck with this midi input...
I made a optocoupler interface no problem, with a 6N138 that seem to receive every midi byte OK but with the code below from Kuk, it sort of work execpt it doen't when you make chords.
It seems that only the first 3 bytes (one note bytes) are seen, which I don't interstand because the program should read all the byte until there is no more in the serial buffer.
how can I use the midi polyphonically ??(excuse my french;-)

thanks for your help
Logged


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