Carriage return in messages from Pd to Arduino?
Hello. I'm working on an Arduino code and accompanying Pd patch, sending values from Pd to Arduino to control the PWM value sent to certain digital pins.
As of now, the code parses incoming strings in the format int,int and ends with a carriage return. This works just fine when sending the string from the Arduino software's own serial monitor, but I cannot seem to get it work when sending messages to the [comport] object. Right now I'm just using a single banged message box (ex. [3,80]) sent to [comport], so I suspect that I need to end the message with a carriage return in some format.
How would I go about doing this? I know \ is not allowed in Pd messages. What format does the Arduino understand in this situation? Ascii?
In the code below, I suppose I could change the string terminating character to something other than a carriage return, but I would be unsure of how to execute it properly.
I'm quite new to the Arduino platform, so if anything looks and sounds completely off, please do tell me.
void setup()
{
Serial.begin(9600);
}
String command;
void loop()
{
if (Serial.available() > 0)
{
char c = Serial.read();
if(c == '\n')
{
parseCommand(command);
command = "";
}
else
{
command += c;
}
}
}
void parseCommand(String com)
{
String part1;
String part2;
//int SPACE int
part1 = com.substring(0, com.indexOf(","));
part2 = com.substring(com.indexOf(",") + 1);
int pin = part1.toInt();
int pwmval = part2.toInt();
analogWrite(pin, pwmval);
}
Thank you.
Getting DHT-22 sensor data to PD/PD-l2Ork RPi3
Hello, first post here as a PD newbie (but Max veteran)
I have managed to get PD working on my RPi3 (well that was easy as it is included in the Rasbian repository!!) and I am currently installing PD-l2Ork. I hate to ask stuff without having had a good stab at it myself already but I just wanted to ask for tips on getting sensor information into PD.
I am going to take part in Tiree Tech Wave in a couple of weeks and I want to make some kind of reactive bio feedback sample player, trying to scrub local weather data looks like it might be quite hard so I thought of doing something a little more micro scale and use something like the DHT-22 to get local ambient data and to influence a generative system that plays back samples from file.
I am fairly competant with Arduino style C and have done a little work in Python (but Python does give me a headache!!) - I have managed to get DHT-22 collecting and feeding back data on the RPi with Python and on the Arduino individually. I have no idea right now how to go about getting that data into PD...
The DHT-22 has a basic microprocessor on it that sends the collected ambient readings as words on a single wire data line, People have made nice Arduino and Python libraries already to handle that painlessly...
I have installed pd-comport and I have the impression the PD-l2Ork has some good included GPIO handling, I think that what I could do quite easily right now is bring an Arduino along as well and get the Arduino to handle all the DHT-22 stuff, and also react to the data - this could result in something like triggers activating on several GPIO pins, all easy stuff. But it would be nicer and I would learn more if I could send the actual numbers based on temperature and humidity to PD and do stuff there... I have no idea how easy that would be, in Max/MSP I would use the serial object to get data from the Arduino, and it's pretty easy to filter what you see at either end.
I guess another possible benefit of serial is perhaps using Bluetooth and having the sensor located more remotely.
Of course, it's probably totally unnecessary to use an Arduino and it can all be handled by the RPi but using Python makes my blood pressure go up
Anyway, woops I have written an essay... any thoughts, tips or words of encouragement would be welcomed!
pduino/win10 - RX errors from [comport]
Hi, I did have a search through the mail archive before I posted. But met dead-ends or info that went over my head. it seems like a fix was found here:
https://www.mail-archive.com/search?l=pd-list@lists.iem.at&q=subject:%22Re%5C%3A+%5C%5BPD%5C%5D+comport+rxerrors%22&o=newest&f=1
I found more recent builds here, but not recent enough, and they didn't resolve the issue:
http://puredata.info/search?SearchableText=comport
Although some search results are dated 2016, the most recent version of the comport.dll that I've found is from 29/5/2015 (two months before Win10 official release).
I'm a novice arduino user, but things seem ok in the IDE. Can see board info, upload sketches ok.
As a semi-functional workaround, I've got the arduino talking to Processing now, and sending OSC to PD. But I think the Processing Arduino library is limiting my Mega to Uno pin totals (0-5 analog, 2-13 digital), and is pretty heavy on system resources, causing lags in PD.
So Processing is handling the serial data ok on Windows 10, but I'd prefer to be able to use [comport].
Multiple patches sending to the same Arduino / change block size?
I'm working on a project involving Pure Data and Arduino. The idea is to play an audio file while controlling a pump that breathes air into an aquarium, based on the envelope of the audio, so that the bubbles correspond to the voice that you hear in headphones.
My problem is, while it works perfectly with one aquarium (playing the audio file + controlling the pump), it's less precise, and sometimes completely off, when I'm adding the others.
Files : main.pd, aquarium.pd, arduino.pd
The logic of one aquarium is inside an abstraction, [aquarium], with the file, threshold, audio output and Arduino pin as creation arguments. Every instance of the abstraction is playing its own file into a given audio output, and sending messages to the Arduino ("turn on pump X" or "turn off pump X"). It works quite well for most of the aquariums, so I guess (hope) the fix must be simple.
I tried different ideas to limit the message flow but didn't quite succeed (hence the mess below the [dac~] object, this stuff is not used anymore).
I only recently thought about increasing block size, thinking that would reduce the number of messages sent to the Arduino. However using the audio settings, it didn't seem to change anything, and I'm not sure how to use the [block~] object. Do I have to send the audio output through an [outlet~] object? I guess that would mean each of my 9 [aquarium…] blocks would need to have 9 outlets going into a [dac~] object in my main patch, and that would be a big spaghetti plate
I'd be curious to know if any of you has ever encountered this kind of issue, or has an idea to fix it, either with block size, pure data magic or anything else…
Thanks!
Problem with [comport]
Hello
i have one problem and i don't know how to solve it without going back to windows 8.1
before i update my pc to windows 10 my puredata+arduino work, on arduino i use Serial.write(); to comunicate with puredata with [comport 9600] but now when i open puredata sketch i get this error:
comport number 9600 out of range (1-99)
[comport] opening serial port 9600 failed!
comport number 9600 out of range (1-99)
[comport] opening serial port 9600 failed!
and when i try to open port 3 (where i have arduino connected) i get this error:
Opening COM3
[comport] opened serial line device 3 (COM3)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
[comport]: RXERRORS on serial line (997)
and i can't receive the data from arduino.
I am using arduino 1.6.4 and puredata 0.43.4- extended
anyone can help me?
thanks in advance
Pduino-based multi-arduino wireless personal midi controller network
Saw your TED video, so maybe you've already solved this problem.
In my limited work with getting arduino and pd to play nice, I've found that things like pduino and firmata work great but can be restrictive. I had to multiplex inputs on my arduino, which doesn't play nice with something like firmata that automatically reads all the pin values.
It might be better to have each arduino on it's own [comport], and differentiate the arduinos that way. Dump pin values over each comport and keep reading it.
Here's the thread explaining what I did:
http://puredata.hurleur.com/sujet-5832-reading-multiplexed-input-streams-arduino
I'm a fan of your work.
Pure Data and Arduino
Hello,
Although there seems to be endless information on the internet on using an Arduino board with Pure-Data, I haven't found any info that will make it work for me... So, I'm seeking for some help.
So I'm trying to use my Arduino board to read galvanic skin response. I've got that nearly working. Where I'm having trouble is getting the data into PD in the correct format.
Here is the code I have for my Arduino:
// Arduino Code
int sensorPin = A0;
int sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
float conductance = getVoltage(sensorPin);
Serial.println(conductance);
Serial.write(conductance);
delay(1000);
}
float getVoltage(int pin){
return (analogRead(pin));
}
// End Arduino Code.
I'm using the comport object in PD. And I am receiving Data which is analogous to what I'm doing on the board. But I can't understand exactly what it is reading. Here is the link to my PD patch: http://www.sendspace.com/file/n81jlj
So Firstly, the Numbers keep jumping around, and secondly I'm not sure what those numbers are. What I'd like them to be is the individual analog inputs of my Arduino. But they clearly aren't as they all change when I play around with my arduino board. Also they seem to range between 0 and 255, whereas my Arduino reads the data as 10bits...
Any sugestions!?
Thank you,
Niko.
Pd to arduino
hi there
I am trying to get video tracking info form vvvv to pd to arduino.
I want to control dc motors in an angle that is determined by the video tracking
so I managed to get the angle-info from vvvv to PD, now I want pd to transport it to my arduino but I cant get
clear how to do that. I am using the hansrudolfsteiner ( http://www.arduino.cc/playground/Interfacing/PD ) stuff but have a few questions.
-- i sent the data from vvvv to pd with the netsend/receive stuff, where do i connect that to a digital pin so the changing value gets transported to my arduino mega
--how can I read that digital pin so I can use it in my arduino program, do I really need to use the whole firmata patch? or can this be done easier? because I only need to read 1 pin... and I need my other pins for output
if somebody knows something about this, thanx in advance..
art
Reading multiplexed input streams from arduino
I'm currently building something with an arduino and pd. Arduino vets- help is appreciated!
So, I'm using [comport] and [convert.ascii2pd] to read inputs from an arduino. I'm not using pduino, firmata, etc. because I'm multiplexing the input.
I have a multiplexer read 8 potentiometers going into 1 analog input on my arduino. So I rapidly read all 8 of the inputs in a loop and print them out over serial.
My problem is I don't know how to take this stream and put it to an array properly. Out of [comport] to [convert.ascii2pd] to printing the results looks like this:
print: 790
print: CR
print: LF
print: 0
print: CR
print: LF
print: 0
print: CR
print: LF
print: 0
print: CR
print: LF
print: 703
print: CR
print: LF
print: 649
print: CR
print: LF
print: 547
print: CR
print: LF
END: bang
I'm seperating the values with special characters, which can be weeded out with [route] if need be. I have the end of each 8 input read banging.
But it's late and my head is reeling. Not sure where to start next in terms of putting these properly in a list or an array. The end goal being that I have 8 potentiometers that can control things in pure data. Any way to make sense of this input?
The things we do for more inputs!
Pduino-based multi-arduino wireless personal midi controller network
I am trying to find out if and how to create an arduino fio/xbee based wireless network of multiple fio/xbee's? 4 to be exact.
I am currently building a wireless system consisting of 2 "hand units", a wireless mouth interface and a base station xbee interfacing with pure data. www.beatjazz.blogspot.com. i already have the first fio/xbee communicating with the base station and pure data using pduino and all is perfect. this weekend i pick up the other 2 arduinos and fio's. all 3 arduinos need to connect with the pure data at the same time.
the instrument i am building is a wind midi controller except that instead of it being one horn like instrument, allthe left hand keys are in a wireless unit attached to the left hand and same goes for the right hand. the mouthpiece is worn like a headset microphone and is a pressure transducer for breath and a FSR for lip pressure. they must all work together as if one instrument. most of the coding has been done, andnow is time to split that code to the multiple wireless nodes.
it would seem that since all the xbee's have their own id's that that would translate over to the arduinos they are connected with and the whole network should come into the computer thru one serial port, which should solve that problem. I am wondering; how i might interface the 3 arduinos to pure data/pduino? theoretically, shouldnt i be able to name instances of the [arduino] object, say [arduino left], [arduino right], and [arduino mouth] so that each fio has its own instance? if so, how do i recognize the individual fio's and make use of their individual id's if that is the case at all?
Thank you in advance for any insight anyone might share.
Onyx