Pduino + Arduino Output to Pins
Unfortunately, snapshot~ doesn't seem to send data at a rate which enables clean signaling of arduino pins. When it comes to audio anything, I find that outputting signal is necessary, as outputting control values just cannot keep up with audio. If you are looking to make a square wave generator that is controllable from puredata, the best way that I have found to do this is by using a combination of arduino, a DAC chip and an op-amp chip. Also, you'll want to use at least a 12 bit DAC, such as mcp4921 or mcp4725, as 8 bit DAC lacks the ability to tune the output fine enough to stay in tune with standard tuning. For opamp choices, you can pretty much take your pick. They all do pretty much the same thing, though you will find that every opamp has it's own unique sound quality. I really love the gritty sound of the CA313. A very good and popular sound for opamp VCO is the tl072 or tl075. There are tons of schematics out there for how to configure a square wave vco with opamps. You would just modify the components to fit the output of your DAC.
Next, you would send your controller values from PD to the arduino and have some code in the ar'dweener to handle communicating with the DAC. You can then add all sorts of fun stuff to your board like digipots, opamp buffers, VCAs and so on to make envelopes, LFOs etc.
If you don't want to track down additional chips (usually ordered from china being the only way to find them, cheap though they tend to be,) but want to have square waves being output directly from the arduino, then you would still be better off having pd send control values to the arduino and then let the arduino handle the signal generation to it's pins. For this purpose, you may want to look at the tone library or the mozzi library. Teensy boards have some expanded audio capabilities as well, but teensy boards are a bit expensive for my taste, as you can get a freakin raspberry pi with a full linux operating system on it for a fraction of what it costs. Still, teensies are great and extremely handy for these types of applications if you dont mind dropping some extra money. I try to build everything to work on cheap arduino clones just for financial and practicality sake.
I have code and patches that I have written to control these types of circuits for many DACs and digipots with SPI and I2C protocalls... let me know if you'd like to check them out for some guidance.
Pduino + Arduino Output to Pins
Dear Forum,
Experienced PD user, intermediate Arduino user here.
My goal is to send several different frequency square waves (to be used as "on" and "off" signals for a circuit) to various output pins on an Arduino.
I am up and running using the Pduino library, and have PD and Arduino talking to each other.
However, I am not able to output audio-rate signals to any Arduino pins. For example, sending a square~ into an appropriately timed snapshot~ to output 0's and 1's to Arduino pins yields random clicking/sputtering Arduino output, rather than the expected steady square wave tone at any freq.
My arduinos play a square wave out through the pins just fine when using the Arduino IDE...so, what am I missing in the communication between Arduino and PD/Pduino? A speed issue?
Thanks in advance for any advice!
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.
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