Hello,
Here's the mixer: http://www.allen-heath.com/ahproducts/qu-16/
Here's the midi spec: http://www.allen-heath.com/media/Qu-MIDI-Protocol-V1.3.pdf
And here's some pictures and videos of my project: Dropbox - File Deleted - Simplify your life
Here's my code (Compiled for a UNO + ethernet shield W5100, but I also tried a DUE + W5100, same problem!):
/*
tcp client
Arduino Ethernet shield w5100.
* Ethernet shield attached to pins 10, 11, 12, 13
* carte micro sd = pin 4
*/
#include <SPI.h>
#include <Ethernet.h>
// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 0xDE, 0xAD, 0xBE, 0x25, 0x11, 0x80 };
// if you don't want to use DNS (and reduce your sketch size)
// use the numeric IP instead of the name for the server:
//IPAddress server(192, 168, 1, 5); // numeric IP for Google (no DNS)
//char server[] = "www.google.com"; // name address for Google (using DNS)
// Set the static IP address to use if the DHCP fails to assign
IPAddress ip(192, 168, 1, 177);
// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;
void(* resetFunc) (void) = 0; //declare reset function @ address 0
class Strip
{
public:
int pin;
byte CH;
byte VX;
byte dernierEnvoye;
byte val;
void init(int p, byte c, byte v)
{
pin = p;
CH = c;
VX = v;
}
void tester()
{
val = map(analogRead(pin), 0, 1023, 0x00, 0x7F);
if (val != dernierEnvoye)
{
byte buf[] = { 0xB0, 0x63, CH, 0xB0, 0x62, 0x20 , 0xB0, 0x06, val, 0xB0, 0x26, VX};
client.write(buf, 12);
//client.write(0xFE);
dernierEnvoye = val;
}
}
};
const int nbStrip = 6;
Strip strip[nbStrip];
int nbFE = 0;
const int ledVerte = 32;
const int ledRouge = 33;
void setup() {
pinMode(ledVerte, OUTPUT);
pinMode(ledRouge, OUTPUT);
digitalWrite(ledVerte, HIGH); // vert
digitalWrite(ledRouge, HIGH); // rouge
pinMode(4, OUTPUT);
digitalWrite(4, HIGH); // disable SD SPI
strip[0].init(A0, 0X2C, 0x03);
strip[1].init(A1, 0X29, 0x03);
//strip[2].init(A1, 0X2A, 0x03);
strip[2].init(A1, 0X2B, 0x03);
//strip[4].init(A1, 0X2C, 0x03);
strip[3].init(A2, 0X24, 0x03);
strip[4].init(A2, 0X25, 0x03);
strip[5].init(A3, 0X23, 0x03);
// Open serial communications and wait for port to open:
Serial.begin(57600);
Serial.println("start!");
// while (!Serial) {
// ; // wait for serial port to connect. Needed for Leonardo only
// }
// start the Ethernet connection:
if (Ethernet.begin(mac) == 0) {
Serial.println("Failed to configure Ethernet using DHCP");
// no point in carrying on, so do nothing forevermore:
// try to congifure using IP address instead of DHCP:
Ethernet.begin(mac, ip);
}
// give the Ethernet shield a second to initialize:
delay(1000);
digitalWrite(ledVerte, LOW); // vert
digitalWrite(ledRouge, LOW); // rouge
Serial.println("connecting...");
// if you get a connection, report back via serial:
bool connexionOK = false;
for (int j = 0; j < 256; j++)
{
if (j % 2 == 0)
digitalWrite(ledRouge, HIGH); // rouge
else
digitalWrite(ledRouge, LOW); // rouge
IPAddress server(192, 168, 1, j); // QU-16 ip
Serial.println(j);
if (client.connect(server, 51325))
{
connexionOK = true;
break;
}
}
if (connexionOK) {
connexionOK = true;
Serial.println("connected");
Serial.println(Ethernet.localIP());
digitalWrite(ledVerte, HIGH); // vert
}
else {
digitalWrite(ledRouge, HIGH); // rouge
Serial.println("connection failed");
delay(1000); // wait for a second
Serial.println("resetting");
resetFunc(); //call reset
}
}
void loop()
{
// if there are incoming bytes available
// from the server, read them and print them:
bool recu = false;
if (client.available())
{
recu = true;
client.flush();
byte c = client.read();
Serial.print(c, HEX);
Serial.print(" ");
if (c == 0xFE)
{
nbFE++;
if (nbFE >= 2)
{
digitalWrite(ledVerte, HIGH); //vert
nbFE = 0;
}
else
digitalWrite(ledVerte, LOW); // vert
Serial.println();
}
}
if (recu)
{
for (int s = 0; s < nbStrip; s++)
strip[s].tester();
}
// if the server's disconnected, stop the client:
if (!client.connected()) {
digitalWrite(ledRouge, HIGH); // rouge
Serial.println();
Serial.println("disconnecting.");
client.stop();
delay(1000); // wait for a second
Serial.println("resetting");
resetFunc(); //call reset
// do nothing forevermore:
while (true)
{
;
};
}
digitalWrite(ledVerte, LOW); // vert
}
The Arduino searches for the mixer's ip adress and connects to it. This is ok.
The mixers begins to send "FE" every 300ms to keep the link active. This is ok.
The arduino reads some potentiometers values and send them to the mixer, by midi/tcp. This works fine. (you can see the videos!)
When I use the mixer directly (without touching the arduino), the mixer sends midi messages to the arduino to tell "this fader moved from... to ..." and this can be around 50 bytes (sometimes more) at once. When this happens, the arduino receive these midi informations and writes them to Serial. Then the "FE" byte starts again at 300ms interval. OK
But if there's too much messages coming at once from the mixer to the arduino, something goes wrong, the arduino stops responding...
I tried to ignore every message coming from the mixer (don't use the 'client.read()', or replaced it by a 'client.flush()), -> not better :~
I tried to remove everything related to "Serial" (maybe it is too slow compared to the ethernet) -> not better :~
I tried to disable the micro SD card reader (not used) -> not better
Does anybody have an idea?
Thank you for reading!
Johan