Firmata on Tennsy 3.2

Status
Not open for further replies.

brucepomeroy

New member
Firmata on Teensy 3.2

Hi there,

I'm interested in recommendations on running Firmata on a Teensy 3.2. I found some downloads here https://www.pjrc.com/teensy/td_libs_Firmata.html. They don't make any reference to 3.x teensys though so i'm wondering if they're intended for 3.x series. I tried running the "Standard Firmata" example that comes with the Arduino IDE. I was able to compile and upload to the board no problem but it didn't seem to respond to Firmata commands. Has anyone used this with Teensy 3.2 and if so what modifications did they have to make to it? I assume at the minimum you'd need to specify the serial port that the Firmata commands are expected to be received on. Thanks in advance for any guidance on this.
 
Last edited:
Works for me on T3.2. in IDE i selected Examples > Firmata > StandardFirmata
on ubuntu i ran firmata_test and selected port /dev/ttyACM0. I could read analog ports, turn pin 13 LED on and off ....

I also ran a processing blink sketch on ubuntu.
 
Last edited:
Great, thanks Manitou. How did you have your board connected to your host computer? Just with the regular USB cable or did you attache a USB->TTL cable to one of the serial ports on the board?

Thanks so much.
 
Thanks again Manitou. I tried the setup you described and it worked well. I had actually been testing with a USB -> TTL cable connected to Serial1 and I still can't get that to work. I tried replacing the following line in Standard Firmata:
Firmata.begin(57600);
With:
Serial1.begin(57600);
Firmata.begin(Serial1);


But maybe that's not sufficient. Anyway, glad to have got it working with `Serial` now I have something to compare to and only a matter of time before I have it working with `Serial1`. In the meantime, if anyone has gotten Standard Firmata working using Serial1 on Teensy I'd love to hear what changes you had to make to the Standard Firmata example to get it to work.

Thanks!
 
You'll probably need to edit Firmata's Boards.h to disallow use of pins 0 and 1. If anything in Firmata tries to access them as GPIO, the pins are no longer controlled by Serial1.
 
That got it working, thanks Paul!

If anyone else runs into this, on OS X the file was here on my machine:
/Applications/Arduino.app/Contents/Java/libraries/Firmata/Boards.h

In that file look for:
...
// Teensy 3.0, 3.1 and 3.2
...
#define IS_PIN_DIGITAL(p) ((p) >= 0 && (p) <= 33)
...

And change it to:
...
// Teensy 3.0, 3.1 and 3.2
...
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 33) // Originally: ((p) >= 0 && (p) <= 33)
...


Thanks again!
 
I had a similar problem on Teensy 3.2 so that firmata worked via usb but failed over wireless. I'm using 2 xbee S1 radio transceivers, one as a usb dongle on my mac plugged into a sparkfun xbee explorer and the other xbee plugged to a teensy/xbee adapter board from sparkfun. As a client I'm using pduino on Pure Data Vanilla. v. 0.50
Rather than editing the boards.h file i added these two lines to the standard firmata arduino code:

// Ignore TX1 and RX1 pins
Firmata.setPinMode(0, PIN_MODE_IGNORE);
Firmata.setPinMode(1, PIN_MODE_IGNORE);

If you are using standard firmata you would add them after line 266 then change Serial to Serial1 as follows. Also I have commented out the line 782: Firmata.begin(57600); which seems to be redundant in this setup.
Teensy/Firmata now work over wireless.


Code should now read from 766 onwards:

// Ignore TX1 and RX1 pins
Firmata.setPinMode(0, PIN_MODE_IGNORE);
Firmata.setPinMode(1, PIN_MODE_IGNORE);


// to use a port other than Serial, such as Serial1 on an Arduino Leonardo or Mega,
// Call begin(baud) on the alternate serial port and pass it to Firmata to begin like this:

Serial1.begin(57600);
Firmata.begin(Serial1);

// However do not do this if you are using SERIAL_MESSAGE

// Firmata.begin(57600);
while (!Serial1) {
; // wait for serial port to connect. Needed for ATmega32u4-based boards and Arduino 101
}

systemResetCallback(); // reset to default config
}
 
Hello,
trying to use pin 26 to 31 as analog input but Firmata does not authorize to configure these pins as analog (I tried with Pure Data and Max/MSP).
Is anyone has the same problem / can solve this ?

I set Boards.h as follow :
// Teensy 3.0, 3.1
// Teensy 3.2
#elif defined(__MK20DX128__) || defined(__MK20DX256__)
#define TOTAL_ANALOG_PINS 16
#define TOTAL_PINS 49 // 28 digital + 16 analog-digital + 4 analog + 1 analog-DAC
#define VERSION_BLINK_PIN 13
#define PIN_SERIAL1_RX 0
#define PIN_SERIAL1_TX 1
#define PIN_SERIAL2_RX 9
#define PIN_SERIAL2_TX 10
#define PIN_SERIAL3_RX 7
#define PIN_SERIAL3_TX 8
#define IS_PIN_DIGITAL(p) ((p) >= 2 && (p) <= 33)
#define IS_PIN_ANALOG(p) (((p) >= 14 && (p) <= 23) || ((p) >= 26 && (p) <= 31))
#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 IS_PIN_SERIAL(p) (((p) > 6 && (p) < 11) || ((p) == 0 || (p) == 1))
#define PIN_TO_DIGITAL(p) (p)
#define PIN_TO_ANALOG(p) (((p) <= 23) ? (p) - 14 : ((p) <= 31) ? (p) - 11 : (p) - 28)
#define PIN_TO_PWM(p) PIN_TO_DIGITAL(p)
#define PIN_TO_SERVO(p) (p)
 
Status
Not open for further replies.
Back
Top