Hello list!
I am looking for some advice on sending messages from PD to an Arduino sketch. Essentially, I plan to connect a mac to an Arduino via USB and control a large amount of variables within the Arduino sketch from PD.
Is using the sysex message with the [arduino] object message the way to go with this? How can I "tag" the messages so that they go to the correct variable in the arduino sketch? Is there a practical limit to the speed of such a system?
I am much more familiar with using OSC messaging between applications but when I looked into using OSC with Arduino it seemed like I needed to use an ethernet shield (instead of connect via usb) and I would rather not go that route unless absolutely necessary.
Any advice is much appreciated!
cheers, Rick
There's an OSC library for Arduino here: https://github.com/CNMAT/OSC Using SLIP it can communicate over serial line using [comport] on the Pd end.
Martin
On Wed, Jun 1, 2016 at 10:29 AM, Rick Snow ricksnow@gmail.com wrote:
Hello list!
I am looking for some advice on sending messages from PD to an Arduino sketch. Essentially, I plan to connect a mac to an Arduino via USB and control a large amount of variables within the Arduino sketch from PD.
Is using the sysex message with the [arduino] object message the way to go with this? How can I "tag" the messages so that they go to the correct variable in the arduino sketch? Is there a practical limit to the speed of such a system?
I am much more familiar with using OSC messaging between applications but when I looked into using OSC with Arduino it seemed like I needed to use an ethernet shield (instead of connect via usb) and I would rather not go that route unless absolutely necessary.
Any advice is much appreciated!
cheers, Rick
Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list
The CNMAT OSC library works well and I often used it with a serial connection. The documentation, however, is not so good and some of the examples are buggy. I attached some test sketches/patches I once made for a class presentation. The arduino sketch explains how to easily send and receive OSC messages via a serial connection (make sure you use the same baud rate on both sides!)
Although OSC is convenient, it can be a waste of ressources if you send lots of messages. I often work with raw SLIP packages instead, where the first byte is used for addressing and the other bytes are the actual data (using some bit shifting to break up integers into several bytes). In the arduino code, use SLIPSerial.read() to fill an array (instead of an OSC message) and interpret your data as needed.
You can also make your own simple protocol where you define a certain character to signify the start or end of a message. But how do you know if it's not part of the data? SLIP uses escape sequences to handle this case. Two alternative solutions: a) work with fixed length messages and count bytes (not very safe) b) reduce the range of possible values for your data (e.g. 0-127, like MIDI) and reserve the rest for addressing (128-255). If you need a greater resolution for your values, just break them up into several bytes. This way, sending a single 16 bit integer would take 4 bytes (address, bit 14-15, bit 13-7, bit 0-6).
Christof
Gesendet: Mittwoch, 01. Juni 2016 um 17:16 Uhr Von: "Martin Peach" chakekatzil@gmail.com An: "pd-list@lists.iem.at" pd-list@lists.iem.at Betreff: Re: [PD] Pduino sysex vs. OSC advice
There's an OSC library for Arduino here: https://github.com/CNMAT/OSCUsing SLIP it can communicate over serial line using [comport] on the Pd end. Martin On Wed, Jun 1, 2016 at 10:29 AM, Rick Snow <ricksnow@gmail.com[ricksnow@gmail.com]> wrote:
Hello list! I am looking for some advice on sending messages from PD to an Arduino sketch. Essentially, I plan to connect a mac to an Arduino via USB and control a large amount of variables within the Arduino sketch from PD. Is using the sysex message with the [arduino] object message the way to go with this? How can I "tag" the messages so that they go to the correct variable in the arduino sketch? Is there a practical limit to the speed of such a system? I am much more familiar with using OSC messaging between applications but when I looked into using OSC with Arduino it seemed like I needed to use an ethernet shield (instead of connect via usb) and I would rather not go that route unless absolutely necessary. Any advice is much appreciated! cheers, Rick _______________________________________________ Pd-list@lists.iem.at[Pd-list@lists.iem.at] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...] _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]
Thanks Christof (and Martin) for pointing me to the CNMAT library.
I did spend a bit of time with this library before posting to the list but the tutorial I looked at originally required the ethernet shield. Now I am giving the slipenc/slipdec + OSC functionality a try. The raw SLIP packages look promising as well though I unfamiliar with bitshifting at this point!
Christof, Your Arduino_Serial patches look very promising. Thanks for taking the time to make this and send my way! I've taken a look and after getting the mrpeach objects loaded correctly (and the object/message connections correctly reconnected) am able to get the LED to light up using ArduinoTestOSC.pd.
There are a lot of unpackOSC messages telling me things like "Packet size (#) not a multiple of 4: dropping packet" but I think this is not a big problem right?
Thanks again! Rick
On Wed, Jun 1, 2016 at 6:40 PM, Christof Ressi christof.ressi@gmx.at wrote:
The CNMAT OSC library works well and I often used it with a serial connection. The documentation, however, is not so good and some of the examples are buggy. I attached some test sketches/patches I once made for a class presentation. The arduino sketch explains how to easily send and receive OSC messages via a serial connection (make sure you use the same baud rate on both sides!)
Although OSC is convenient, it can be a waste of ressources if you send lots of messages. I often work with raw SLIP packages instead, where the first byte is used for addressing and the other bytes are the actual data (using some bit shifting to break up integers into several bytes). In the arduino code, use SLIPSerial.read() to fill an array (instead of an OSC message) and interpret your data as needed.
You can also make your own simple protocol where you define a certain character to signify the start or end of a message. But how do you know if it's not part of the data? SLIP uses escape sequences to handle this case. Two alternative solutions: a) work with fixed length messages and count bytes (not very safe) b) reduce the range of possible values for your data (e.g. 0-127, like MIDI) and reserve the rest for addressing (128-255). If you need a greater resolution for your values, just break them up into several bytes. This way, sending a single 16 bit integer would take 4 bytes (address, bit 14-15, bit 13-7, bit 0-6).
Christof
Gesendet: Mittwoch, 01. Juni 2016 um 17:16 Uhr Von: "Martin Peach" chakekatzil@gmail.com An: "pd-list@lists.iem.at" pd-list@lists.iem.at Betreff: Re: [PD] Pduino sysex vs. OSC advice
There's an OSC library for Arduino here: https://github.com/CNMAT/OSCUsing SLIP it can communicate over serial line using [comport] on the Pd end. Martin
On Wed, Jun 1, 2016 at 10:29 AM, Rick Snow <ricksnow@gmail.com[ ricksnow@gmail.com]> wrote:
Hello list!
I am looking for some advice on sending messages from PD to an Arduino sketch. Essentially, I plan to connect a mac to an Arduino via USB and control a large amount of variables within the Arduino sketch from PD.
Is using the sysex message with the [arduino] object message the way to go with this? How can I "tag" the messages so that they go to the correct variable in the arduino sketch? Is there a practical limit to the speed of such a system?
I am much more familiar with using OSC messaging between applications but when I looked into using OSC with Arduino it seemed like I needed to use an ethernet shield (instead of connect via usb) and I would rather not go that route unless absolutely necessary.
Any advice is much appreciated!
cheers, Rick _______________________________________________ Pd-list@lists.iem.at[Pd-list@lists.iem.at] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...] _______________________________________________ Pd-list@lists.iem.at mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]
am able to get the LED to light up using ArduinoTestOSC.pd.
But you can also receive the data from the analog pin, right? (random values, if nothing is connected to the pin)
"Packet size (#) not a multiple of 4: dropping packet"
I can vaguely remember this message. Does it happen all the time or just at the beginning? Does it happen if you close and open the serial device? It didn't cause any problem with me. Actually, the Processing version of ArduinoSLIPSerialToUDP has protection against sending unvalid OSC messages.
Gesendet: Donnerstag, 02. Juni 2016 um 18:00 Uhr Von: "Rick Snow" ricksnow@gmail.com An: "Christof Ressi" christof.ressi@gmx.at Cc: "pd-list@lists.iem.at" pd-list@lists.iem.at Betreff: Re: Re: [PD] Pduino sysex vs. OSC advice
Thanks Christof (and Martin) for pointing me to the CNMAT library. I did spend a bit of time with this library before posting to the list but the tutorial I looked at originally required the ethernet shield. Now I am giving the slipenc/slipdec + OSC functionality a try. The raw SLIP packages look promising as well though I unfamiliar with bitshifting at this point! Christof, Your Arduino_Serial patches look very promising. Thanks for taking the time to make this and send my way! I've taken a look and after getting the mrpeach objects loaded correctly (and the object/message connections correctly reconnected) am able to get the LED to light up using ArduinoTestOSC.pd. There are a lot of unpackOSC messages telling me things like "Packet size (#) not a multiple of 4: dropping packet" but I think this is not a big problem right? Thanks again! Rick On Wed, Jun 1, 2016 at 6:40 PM, Christof Ressi christof.ressi@gmx.at wrote:The CNMAT OSC library works well and I often used it with a serial connection. The documentation, however, is not so good and some of the examples are buggy. I attached some test sketches/patches I once made for a class presentation. The arduino sketch explains how to easily send and receive OSC messages via a serial connection (make sure you use the same baud rate on both sides!)
Although OSC is convenient, it can be a waste of ressources if you send lots of messages. I often work with raw SLIP packages instead, where the first byte is used for addressing and the other bytes are the actual data (using some bit shifting to break up integers into several bytes). In the arduino code, use SLIPSerial.read() to fill an array (instead of an OSC message) and interpret your data as needed.
You can also make your own simple protocol where you define a certain character to signify the start or end of a message. But how do you know if it's not part of the data? SLIP uses escape sequences to handle this case. Two alternative solutions: a) work with fixed length messages and count bytes (not very safe) b) reduce the range of possible values for your data (e.g. 0-127, like MIDI) and reserve the rest for addressing (128-255). If you need a greater resolution for your values, just break them up into several bytes. This way, sending a single 16 bit integer would take 4 bytes (address, bit 14-15, bit 13-7, bit 0-6).
Christof
Gesendet: Mittwoch, 01. Juni 2016 um 17:16 Uhr Von: "Martin Peach" <chakekatzil@gmail.com[chakekatzil@gmail.com]> An: "pd-list@lists.iem.at[pd-list@lists.iem.at]" <pd-list@lists.iem.at[pd-list@lists.iem.at]> Betreff: Re: [PD] Pduino sysex vs. OSC advice
There's an OSC library for Arduino here: https://github.com/CNMAT/OSCUsing%5Bhttps://github.com/CNMAT/OSCUsing] SLIP it can communicate over serial line using [comport] on the Pd end. Martin
On Wed, Jun 1, 2016 at 10:29 AM, Rick Snow <ricksnow@gmail.com[ricksnow@gmail.com][ricksnow@gmail.com[ricksnow@gmail.com]]> wrote:
Hello list! I am looking for some advice on sending messages from PD to an Arduino sketch. Essentially, I plan to connect a mac to an Arduino via USB and control a large amount of variables within the Arduino sketch from PD. Is using the sysex message with the [arduino] object message the way to go with this? How can I "tag" the messages so that they go to the correct variable in the arduino sketch? Is there a practical limit to the speed of such a system? I am much more familiar with using OSC messaging between applications but when I looked into using OSC with Arduino it seemed like I needed to use an ethernet shield (instead of connect via usb) and I would rather not go that route unless absolutely necessary. Any advice is much appreciated! cheers, Rick _______________________________________________ Pd-list@lists.iem.at[Pd-list@lists.iem.at][Pd-list@lists.iem.at[Pd-list@lists.iem.at]] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]] _______________________________________________ Pd-list@lists.iem.at[Pd-list@lists.iem.at] mailing list UNSUBSCRIBE and account-management -> https://lists.puredata.info/listinfo/pd-list%5Bhttps://lists.puredata.info/l...]]