05 arduino and firmata (05.2010)
Hans-Christoph Steiner (PD dev) and a few others did a piece of ardino code wich turns basically your arduino into a fully external configurable I/O box.
to quote him:
"Basically, I have established a protocol for talking to the Arduino from the host software. It allows you to switch pins from input/output/pwm, and it allows you to read and write, of course ...
If you are interested, I can help you use this firmware with an whatever software. The protocol is quite simple. We will all benefit if we use a common firmware. Then Arduino becomes a really cheap sensorbox in addition to all the rest of the stuff you can already do with Arduino."
Inspired by Mr.Benefits previous work which you'll find at this page too, i (wirmachenbunt) made a plugin for the firmata 2.0 version. It should simplify the usage of the firmatized arduino and keep your patch clean of any serial communication stuff.
Youtube Video
ArduinoFirmataPlugin0.2.zip (8.04 Kb)
and a handy module to smooth analogue values, a noisecleaner...
noisecleaner.zip (3.32 Kb)
Previous Work done by Mr.Benefit 2006
arduino+firmata_11.2006.zip (102.82 Kb)
please note
my port works only with the included arduino code in the .zip file. (don't forget to upload this code to your arduino board)
the protocol is still changing ... so i will do a final version if the whole protocol is fixed. but for now on, only the included one will work.
for more infos follow:
project page arduino playground
sourceforge project page
snippet from the arduino code.
see how the protocol is working. (note: final version will be slightely different)
/* firmata protocol
* ===============
* data: 0-127
* control: 128-255
*/
/* computer<->Arduino commands
* -------------------- */
/* 128-129 // UNUSED */
/* two byte digital output data format
* ----------------------
* 0 get ready for digital input bytes (229)
* 1 digitalOut 7-13 bitmask
* 2 digitalOut 0-6 bitmask
*/
/* two byte PWM data format
* ----------------------
* 0 get ready for digital input bytes (ENABLE_SOFTWARE_PWM/ENABLE_PWM)
* 1 pin #
* 2 duty cycle expressed as 1 byte (255 = 100%)
*/
/* digital input message format
* ----------------------
* 0 digital input marker (255/11111111)
* 1 digital read from Arduino // 7-13 bitmask
* 2 digital read from Arduino // 0-6 bitmask
*/
/* analog input message format
* ----------------------
* 0 analog input marker (160 + number of pins to report)
* 1 high byte from analog input pin 0
* 2 low byte from analog input pin 0
* 3 high byte from analog input pin 1
* 4 low byte from analog input pin 1
* 5 high byte from analog input pin 2
* 6 low byte from analog input pin 2
* 7 high byte from analog input pin 3
* 8 low byte from analog input pin 3
* 9 high byte from analog input pin 4
* 10 low byte from analog input pin 4
* 11 high byte from analog input pin 5
* 12 low byte from analog input pin 5
*/
* ===============
* data: 0-127
* control: 128-255
*/
/* computer<->Arduino commands
* -------------------- */
/* 128-129 // UNUSED */
- define SET_PIN_ZERO_TO_IN 130 // set digital pin 0 to INPUT
- define SET_PIN_ONE_TO_IN 131 // set digital pin 1 to INPUT
- define SET_PIN_TWO_TO_IN 132 // set digital pin 2 to INPUT
- define SET_PIN_THREE_TO_IN 133 // set digital pin 3 to INPUT
- define SET_PIN_FOUR_TO_IN 134 // set digital pin 4 to INPUT
- define SET_PIN_FIVE_TO_IN 135 // set digital pin 5 to INPUT
- define SET_PIN_SIX_TO_IN 136 // set digital pin 6 to INPUT
- define SET_PIN_SEVEN_TO_IN 137 // set digital pin 7 to INPUT
- define SET_PIN_EIGHT_TO_IN 138 // set digital pin 8 to INPUT
- define SET_PIN_NINE_TO_IN 139 // set digital pin 9 to INPUT
- define SET_PIN_TEN_TO_IN 140 // set digital pin 10 to INPUT
- define SET_PIN_ELEVEN_TO_IN 141 // set digital pin 11 to INPUT
- define SET_PIN_TWELVE_TO_IN 142 // set digital pin 12 to INPUT
- define SET_PIN_THIRTEEN_TO_IN 143 // set digital pin 13 to INPUT
- define DISABLE_DIGITAL_INPUTS 150 // disable reporting of digital inputs
- define ENABLE_DIGITAL_INPUTS 151 // enable reporting of digital inputs
- define ZERO_ANALOG_INS 160 // disable reporting on all analog ins
- define ONE_ANALOG_IN 161 // enable reporting for 1 analog in (0)
- define TWO_ANALOG_INS 162 // enable reporting for 2 analog ins (0,1)
- define THREE_ANALOG_INS 163 // enable reporting for 3 analog ins (0-2)
- define FOUR_ANALOG_INS 164 // enable reporting for 4 analog ins (0-3)
- define FIVE_ANALOG_INS 165 // enable reporting for 5 analog ins (0-4)
- define SIX_ANALOG_INS 166 // enable reporting for 6 analog ins (0-5)
- define SEVEN_ANALOG_INS 167 // enable reporting for 6 analog ins (0-6)
- define EIGHT_ANALOG_INS 168 // enable reporting for 6 analog ins (0-7)
- define NINE_ANALOG_INS 169 // enable reporting for 6 analog ins (0-8)
- define SET_PIN_ZERO_TO_OUT 200 // set digital pin 0 to OUTPUT
- define SET_PIN_ONE_TO_OUT 201 // set digital pin 1 to OUTPUT
- define SET_PIN_TWO_TO_OUT 202 // set digital pin 2 to OUTPUT
- define SET_PIN_THREE_TO_OUT 203 // set digital pin 3 to OUTPUT
- define SET_PIN_FOUR_TO_OUT 204 // set digital pin 4 to OUTPUT
- define SET_PIN_FIVE_TO_OUT 205 // set digital pin 5 to OUTPUT
- define SET_PIN_SIX_TO_OUT 206 // set digital pin 6 to OUTPUT
- define SET_PIN_SEVEN_TO_OUT 207 // set digital pin 7 to OUTPUT
- define SET_PIN_EIGHT_TO_OUT 208 // set digital pin 8 to OUTPUT
- define SET_PIN_NINE_TO_OUT 209 // set digital pin 9 to OUTPUT
- define SET_PIN_TEN_TO_OUT 210 // set digital pin 10 to OUTPUT
- define SET_PIN_ELEVEN_TO_OUT 211 // set digital pin 11 to OUTPUT
- define SET_PIN_TWELVE_TO_OUT 212 // set digital pin 12 to OUTPUT
- define SET_PIN_THIRTEEN_TO_OUT 213 // set digital pin 13 to OUTPUT
- define OUTPUT_TO_DIGITAL_PINS 229 // next two bytes set digital output data
- define REPORT_VERSION 240 // return the firmware version
- define DISABLE_PWM 250 // next byte sets pin # to disable
- define ENABLE_PWM 251 // next two bytes set pin # and duty cycle
- define DISABLE_SOFTWARE_PWM 252 // next byte sets pin # to disable
- define ENABLE_SOFTWARE_PWM 253 // next two bytes set pin # and duty cycle
- define SET_SOFTWARE_PWM_FREQ 254 // set master frequency for software PWMs
/* two byte digital output data format
* ----------------------
* 0 get ready for digital input bytes (229)
* 1 digitalOut 7-13 bitmask
* 2 digitalOut 0-6 bitmask
*/
/* two byte PWM data format
* ----------------------
* 0 get ready for digital input bytes (ENABLE_SOFTWARE_PWM/ENABLE_PWM)
* 1 pin #
* 2 duty cycle expressed as 1 byte (255 = 100%)
*/
/* digital input message format
* ----------------------
* 0 digital input marker (255/11111111)
* 1 digital read from Arduino // 7-13 bitmask
* 2 digital read from Arduino // 0-6 bitmask
*/
/* analog input message format
* ----------------------
* 0 analog input marker (160 + number of pins to report)
* 1 high byte from analog input pin 0
* 2 low byte from analog input pin 0
* 3 high byte from analog input pin 1
* 4 low byte from analog input pin 1
* 5 high byte from analog input pin 2
* 6 low byte from analog input pin 2
* 7 high byte from analog input pin 3
* 8 low byte from analog input pin 3
* 9 high byte from analog input pin 4
* 10 low byte from analog input pin 4
* 11 high byte from analog input pin 5
* 12 low byte from analog input pin 5
*/
back to toc
