Author Topic: Firmata  (Read 5722 times)

Trakkasure

  • Newbie
  • *
  • Posts: 28
Firmata
« on: January 23, 2013, 09:44:40 pm »
Trying to get Firmata working here...
My attempt at a config for Firmata/Boards.h :



Code: [Select]

// DigiSpark
#elif defined(__AVR_ATtinyX5__)
#define TOTAL_ANALOG_PINS       4
#define TOTAL_PINS              6 // 6 digital + 4 analog
#define VERSION_BLINK_PIN       0
#define IS_PIN_DIGITAL(p)       ((p) >= 0 && (p) <= 5)
#define IS_PIN_ANALOG(p)        ((p) >= 0 && (p) <= 3)
#define IS_PIN_PWM(p)           ((p) == 0 || (p) == 1 || (p) == 4)
#define IS_PIN_SERVO(p)         (IS_PIN_DIGITAL(p))
#define IS_PIN_I2C(p)           ((p) == 0 || (p) == 3)
#define PIN_TO_DIGITAL(p)       (p)
#define PIN_TO_ANALOG(p)        ((p)==0?5:(p)==1?2?(p)==2?4:(p))
#define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p)         (p)


Now the default baud rate set in Firmata is 57600. So I update that to 115200 to avoid any problems.
Next load up the EchoString firmata demo and compile.


Code: [Select]

In member function 'void TinyDebugSerial::begin(long int)',
    inlined from 'void FirmataClass::begin(long int)' at /Users/myersbrandon/Applications/DigiSpark.app/Contents/Resources/Java/libraries/Firmata/Firmata.cpp:68:
/Users/myersbrandon/Applications/DigiSpark.app/Contents/Resources/Java/hardware/tiny-digispark/cores/tiny/TinyDebugSerial.h:705: error: call to 'TinyDebugSerialBaudMustBeConstant' declared with attribute error: The baud rate for Serial (TinyDebugSerial) cannot be changed at run-time.  Use 9600, 38400, or 115200.



I can't seem to find where there is code using a non-constant.


If I force to only use 115200, it compiles.. but doesn't seem to run.
I don't see any serial ports after running the code. (Watching /var/log/system.log)


I'm really playing catchup here, as I haven't done C/C++ coding for a while... and I'm currently winging it from old knowledge.


I'm running this on a MacBook Pro 15" plugging in through a USB 2.0 Hub to make sure it is recognized.


-- Brandon

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Firmata
« Reply #1 on: January 23, 2013, 11:01:12 pm »
Brandon -


I haven't used firmata much but form what I understand firmata uses serial to communicate with the host computer - the Arduino of course has a serial to usb converter on it and that makes it easy for the firmata code on the arduino to talk to the firmata application.


The Digispark can support SoftwareSerial on its pins - this is different in that it can talk to other serial devices like the Arduino, serial wifi modules, etc or a serial to usb converter - but its actual USB communication is done generally through HID communication, where it appears as an actual USB device and not a serial com port.


The Digispark can be made to show up as a serial device, but that hasn't been full expanded on yet and currently it just acts like a serial to usb converter for other devices.


Littlewire is a firmata like project that runs on the Digispark: http://digistump.com/board/index.php/topic,160.0.html


I have no doubt firmata can be adapted to the Digispark - the concept is simple enough, but it will certainly be a more involved port then using SoftwareSerial.


Hope that helps!


Thanks,
Erik

Trakkasure

  • Newbie
  • *
  • Posts: 28
Re: Firmata
« Reply #2 on: January 25, 2013, 07:39:19 pm »
I am using the built-in Firmata stuff that is already included in the Digispark arduino release.




So the changes I made were inline with the boards.h file.
Firmata uses SoftwareSerial as it's comms protocol. And as you said, it already supports it.


I'm really trying to get some sort of serial communication working.

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Firmata
« Reply #3 on: January 26, 2013, 02:13:54 am »
The firmata stuff is there because we do not remove anything from the Arduino release, we only add to it.


The Digispark can do software serial on its pins but it can not talk to the computer with it because it uses the HID protocol to talk to the computer rather than a serial to USB converter. Currently DigiUSB is the proof of concept of this - we hope to make that evolve quickly with more features and more compatibility with existing libraries.


Here are the timings I've been using to get softwareserial to work on the Digispark - still testing this - but again this would only work for the pins ie. talking to other serial devices, not for USB communication:


http://digistump.com/board/index.php/topic,212.msg1214/topicseen.html#msg1214