Pages: [1]   Go Down
Author Topic: Trouble connecting Arduino to Puredata (sending series of integers)  (Read 600 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I have trouble with connecting Arduino with Puredata. I want to send series of 13 integers and receive those values in Puredata over serial port...
I've tried all solutions from http://www.arduino.cc/playground/Interfacing/PD, but all with major problems :
- SimpleMessageSystem :

The problem is proper parsing of messages in Puredata, since integers can be sent by various lengths (up to 5 chars) and coresponding patch doesn't seem to be dealing with this ok - so numbers more look like a mess - also when parsing group command is used in PD that probably assumes fixed length of messages... ?

- Pduino: I'm basically doing this :
Code:
setup:
    Firmata.setFirmwareVersion(0, 1);
    Firmata.begin(115200);

loop:
  currentMillis = millis();
  if(currentMillis - previousMillis > samplingInterval) {
    previousMillis += samplingInterval;
    while(Firmata.available()) {
      Firmata.processInput();
    }
    for(pin = 0; pin < 5; pin++) {
      analogValue = (int)values[pin];
      Firmata.sendAnalog(pin, analogValue);
    }
  }

but it just does nothing... Shouldn't be sending values to PD ?

- Arduino PureData Message System
It seems the simplest, but Puredata patch doesn't parse integers from ascii text properly. It insers space after each digit, so reconstruction of integers is impossible to me...

I'd kindly ask for any guidance, pointer to more info or any experience with this... I'd just like to transfer set of 13 integers from Arduino to PD continuously..

Thanks in advance,

regards,
Bulek.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you may also be interested in using osc
http://liamtmlacey.blogspot.com/2011/03/arduino-to-maxmsp-via-osc-guide-and.html

im not clued in enough to correct your code here, but the other thing to note is it appears sendanalog is limited to 14bit ints = a max value of 16384.  are your ints exceeding this?
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 631
Posts: 50044
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The problem is proper parsing of messages in Puredata, since integers can be sent by various lengths (up to 5 chars) and coresponding patch doesn't seem to be dealing with this ok - so numbers more look like a mess - also when parsing group command is used in PD that probably assumes fixed length of messages... ?

So, send it a fixed length message. The sprintf() function can be used to control the format of the output of any integer. If you want exactly 5 characters, use %5f. If you want exactly 5 digits, use %05f. The difference, if the int is 35, is "   35" vs. "00035".

Quote
It seems the simplest, but Puredata patch doesn't parse integers from ascii text properly.
Seems unlikely that PureData can not parse integers correctly. If you posted your patch code, perhaps we could decipher it, and tell you how to format the Arduino output so PureData CAN parse it.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

thanks for responses. I'm including my PD patch in case anyone can recomend proper way of communication between Arduino and PD....



Thanks in advance,

regards


Bulek.

* Capacitive_synth_v4.zip (7.11 KB - downloaded 4 times.)
Logged

Pages: [1]   Go Up
Jump to: