Problem with 0017, Firmata 2.1 on Duemilanove

I recently upgraded to Arduino 0017 which includes Firmata 2.1, and my projects that use Standard Firmata no longer work. I believe I have found the problem but wanted to see what people thought.

I'm using the Processing Arduino library to interface with Standard Firmata, and the first thing I had to do was change the serial speed from 115200 to 57600 since this is the new default speed in Firmata 2.1. Digital outputs began to work but digital and analog inputs still did not.

I finally found that the StandardFirmata.pde sketch now calls Firmata.begin(57600) instead of calling Firmata.begin(). This seems fine except that these two implementations of the begin method in Firmata.cpp are different. This difference is causing digital and analog input to not work on my Duemilanove.

/* begin method for overriding default serial bitrate */
void FirmataClass::begin(void)
{
  Serial.begin(57600);
  blinkVersion();
  delay(300);
  printVersion();
}

/* begin method for overriding default serial bitrate */
void FirmataClass::begin(long speed)
{
  blinkVersion();
#if defined(__AVR_ATmega128__)  // Wiring                                                                     
  Serial.begin((uint32_t)speed);
#else
  Serial.begin(speed);
#endif
  delay(300);
  printVersion();
  printFirmwareVersion();
}

Note that in the no-arg version of begin(), the call to Serial.begin(57600) precedes blinkVersion(). But in the begin method that takes a speed argument, blinkVersion() is called before the call to Serial.begin(speed). This causes my Arduino to never send any inputs over the Serial line. There must be a timing issue here. When I change the order so that blinkVersion() occurs after Serial.begin(speed), everything works fine.

Short story: this can be fixed by reordering the Firmata.begin methods to make them consistent or to have the examples call the no-arg version of Firmata.begin().

Has anyone else had issues with using Firmata 2.1 included in Arduino 0017? I would think that anyone using any of the examples like StandardFirmata would have found them not to work...

Thanks. I reported this on the Firmata development list so we should be able to get it fixed. I'll give the Standard Firmata a try with the Processing Arduino library.

Thanks for your thorough bug report, I checked in a fix into the Firmata SVN. It would be great if you could test it. Either check out the whole thing:

svn co https://firmata.svn.sourceforge.net/svnroot/firmata/arduino/trunk

Or just download the file and copy it into place:

I tested your fix to Firmata.cpp and it works fine. I also tested the entire trunk, and no problems. Thanks much. Hopefully an updated Firmata can make it into Arduino 0018...

hi i've tried to change the firmata.ccp but nothing still works

i use an arduino mega with firmata 2.1 beta 3 and pduino 0.5 beta2

in the arduino 0017 of course

I use as3glue with Firmata 2.1 Changing the serialspeed ( in serproxy ) worked out good ( thanks for the tip ) and I have connection.

However I have also problems with the analog inputs. They don't give a range from 0-1023 anymore ( over a even range of 0-5V with a potmeter ). This is a software problem, because with Firmata 2.0 it works good.

Changing the firmata.cpp and firmata.h in the Arduino 17 library's folder didn't work either.

In the forum someone made his on changes :
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1253735359/0

Those work, but the serialspeed is different.

Since I use it in an educational situation it would be good that a standard becomes kind of a standard. I hope Arduino 18 can come with a stable version.

The StandardFirmata in 0017 turned out to be kind of buggy, unfortunately. We have things mostly fixed in SVN, but would love to have more testing and bug reports! So here's a new release. I fixed all bugs that I knew about, including the one where analog pins sometimes acted like they had a log curve on them.

http://at.or.at/hans/pd/objects.html#pduino

I tested this on a Diecimila, I hear there are troubles with the Arduino Pro and others, but I only have the older ones, so testing and bug reports on those are very helpful.

.hc

Is there still a problem with the latest firmware (i.e., svn trunk or your download link)? Owning a Mega, I'm still having the problem described above...

As stated by others, I can see the communication LEDs working, but running the blink example inside Processing, pin 13 doesn't blink.

Help? :slight_smile:

Unfortunately, the Arduino Mega support is spotty right now. There are some pins that work, and some that are mismapped (i.e. pin 13 is actually something like pin 20). My advice if you want to try to use Firmata on the Mega is try all the pins. For example:

  • turn on all analog pins and look to see which one your pot is hooked up to
  • turn on all pins to Output then hook up LEDs to all of them then test

Ok I will try those options and will come back here with some more info.

Does this mean that there should be a specific StandardFirmata for the Mega, or is it just a matter of fixing some bugs?

How can I help on this? I am proficient with programming languages (C and C++ included), but have little experience with the details of Firmata and Arduino.

Had the same problem with the 0017, Firmata 2.1 not working with the Arduino 328.

I went back to the Firmata 2 I was using before AND had to change the 57600 in serproxy.cfg and initial testing looks good.

My application needs to support both boards so I'll need to write a routine in to change the serproxy.cfg dynamically if the board is a 168 vs. 328 as the Arduino 168 don't work on 57600 in serproxy.cfg (I'm using as3glue with a flash app)

I would be curious to know why the same version of firmata only runs on the 168 board with serproxy.cfg at 115200 and at 57600 on the 328 board and if there is any way to fix that going forward?

On a side note, my app requires a reset of the board before running which I was doing with the command line on the 168 boards with this command

"C:\Program Files\DIY Magic Mirror\utils\arduino-0017\hardware\tools\avr\bin\avrdude.exe" -C "C:\Program Files\DIY Magic Mirror\utils\arduino-0017\hardware\tools\avr\etc\avrdude.conf" -pm168 -cstk500v1 -P\.%1 -b19200 -U hfuse:r:high.txt:s -U lfuse:r:low.txt:s

with the 328 board, a few changes and this works now too

"C:\Program Files (x86)\DIY Magic Mirror\utils\arduino-0017\hardware\tools\avr\bin\avrdude.exe" -C "C:\Program Files (x86)\DIY Magic Mirror\utils\arduino-0017\hardware\tools\avr\etc\avrdude.conf" -pm328p -cstk500v1 -P\.%1 -b57600 -U hfuse:r:high.txt:s -U lfuse:r:low.txt:s

I don't have a 328-based board, so I would greatly appreciate you testing this latest test release. On my boards, I fixed all of the bugs.

http://at.or.at/hans/pd/objects.html#firmata

If it doesn't work for you, I'll try to get my hands on a 328 board.

I don't have a 328-based board, so I would greatly appreciate you testing this latest test release. On my boards, I fixed all of the bugs.

http://at.or.at/hans/pd/objects.html#firmata

If it doesn't work for you, I'll try to get my hands on a 328 board.

Regarding the Mega, pin 13 is (wrongly) mapped to 15. I haven't been able to test the rest, since I'm still waiting for a led/pots kit to arrive by mail.

Any thoughts about the other questions on my previous post?

Thanks!

I don't have a 328-based board, so I would greatly appreciate you testing this latest test release. On my boards, I fixed all of the bugs.

http://at.or.at/hans/pd/objects.html#firmata

If it doesn't work for you, I'll try to get my hands on a 328 board.

(sorry about the triple post, it said "Internal Server Error")

ruidlopes,

I think its feasible to make StandardFirmata include full Mega support, but it could add a lot of complexity. If you are willing to take on the coding of it, I'll happily help where I can. I think the easiest way to start would be to make a MegaStandardFirmata and get that all working, so we have an idea of what needs to happen, and people can start using it. Then, we can check into the feasibility of merging the code into a single StandardFirmata.

How does that sound?

(sorry about the triple post, it said "Internal Server Error")

ruidlopes,

I think its feasible to make StandardFirmata include full Mega support, but it could add a lot of complexity. If you are willing to take on the coding of it, I'll happily help where I can. I think the easiest way to start would be to make a MegaStandardFirmata and get that all working, so we have an idea of what needs to happen, and people can start using it. Then, we can check into the feasibility of merging the code into a single StandardFirmata.

How does that sound?

Thanks for the quick answer on this.

It sounds like a great "one step at a time" approach :slight_smile: From what I could tell from the code, it might just be a matter of tweaking flags & masks on StandardFirmata, to comply with the extra fluff added on the Mega.

Am I right on this? Please do correct me where I'm wrong.

Yup, that's my guess too. I hope its not more complicated. I think the hard part is that they numbered things out of order with the mega. So while all the other Arduino boards pins 0-7 are one PORT, pins 8-14 are another PORT, and the analog pins are another PORT, on the mega, the numbers don't always go in sequence with the ports.

We have a new beta release we a major feature and minor fix:

  • Shigeru Kobayashi added support running servos on almost all the pins!
  • Hernando Barragán added some fixes for building for the Wiring board.

http://at.or.at/hans/pd/objects.html#pduino

I tested this on a Diecimila and original Arduino. These are the only Arduinos I have, so testing and bug reports on those are very helpful. There are no outstanding bugs that I know of, if I hear of no other bugs, I think this one will be the final release!

.hc