Is library "Firmata" working on the Teensy 3?

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)
 
Works great! (using example "standardfirmata" ONLY) Now how would you handle the touch inputs?
 
Last edited:
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?
 
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.
 
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 --
 
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?
 
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....
 
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 --
 
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.
 
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!
 
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!
 
In Arduino, use File > Examples > Firmata > StandardFirmata. Set Tools > USB Type to "Serial" (Firmata is based on Serial) and then click Upload.
 
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.
 
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.
 
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...
 
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.
 
Back
Top