while waiting for some glue drying on cutterheadrepair i did a quick&dirty
midi remote control.
open source as i promised. i used an arduino and some other parts.
it works on Midi channel 1 and uses 4 notes starting from C3 on upwards.
it sets the pin to ground for 100ms. I also have a status LED for each command. which i guess can be removed.
only for testing. most pitch controllers anyway indicate a pressed button.
START=PIN2 and START LED=PIN3= Midi note "C3" =36
STOP =PIN4 and START LED=PIN5= Midi note "C3" =37
FAST =PIN6 and START LED=PIN7= Midi note "D" =38
MARK =PIN8 and START LED=PIN9= Midi note "D*" =39
you need
any kind of arduino board
a 5pin din socket
a 6N139 optocoupler or anything similar
a 220 ohm resistor
a 1k resistor
a small breadboard or a arduino shield
some cables
30 min of time
how to connect the optocoupler check here
http://www.google.ch/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&docid=y3Az0M1AnWqpiM&tbnid=d2Y3wrAQRFq17M:&ved=0CAUQjRw&url=http%3A%2F%2Fwww.instructables.com%2Fid%2FMIDI-Tester%2Fstep2%2FSchematic-diagram%2F&ei=5uxNUYO6L4TfPZmkgIAB&bvm=bv.44158598,d.ZGU&psig=AFQjCNEUQFyrFmhKrJgA_hgOMBsDojwDIA&ust=1364147744852263
on the picture you can see an empty 8pin socket. i later on will use a ATiny or a pic controller instead of the arduino.
but for someone who wants to just play around and build it quick i guess the arduino is great.
here you can find the arduino sketch. it will work with any arduino board. make sure pin2 (RX) is disconnected for uploading the sketch.
happy bricolage.
f.
Code: Select all
/* Midi to Lathe V0.1 flo@floka.com
*midi in is based on code done by kuki
*
* -----------------
* listen for midi serial data, and light leds for individual notes and set coresponding output to ground
Function:
this is a midi remote for (neumann lathes)
listen to midi serial data
if one of the four Notes for START,STOP,FAST, MARK is recieved the output and its led is set for 100ms
START=36="C3"=OUTPUT2=LED3
STOP=38="D3" =OUTPUT4=LED5
FAST=40="E3"=OUTPUT6=LED7
MARK=41="G3"=OUTPUT8=LED9
we dont wait for note off. just set the output for 100ms
IMPORTANT:
your arduino might not start if it receives data directly after a reset, because the bootloader thinks you want to uplad a new progam.
you might need to unplug the midi-hardware until the board is running your program. that is when that statusLed turns on.
#####################################################################################################################################################
SOMETHING ABOUT MIDI MESSAGES
midi messages start with one status byte followed by 1 _or_ 2 data bytes, depending on the command
example midi message: 144-36-100
the status byte "144" tells us what to do. "144" means "note on".
in this case the second bytes tells us which note to play (36=middle C)
the third byte is the velocity for that note (that is how powerful the note was struck= 100)
example midi message: 128-36
this message is a "note off" message (status byte = 128). it is followed by the note (data byte = 36)
since "note off" messages don't need a velocity value (it's just OFF) there will be no third byte in this case
NOTE: some midi keyboards will never send a "note off" message, but rather a "note on with zero velocity"
#####################################################################################################################################################
HARDWARE NOTE:
The Midi Socket is connected to arduino RX through an opto-isolator to invert the midi signal and seperate the circuits of individual instruments.
connect 4 outputs and 4 otional leds to pin2-pin9 on your arduino.
Midi Channel1,
START=PIN2 and START LED=PIN3= Midi note "C3" =36
STOP =PIN4 and START LED=PIN5= Midi note "Cis3" =37
FAST =PIN6 and START LED=PIN7= Midi note "D3" =38
MARK =PIN8 and START LED=PIN9= Midi note "Dis3" =39
####################################################################################################################################################
*/
//variables setup
byte incomingByte;
byte note;
byte velocity;
int statusLed = 13; // select the pin for the LED
int action=2; //0 =note off ; 1=note on ; 2= nada
//setup: declaring iputs and outputs and begin serial
void setup() {
pinMode(statusLed,OUTPUT); // declare the LED's pin as output
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
//start serial with midi baudrate 31250 or 38400 for debugging
Serial.begin(31250);
digitalWrite(statusLed,HIGH);
digitalWrite(2,HIGH); // set all ports high because inputs of pitch
digitalWrite(4,HIGH); // controller are low active. you might use
digitalWrite(6,HIGH); // optocouplers to prevent any ground loops or other troubles.
digitalWrite(8,HIGH); // in this case the outputs 2,4,6,8 must be inverted
}
//loop: wait for serial data, and interpret the message
void loop ()
{
if (Serial.available() > 0)
{
incomingByte = Serial.read();// read the incoming byte:
// wait for as status-byte, channel 1, note
if (incomingByte== 144)//144
{ // note on message starting starting
action=1;
}
else if ( (action==1)&&(note==0) )
{ // if we received a "note on", we wait for the note (databyte)
note=incomingByte;
}
else if ( (action==1)&&(note!=0) )
{ // we just read the velocity to be sure it is a regular midi note on sequence.an option could be to use the velocity to set lenght of the mark-time
velocity=incomingByte;
playNote(note);
note=0;
velocity=0;
action=0;
}
else{
//do nothing
}
}
}
void playNote(byte note)
{
//since we don't want to "play" all notes we wait for a note between 36 & 44
if(note>=36 && note<44)
{
byte myPin=note-34; // to get a pin number between 2 and 9
digitalWrite(myPin, 0); //low active key
delay(100); // wait for 100ms key stroke
digitalWrite(myPin, 1); //reset pin
// this part is for led indication only can be removed
digitalWrite(myPin+1, 1); //set led
delay(250);
digitalWrite(myPin+1, 0);//led off
delay(250);
}
}