Inputting serial data
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
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
Unfortunately I don't know the Arduino protocol. But it's not a real problem to implement serial i/o modules.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
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:
let me know if this helps at all. i can dig plenty more of material if needed....
antwan
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);
}antwan
thanks.
I will help.
But the I can't do anything without a real arduino!
I will help.
But the I can't do anything without a real arduino!
Olivier Sens
www.brainmodular.com
www.brainmodular.com
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:
Also, I can of course point you to some examples of how this has been implemented in PureData, Processing or Max, etc.
Thanks,
antwan
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);
}Thanks,
antwan
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
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.
regards
C.
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!
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!
Olivier Sens
www.brainmodular.com
www.brainmodular.com
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
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
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
fair enough senso. let us know if/when you need testers!
-
headphoner
- Member
- Posts: 225
- Contact:
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?
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?
Hi,
No I'm still stuck using S2MIDI. I'd love to be running only one software though (=Usine!)...
antwan
No I'm still stuck using S2MIDI. I'd love to be running only one software though (=Usine!)...
antwan
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
any chance of this being integrated into usine senso? i think i can lend you an arduino board if it helps...
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)?
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)?
Olivier Sens
www.brainmodular.com
www.brainmodular.com
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
unfortunately the download is coming up '403 Forbidden'? looking forward to trying it!senso wrote:I have uploaded a test program http://sensomusic.com/forums/uploaded/T ... alPort.zip
oups try this link
http://www.sensomusic.com/forums/upload ... alPort.zip
http://www.sensomusic.com/forums/upload ... alPort.zip
Olivier Sens
www.brainmodular.com
www.brainmodular.com
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
I tried the test program but there was one little problem
"Demo version runs only with Delphi or C++Builder IDE"
antwan
normal it's just a demo test program.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
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
a
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
just to confirm, same trouble here senso...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
oups again.
I should sleep a little more....
sorry for the bad file.
Forget the test.
I should sleep a little more....
sorry for the bad file.
Forget the test.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
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.
Interesting new protocol.
I'll watch it's future developments.
I'll watch it's future developments.
Olivier Sens
www.brainmodular.com
www.brainmodular.com
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
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...
-
headphoner
- Member
- Posts: 225
- Contact:
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.
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.
-
Clearscreen
- Member
- Posts: 482
- Location: Australia
- Contact:
Interesting - i haven't seen s2midi before. i'll give it a try...
Who is online
Users browsing this forum: No registered users and 94 guests
