Monday, 22 February 2010

Arduino take 1


Took delivery of an Arduino Duemilanove a few days ago now. Since then i've been trying to break the back of a few things i had to resolve to ensure everything communicates correctly.

Firsty -
Once amplified, the signals sampled by the Nexus sensors need to be recognised in Max.

Secondly -
Messages from Max need to be communicated out the serial port to the Arduino's digital pins. Once done external electronics can be controlled through Max and the microcontroller.

Thirdly -
There may be times when simple on and off messages will not provide enough control to the actuator electronic devices (hardware/electronics that are controlled by the Arduino and Max - as an end game). There needs to be some kind of Digital to Analogue conversion either through max or after the software stage.


Input/Output communications
From research in Tom Igoe's 'Making things talk' and looking around arduino.cc (playground) i came across two solutions. The first was the SimpleMessagingSystem (SYS) provided by max/MSP examples where the Max constantly samples input pin voltages from the Arduino and converts the resultant ASCII messages into something usable in Max. In this case the Arduino and software are locked in a symbiotic relationship where messages are constantly sent and received at a set baud/sample rate. I've come across this system before and i found it to be lag significantly when the Arduino was being driven. In addition the SYS is more of an voltage sampler then something that was designed for sending data to the Arduino and because of this the output stages are not that well designed.

Igoe, T (2007) Making Things Talk Cambridge: O'Reilly ISBN-13 9780596510510
Simple Messaging System @ arduino.cc

The second solution was offered form a generic communications protocol called 'Firmata'. Unlike SYS it uses the Arduino as a slave device, committing all communication actions to MAX (or PD/Supercollider depending on the application). I found this to be a better piece of firmware mainly because it allows simple representation of the Arduino's analog input pins and should (with some manipulation of the MAX patch) allow simple Digital communication with the Arduino's output pins.

Some additional information at Firmata.org

After some routing i managed to use the Firmata protocol to effective set up triggers in Max so that i could set the Arduino's digital pins high or low (logic 1 or 0, 5v or 0v) on command. This would suit such applications as the activation of vibration devices or essentially anything that requires a static DC signal.

Where things get more difficult is when we consider a device such as a heating resistor. A device such as this could be used, for example, to heat a chest strap attached to one person that mimics temperature changes or stress level changes in another person. As the source information (skin temperature/GSR) is constantly changing, the voltage driving the heating resistor would also have to change respectively.
Potentially i could use some kind of Pulse Width Modulation set up within Max to send intermittent and rapidly changing logic levels to emulate voltages between 0 and 5v. This works well with lighting where a pulse with half its cycle at logic 1 (5v) and half its cycle at logic 0 (0v) will appear as if the LED is lit at 2.5v. Light however has the ability to change its state near instantaneously, heat does not. Will this work? I do not know.
The other option of course is to use a regulate the voltage outside of Max using smoothing capacitors similar to AC-DC conversion. This however is more complicated and requires more electric components. More components in a live installation means more chance of something going wrong.

PWM

PWM
Example of PWM voltage averaging - Micromouseinfo.com



No comments:

Post a Comment