Page 1 of 1
Posted: 13 Dec 2007, 15:54
by antwan
hi Olivier,
I wonder if you would have interest in implementing inputting of raw serial data for use with interfacing boards like Arduino / Wiring? This would cancel the need of using programs like Pure Data or Max/MSP in between, inputting the serial data from the USB port and converting it to OSC.
What do you think?
Antwan
Posted: 16 Dec 2007, 19:39
by senso
Unfortunately I don't know the Arduino protocol. But it's not a real problem to implement serial i/o modules.
Posted: 18 Dec 2007, 08:32
by antwan
Hi,
great. Well the arduino microcontroller is programmed with c++ (or c ?)... anyways. i think it's rather straightforward and simple. one should be able to select the serial port (COM #).
here's a simple code loaded to the arduino for reading the digital and analog input pins and sending them for MAX/MSP to read over serial. maybe this gives an idea:
Code: Select all
/*
* Arduino2Max
* Send pin values from Arduino to MAX/MSP
*
* Arduino2Max.pde
* ------------
* This version: .4, October 2007
* ------------
* Copyleft: use as you like
* by Daniel Jolliffe
* Based on a sketch and patch by Thomas Ouellet Fredericks tof.danslchamp.org
*
*/
int x = 0; // a place to hold pin values
int ledpin = 13;
void setup()
{
Serial.begin(115200); // 115200 is the default Arduino Bluetooth speed
digitalWrite(13,HIGH); ///startup blink
delay(600);
digitalWrite(13,LOW);
pinMode(13,INPUT);
}
void loop()
{
if (Serial.available() > 0){ // Check serial buffer for characters
if (Serial.read() == 'r') { // If an 'r' is received then read the pins
for (int pin= 0; pin<=5; pin++){ // Read and send analog pins 0-5
x = analogRead(pin);
sendValue (x);
}
for (int pin= 2; pin<=13; pin++){ // Read and send digital pins 2-13
x = digitalRead(pin);
sendValue (x);
}
Serial.println(); // Send a carriage returnt to mark end of pin data.
delay (5); // add a delay to prevent crashing/overloading of the serial port
}
}
}
void sendValue (int x){ // function to send the pin value followed by a "space".
Serial.print(x);
Serial.print(32, BYTE);
}
let me know if this helps at all. i can dig plenty more of material if needed....
antwan
Posted: 18 Dec 2007, 20:23
by senso
thanks.
I will help.
But the I can't do anything without a real arduino!
Posted: 20 Dec 2007, 13:54
by antwan
Although I'm not an actual programmer, I think you might be able to set this up even without having an arduino handy. I'll gladly be your beta tester. Forgive me if what I'm saying is nothing new to you - just trying to discuss this further. The same principle works for also other boards. Basically:
1) What the Arduino sends along the USB cable is coded into the Arduino microchip
2) For reading what is sent through the port, Usine should have the tools.
So let's say that the Arduino code sends a package sized three bytes, each containing one number (like a simple midi command would be). Usine should have the tools to open/close a certain COM-port. Then receive packages of varying sizes (if this is trouble, one could start with, say, 1-5 bytes in size) and the user should be able to treat those bytes separately. To me it seems to be quite like the way in which you've setup the OSC system. Here's another Arduino code, demonstrating input from a switch (=digital input of Arduino) turned into a "midi command" i.e. a 3 byte serial package:
Code: Select all
int buttonA = 2; // Pin button is connected to
// Key de-bouncing stuff
int lastKey = 0;
long time = 0;
int debounce = 100; // minimum allowed time between button presses
void setup() // run once, when the sketch starts
{
pinMode(buttonA, INPUT); // sets the digital pin as input
digitalWrite(buttonA, HIGH); // Pull high
Serial.begin(9600); // Start serial output
}
void loop() // run over and over again
{
if ((digitalRead(buttonA) == LOW) && (millis() - time > debounce) && lastKey != 1) {
noteOn(9,56,120); // channel 9 - maps to MIDI channel 10 AKA percussion)
// note 56 - Cow Bell!
// velocity 120 (127 = max)
time = millis(); // Reset debounce clock
lastKey = 1; // Store last button state
}
else if ((digitalRead(buttonA) == HIGH) && lastKey == 1)
lastKey = 0;
}
// Send a MIDI note-on message
void noteOn(byte channel, byte note, byte velocity) {
midiMsg(channel+0x90, note, velocity);
}
// Send a MIDI control change
void controlChange(byte channel, byte controller, byte value) {
midiMsg(channel+0xB0, controller, value);
}
// Send a general MIDI message
void midiMsg(byte cmd, byte data1, byte data2) {
Serial.print(cmd, BYTE);
Serial.print(data1, BYTE);
Serial.print(data2, BYTE);
}
Also, I can of course point you to some examples of how this has been implemented in PureData, Processing or Max, etc.
Thanks,
antwan
Posted: 20 Dec 2007, 22:53
by Clearscreen
Hi Senso, i've just got a couple of these boards as well so i can test things as well if need be. also, theres some pre-made interface code & protocols here
http://www.arduino.cc/playground/Interfacing/Firmata that may help. it appears that the guys over there are pretty happy to help write code to allow the board to interface with any software so it might be worth getting in touch with them if you need any assistance?
regards
C.
Posted: 21 Dec 2007, 08:58
by senso
thanks for the proposition.
I know by (small) experience that creating low level hardware interfaces is not so easy...especially if you don't have the hardware itself!
The first thing is to buy one!
Posted: 21 Dec 2007, 09:15
by antwan
sure, I understand.
you could get an arduino, one simple switch and some connecting wire and you're basically ready to go. maybe one led to test the data the other way...
if you like, you could also check the source code of this simple opensource application called S2MIDI, which basically receives data from a serial port and sends it forward along a virtual midi port.
http://www.memeteam.net/2007/s2midi/
and the code is available at:
http://code.google.com/p/s2midi/source/
I have used this succesfully with Arduino. It works only one way though.
best regards,
antwan
Posted: 21 Dec 2007, 23:08
by Clearscreen
fair enough senso. let us know if/when you need testers!
Posted: 09 Feb 2009, 19:34
by headphoner
Hi,
I just begin with arduino, so i want to know your experiences with arduino and usine.
I tried S2MIDI but it cost a lot of cpu on my computer...anybody improved other solution to receive serial data from the arduino to usine?
Posted: 09 Feb 2009, 21:45
by antwan
Hi,
No I'm still stuck using S2MIDI. I'd love to be running only one software though (=Usine!)...
antwan
Posted: 26 Feb 2009, 01:10
by Clearscreen
any chance of this being integrated into usine senso? i think i can lend you an arduino board if it helps...
Posted: 26 Feb 2009, 09:13
by senso
Not definitively dead but, not easy to implement because I don't have any serial hardware neither a serial port on my development machine...
I have uploaded a test program
http://sensomusic.com/forums/uploaded/T ... alPort.zip.
Tel me if it works (you can see incoming data's) and what is the speed of the communication. It's a first step. If it works it means that it's easy to implement.
I concentrate my work on the global ergonomic of Usine and this kind of module is a perfect candidate for a User module (SDK)?
Posted: 26 Feb 2009, 11:09
by Clearscreen
unfortunately the download is coming up '403 Forbidden'? looking forward to trying it!

Posted: 26 Feb 2009, 11:57
by senso
Posted: 26 Feb 2009, 20:04
by antwan
Hi,
I tried the test program but there was one little problem

When I selected the COM port and clicked Open the software gives an alert box that states:
"Demo version runs only with Delphi or C++Builder IDE"
antwan
Posted: 26 Feb 2009, 20:41
by senso
normal it's just a demo test program.
Posted: 26 Feb 2009, 20:53
by antwan
yes but I forgot to clarify that after this message the program quits. So apparently it doesn't want to run without Delphi or C++Builder IDE?
a
Posted: 27 Feb 2009, 00:05
by Clearscreen
antwan wrote:yes but I forgot to clarify that after this message the program quits. So apparently it doesn't want to run without Delphi or C++Builder IDE?
a
just to confirm, same trouble here senso...
Posted: 27 Feb 2009, 00:18
by senso
oups again.
I should sleep a little more....
sorry for the bad file.
Forget the test.
Posted: 28 Feb 2009, 06:15
by Clearscreen
No worries - now go get some sleep

! when you get around to it remember my offer to lend you an arduino board for testing may still stand, i don't have any immediate plans for it. also, i'd be happy if only the firmata protocol (
http://www.arduino.cc/playground/Interfacing/Firmata) got implemented as this would at least allow the bords I/O to be available for use in Usine.
Posted: 28 Feb 2009, 09:51
by senso
Interesting new protocol.
I'll watch it's future developments.
Posted: 01 Mar 2009, 01:04
by Clearscreen
it's been around for a few years, i think their on version 2 now. i'm currently still using an old version that works with vvvv to get my arduino to talk OSC and midi. it does make life a fair bit easier...
Posted: 01 Mar 2009, 11:48
by headphoner
Hi,
I finally found the solution for low cost of cpu with S2MIDI.
i have to use a very slow baud.
it seems that arduino vs usine are interesting a lot of people ...1296 views.
Posted: 01 Mar 2009, 22:11
by Clearscreen
Interesting - i haven't seen s2midi before. i'll give it a try...