Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 20 of 20

Thread: Is library "Firmata" working on the Teensy 3?

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Posts
    412

    Is library "Firmata" working on the Teensy 3?

    Is library "Firmata" working on the Teensy 3?

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    I've been working on Firmata. Here's the lines to add to Boards.h to make Teensy 3.0 work.

    Code:
    // Teensy 3.0
    #elif defined(__MK20DX128__)
    #define TOTAL_ANALOG_PINS       14
    #define TOTAL_PINS              38 // 24 digital + 10 analog-digital + 4 analog
    #define VERSION_BLINK_PIN       13
    #define IS_PIN_DIGITAL(p)       ((p) >= 0 && (p) <= 34)
    #define IS_PIN_ANALOG(p)        (((p) >= 14 && (p) <= 23) || ((p) >= 34 && (p) <= 38))
    #define IS_PIN_PWM(p)           digitalPinHasPWM(p)
    #define IS_PIN_SERVO(p)         ((p) >= 0 && (p) < MAX_SERVOS)
    #define IS_PIN_I2C(p)           ((p) == 18 || (p) == 19)
    #define PIN_TO_DIGITAL(p)       (p)
    #define PIN_TO_ANALOG(p)        (((p)<=23)?(p)-14:(p)-24)
    #define PIN_TO_PWM(p)           PIN_TO_DIGITAL(p)
    #define PIN_TO_SERVO(p)         (p)

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    412
    Works great! (using example "standardfirmata" ONLY) Now how would you handle the touch inputs?
    Last edited by t3andy; 12-15-2012 at 03:06 AM.

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    1
    Thanks for the support Paul! (I'm new to Teensy and hobby electronics in general).
    I'm working with Teensy 3.0 from python (using pyfirmata) and I created the following board definition. I'm not sure, but it looks like you have an "off by one" error on the analog pins. Am I correct?

  5. #5
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    I do not know. I've never really used Python.

    The firmata_test program is usually the easiest way to check your Firmata implementation against a known-good program.

  6. #6
    Member
    Join Date
    Nov 2012
    Location
    Santa Fe, New Mexico, USA
    Posts
    30
    I had fits getting firmata working today, using Ubuntu and the Teensy 3.0. Fixing the Boards.h definitions was the easy part, none of the firmata_test variants would work.

    I believe that the problem may be that the modem-manager has been upgraded in recent versions to ignore all the careful setting of ENV{ID_MM_DEVICE_IGNORE}="1" in /etc/udev/rules.d/* and elsewhere.

    In any case, I removed the modemmanager package and things work much better now.

    -- rec --

  7. #7
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by recri View Post
    I believe that the problem may be that the modem-manager has been upgraded in recent versions to ignore all the careful setting of ENV{ID_MM_DEVICE_IGNORE}="1" in /etc/udev/rules.d/* and elsewhere.
    I posted a question on the Gnome Network Manager mail list.

    Years ago, I exchanged several emails with the guy at Redhat who wrote the modem manager. Back then, the only way to prevent it from interfering was a hard-coded list. He promised to add Teensy to his list, but repeatedly forgot (we exchanged emails about this on each new release, when he would again promise to fix it on the next release). Apparently he redesigned how it all worked about every 6 months, tossing out his previous list of devices it has troubled. Finally, a huge number of bug reports about interference with a very wide range of USB devices piled up on Redhat's issue tracker and they added ID_MM_DEVICE_IGNORE. I optimistically hoped that would forever be the end of so much trouble from Gnome's modem manager.

    I just looked at the 0.9.8 network manager source code. Indeed it looks like they're redesigned it all over, yet again. I searched every file and found no trace of "ID_MM_DEVICE_IGNORE" or anything similar in the source code.

    Can you tell me which Linux distro/version you're using? Is there a way to see which version of the Network Manager or Modem Manager it installed?

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Hmmm.... now I just found mm-manager.c which has this code:

    Code:
        /* Is the device blacklisted? */
        if (g_udev_device_get_property_as_boolean (physdev, "ID_MM_DEVICE_IGNORE")) {
            mm_dbg ("(%s/%s): port's parent device is blacklisted", subsys, name);
            goto out;
        }
    Why it's not working is a mystery. I'm not sure I can put enough time into really investigating this throughly....

  9. #9
    Member
    Join Date
    Nov 2012
    Location
    Santa Fe, New Mexico, USA
    Posts
    30
    My problems were with a freshly upgraded Ubuntu 13.04, and with the Ubuntu 12.10 that it replaced.

    No fix required for me, I'll just use my phone as a hotspot.

    I updated all sources from the firmata.org repos, then added the Boards.h fix for Teensy 3.0.

    The source for firmata_test/Makefile contains

    WXCONFIG = ~/wxwidgets/2.8.10.gtk2.teensy/bin/wx-config

    but firmata_test doesn't come close to compiling even when that is corrected.

    The precompiled version of firmata_test for Ubuntu 12.04 worked once modem-manager was cleaned up.

    -- rec --

  10. #10
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    I got this help suggestion on the Gnone Network Manager mail list:

    From a quick look that rule should work, but remember you want to tag
    the entire *USB device*, not just the serial port. udev rules parsing
    changes might also affect whether or not this works. In any case, run
    'udevadm control --export-db' and check whether the USB device parent of
    the serial port actually has ID_MM_DEVICE_IGNORE defined.
    I might need to review the udev rule??

    It looks like the command should actually be "sudo udevadm info --export-db". You you please run this? The output is probably going to be very long. Maybe redirect to a file and look if there's any entries for "cdc_acm"? Or just save it to a big file and attach to a message here, if that's easier.

  11. #11
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Hi Paul,

    I have a Teensy 3.1 and want to use Firmata. Is there a similar block of code I can add to Boards.h for Teensy 3.1?

    Thanks!

  12. #12
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by rm90 View Post
    I have a Teensy 3.1 and want to use Firmata. Is there a similar block of code I can add to Boards.h for Teensy 3.1?
    Have you tried Firmata yet on 3.1? Odds are good it may "just work".

  13. #13
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    I did try, but it wouldn't compile and gave me the error "Please edit Boards.h with a hardware abstraction for this board."

    I also tried switching the Board from "Teensy 3.1" to "Teensy 3.0" in the Arduino IDE (not sure if this is recommended); the code compiled and uploaded, but it did not respond to Maxuino (which is what I'm ultimately trying to do).

    What do you think?

    Thanks!

  14. #14
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by rm90 View Post
    I did try, but it wouldn't compile and gave me the error "Please edit Boards.h with a hardware abstraction for this board."
    Install 1.18-rc2. It does compile.

    http://forum.pjrc.com/threads/24796-...te-2-Available

  15. #15
    The Firmata_compiled files located here:
    http://pjrc.com/teensy/td_libs_Firmata.html
    only contain hex files for Teensy 1.0 2.0 & Teensy++.

    Can anyone help with Firmata files for Teensy 3.1, please?
    I am currently using Teensyduino 1.18
    Last edited by rootScript; 04-16-2014 at 11:37 PM.

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    In Arduino, use File > Examples > Firmata > StandardFirmata. Set Tools > USB Type to "Serial" (Firmata is based on Serial) and then click Upload.

  17. #17
    Senior Member
    Join Date
    Apr 2015
    Posts
    125
    Quote Originally Posted by PaulStoffregen View Post
    In Arduino, use File > Examples > Firmata > StandardFirmata. Set Tools > USB Type to "Serial" (Firmata is based on Serial) and then click Upload.
    Is touchRead supported on Firmata for Teensy? It looks like not since there is only the analogRead method and pinouts(A2) and such don't compute when running the software from Processing. Just curious if there was anything I was missing to get this to work? Thanks.

  18. #18
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by ceremona View Post
    Is touchRead supported on Firmata for Teensy?
    No, not out of the box.

    You'd need to create a customized Firmata-based program (like the examples in File > Examples > Firmata) which sends the touchRead() results in place of the analog reads. Firmata is designed so you can create non-standard Firmata sketches that send different things... but it does require some programming to do so.

  19. #19
    Senior Member
    Join Date
    Apr 2015
    Posts
    125
    Maybe I'm wrong but it doesn't look like modifying one of these firmata demos is very hard at all. AFAIKT I don't even need to change anything in the header file, just sub out the pin numbers for which I want to get touchRead values and have the loop send out send out touchRead instead of the analogRead. Still being able to read out the data on the receiving side with analogRead, I would assume...

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,583
    Quote Originally Posted by rootScript View Post
    The Firmata_compiled files located here:
    http://pjrc.com/teensy/td_libs_Firmata.html
    only contain hex files for Teensy 1.0 2.0 & Teensy++.

    Can anyone help with Firmata files for Teensy 3.1, please?
    You will need to use Arduino with Teensyduino. Open File > Examples > Firmata > StandardFirmata. Make sure Tools > USB Type is set to Teensy 3.1. Then click Upload.

    I am currently using Teensyduino 1.18
    Wow, that's very old. Much has improved since then, with a lot of small bugs fixed. If anything doesn't work, try the latest version.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •