Author |
Message |
himijendrix
Joined: Apr 16, 2012 Posts: 18 Location: Germany
|
Posted: Tue Jul 09, 2013 1:42 pm Post subject:
G Lab Looper + Arduino based Footswitch problem ... |
|
|
Hello,
I am working on an Arduino based MIDI footswitch for controlling a G Lab 4xLooper (M4L). As you can see in the manual (http://glab.com.pl/img/um_m4l_14062011.pdf) the G Lab can be controlled by Control Change messages.
I breadboarded a simple test circuit with a button to switch on and off the Loop 1 of the Glab via Midi, here's the code:
Quote: |
/*
Midi Footswitch, based on the Arduino example sketch ButtonStateChange
http://arduino.cc/en/Tutorial/ButtonStateChange
07.2013, JE
*/
#include <MIDI>.h
// setting the pins
const int button_1 = 7; // the pin that the pushbutton is attached to
const int led_1 = 13; // the pin that the LED is attached to
// switching variables
int buttonState_1 = 0; // current state of the button, all buttons off in the beginning
int lastButtonState_1 = 0; // previous state of the button
int channel = 1; //set Midi Channel
void setup() {
pinMode(button_1, INPUT); // initialize the button pin as a input:
pinMode(led_1, OUTPUT); // initialize the LED as an output:
MIDI.begin(channel);
MIDI.sendControlChange(80,0,channel); //switch off Loop 1 after start up
}
void loop() {
buttonState_1 = digitalRead(button_1); // read the pushbutton input pin:
if (buttonState_1 == HIGH) { //detects wheather the switch was pushed
if (buttonState_1 != lastButtonState_1) { // compare the buttonState to its previous state, if it is Low, the switch went from OFF to ON
MIDI.sendControlChange(80,127,channel); //switch Loop 1 ON
digitalWrite(led_1, HIGH);
lastButtonState_1 = HIGH; //save the current state as the last state, for next time through the loop
delay (500); //debounce
}
else { // if the current state is HIGH then the button went from ON to OFF
MIDI.sendControlChange(80,0,channel); //switch Loop 1 OFF
digitalWrite(led_1, LOW);
lastButtonState_1 = LOW;
delay (500);
}
}
}
|
When I send the Midi from the Arduino to my PC I can see the correct Control Change message in MidiOx. Also my Synthesizer is working with it.
But the GLab won't! the channel is set correctly, and when I send the exactly same Midi message with MidiOx from my PC to the GLab it also works.
So where could the problem be? Any Ideas?
The Midi Out of the Arduino is connected like this:
|
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24075 Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320
|
Posted: Tue Jul 09, 2013 2:06 pm Post subject:
|
|
|
Could it be that your baud rate is off a bit?
When its off at the receiving end too, and into the other direction such a thing may cause what you are seeing.
I'm not seeing an electrical problem in the circuit, and the software should be fine too. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Wed Jul 10, 2013 3:41 am Post subject:
|
|
|
Are you using an arduino midi library? If so, which version? I haven't done anything with it in a year, but your project might get me back into it.
Steve |
|
Back to top
|
|
|
himijendrix
Joined: Apr 16, 2012 Posts: 18 Location: Germany
|
Posted: Thu Jul 11, 2013 3:28 am Post subject:
|
|
|
@Blue Hell
I think for the MIDI protocol the baud rate is not ciritcal, you just send one command at any time and the receiver recognizes it. No Sync or anything ...
@MusicMan11712
I use this libary: http://playground.arduino.cc/Main/MIDILibrary and apart from the GLab Looper it seems to work pretty well |
|
Back to top
|
|
|
MusicMan11712
Joined: Aug 08, 2009 Posts: 1082 Location: Out scouting . . .
|
Posted: Thu Jul 11, 2013 4:18 am Post subject:
|
|
|
Hi. So far as I know, baud rate is indeed critical (as are other serial communication settings). From everything I know, most midi gear (if not all) communicates at 31.25kbps. (Blue_Hell and others can correct me if I am wrong). Serial communication necessarily needs to match settings (including baud rate) on both sending and receiving ends. Serial communication is done as a series of bits, so both sender and receiver must be in sync, that is how they know the where and when of serial "words." (Apologies if you know all this or if I am wrong.)
By the way, with my arduino tests with the hairless serial bridge for usb/midi communication between the arduino and my PC, I have had midi going at 256000 bps to my PC. However, in order for the hairless usb/midi bridge to recognize the data, I had to set the arduino's serial port to match the rate I had in the software:
Code: | void setup() {
// Set MIDI baud rate:
Serial.begin(256000);
}
|
Since midi gear always (or almost always) uses 31250 kpbs, to communicate with gear, I use that rate. I am not sure if the midi library sets the rate.
As for the midi library, I am pretty sure that's the same one I used; I will have to double check. But when I first looked at your code it struck me that something didn't look right--at least not the way I tested the library.
I will try to get back into my midi/arduino coding project. If you want to see what I did last year, its in the Arduino sub forum. I don't use the midi library there, but it might be helpful to you.
When I last left my project, I was testing the use of interrupts. (I recommend looking into them if you haven't done so already.) Specifically I use using the Timer1 library to see what I could do with a timer based interrupt and midi clock. When I got around to using buttons, I was planning to teach myself how to do hardware interrupts.
Anyhow, I am glad you raised the issue as it prompts me to pull out my project and see what else I can add to it.
Steve |
|
Back to top
|
|
|
blue hell
Site Admin
Joined: Apr 03, 2004 Posts: 24075 Location: The Netherlands, Enschede
Audio files: 277
G2 patch files: 320
|
Posted: Thu Jul 11, 2013 5:25 am Post subject:
|
|
|
JE wrote: | I think for the MIDI protocol the baud rate is not ciritcal, you just send one command at any time and the receiver recognizes it. No Sync or anything ...
|
You are confusing bit rate with byte rate - bit timing is critical to about 5% for most UARTS, but for some UARTS needs be tighter than that. _________________ Jan
also .. could someone please turn down the thermostat a bit.
|
|
Back to top
|
|
|
himijendrix
Joined: Apr 16, 2012 Posts: 18 Location: Germany
|
Posted: Thu Jul 11, 2013 10:31 am Post subject:
|
|
|
These posts where really helpful, didn't know anything about that baud rate.
I looked it up in the MIDI Library reference, and it says, that the MIDI.begin("input channel") sets the baud rate to 31250 by default.
But I think the G Lab should also use this baud rate, because otherwise it wouldn't react to MIDI messages sent from my PC, right?
I hope next week i will have some time to check everything again.
@MusicMan11712 I will try to have a look at your projects this weekend |
|
Back to top
|
|
|
jksuperstar
Joined: Aug 20, 2004 Posts: 2503 Location: Denver
Audio files: 1
G2 patch files: 18
|
Posted: Fri Jul 12, 2013 9:21 am Post subject:
|
|
|
Is this just one of those things where one device lists MIDI channels as 0-15, while the other lists them as 1-16? Make sure you map between the two:
0-15 : 1-16
0 : 1
1 : 2
...
15:16
The 16-step knob on the M4L looks like it says 1-16. Your code says "Channel=1". Try setting the M4L to channel 2. (or recompile your code with channel=0).
If you see MidiOX reporting channel = 1, then this is probably the issue. |
|
Back to top
|
|
|
|