Teensy + Trellis?

Status
Not open for further replies.

dimixitas

New member
Hi all.

My project idea involves creating something like a mini version of a Novation Launchpad.

I'm using an Adafruit Trellis for this.
The Trellis works fine with an Arduino Uno, however because of the limitations of the MP3 Shield that I purchased for it, I can no longer use it for this project (unless anyone else knows a solution?)

So instead I opted for a Teensy 3.2, after watching the long instruction video by Paul and Alysia.

The problem is I tried to wire the Trellis to the Teensy the exact way that I did for the Arduino, but it doesn't work.
It only "worked" once; the buttons flashed as they do when the program runs, and then turned off, and after that, no matter how I wired it, the buttons don't cooperate.
Nothing has burned out; the buttons still work fine with the Arduino, and I believe I'm uploading files correctly to the Teensy, which also otherwise works fine; I upload the blink program to check.

The way to connect the Trellis to the Arduino is written here.
I followed these instructions, wiring the Trellis to the corresponding Teensy pins, but no luck any more.

Can anyone suggest what I may be doing wrong, or am I overlooking something, or are these things just not compatible?
 
First point would be that the Trellis is 5V and the Teensy is 3.3V. The data sheet for the IC used is at https://www.adafruit.com/datasheets/ht16K33v110.pdf and page nine shows that it's input power range is 4.5-5.5V and to get good data coms you need 0.7 of the supply voltage. Which works out as 3.5V so the 3.3V Teensy can't get high enough to send a 'high'. The right answer is to use a level converter such as:
https://www.adafruit.com/products/757
or whatever the equivalent is that you can get hold of locally.

The wrong answer is to put a power diode on the 5V supply to the Trellis. This will drop it's supply from 5V to 4.6-4.7 and the logic high to 3.29, which may be JUST low enough for a 3.3V Teensy to reach while being high enough for the Trellis to work. Will also impact the LEDS and generally not a good idea but MAY work well enough for testing if you are in a hurry and can afford to take risks.

Long term you need a 5V micro or a level converter for this project if it's going to use the Trellis.

Watch for 5V vs 3.3V logic (and the even lower Intel Edison logic levels that look to become more common) since many devices just blow up if cross connected. Teensy 3.2 can cope with 5V input being connected without harm so hopefully all is still well there. If it was the cheaper LC the outcome would have been far less certain.
 
Thanks for your answer GremlinWrangler.

I purchased the level converter, like you said.
However, I can't find any examples on how the wires go to and from it. I assume I wire the Teensy to the Low Voltage side and the Trellis to the High Voltage side and that's it, but I really don't want to blow up anything at this point. I would appreciate your help once again.
 
Thanks for your answer GremlinWrangler.

I purchased the level converter, like you said.
However, I can't find any examples on how the wires go to and from it. I assume I wire the Teensy to the Low Voltage side and the Trellis to the High Voltage side and that's it, but I really don't want to blow up anything at this point. I would appreciate your help once again.
In addition to converting the voltage from Teensy's 3.3v to Trellis' 5v, it is running i2c, and you need to add pull-up resistors to enable the i2c bus on the Teensy. The Arduino Uno does not need pull-ups, because it has strong enough pull-up resistors inside of the chip that the Wire library can enable, but the pull-up resistors the Teensy does have are not strong enough.

There have been various threads on what is the proper pull-up resistors to use. For 5v, a typical value is 4.7K. For 3.3v systems, a typical value is 2.2-2.4K, but 4.7K will also work (at least for the slower speeds). Before soldering permanent connections, I would try it on a breadboard, in case you need to change the two pull-up resistors (and if you don't have resistors lying about, buy a pack that includes at least 2.2K, 3.3K, 4.7K, and maybe 8.2K). Here is a fairly cheap resistor pack I picked up some time ago: http://www.dipmicro.com/store/SET-RF405

So for your setup, the connections would look like:

  • Connect Teensy Ground to GND on the LV side of the shifter;
  • Connect Teensy 3.3v to LV;
  • Connect Teensy pin 18/A4 to A1 on the shifter;
  • Also connect Teensy pin 18/A4 to a 2.2K resistor, and connect the other end of the resistor to Teensy 3.3v;
  • Connect Teensy pin 19/A5 to A2 on the shifter;
  • Also connect Teensy pin 19/A5 to a 2.2K resistor, and connect the other end of the resistor to the Teensy 3.3v;
  • If you want to use the interrupt pin, connect the Teensy pin to A3 on the shifter;
  • Connect the Trellis ground to GND on the HV side of the shifter;
  • Connect the Trellis 5v to HV on the shifter;
  • Also connect the VIN pin on the Teensy to the HV pin on the shifter (unless you want to use a different power supply for the Trellis -- if you do, you need to cross connect the grounds between the two power sources).
  • Connect the Trellis SDA pin to B1 on the shifter;
  • Connect the Trellis SCL pin to B2 on the shifter;
  • Connect the Trellis interrupt pin to B3 on the shifter.

Note, the A1/A2/A3 pins are arbitrary. As long as you hook up the A<n> pin from the Teensy and the same B<n> pin for the Trellis, it doesn't matter which ones you use.

If you want to use i2c at higher speeds, change to use the alternate pins, and/or use the second i2c bus, you need to use the i2c_t3 library instead of the Wire library.
 
Last edited:
Hey MichaelMeissner,

Thanks so much for your detailed instructions!
I tried to follow them to the letter, but unfortunately, the Trellis still refuses to light up.
I checked before and after if anything is broken/burnt out, but everything works fine.

I'll attach a few images for you, if that helps.
Please be patient, this is my first few months with electronics, so I don't know what looks right and what doesn't.
20160415_210023_resized_1.jpg20160415_210028_resized_1.jpg20160415_210039_resized_1.jpg
 
Working from the photo's suggest as a first point putting your pull ups in the breadboard, and wiring to them since electrical tape is not very robust for making electrical joins.

A bread board has metal rails connecting each row of five holes, so you can put the resistors in running sideways, starting from the same set of five, and ending in different ones, and then connect the wires to any of the remaining holes in the relevant rows (the red and blue marked long rows are special and run the other way for the whole length, normally used for power/ground).

With the level converter and Teensy wiring would be also be suspicious of the connections with the narrow pin tips just feed through the holes like that. Ideally you'd solder headers into the holes, then jamb the headers into the bread board and put wires into the breadboard on the same column getting a nice solid mechanical connection at each point. Anything that can just fall out isn't going to work. If you don't have a soldering iron handy it may work to do what you've done, but use the headers pins that should have come with the break out board (Teensy probably didn't) to stake it out. The larger square pins are more likely to make a solid mate, though it would still be vulnerable to bumps until it got soldered.

Also, conventionally you'd wire up +vs in red, grounds in black and if possible use like colours for the same signal (so clock on both sides of the level converter is the same colour) Makes reading the layout easier, and far less likely to accidentally connect power to something.

Fundamentally you need to get headers soldered and suspect working out how to do that is the next step.
 
Just to clarify, the wires under the electrical tape are in fact soldered together, the tape was there so that there's no live parts exposed.

I'll solder some headers and retry the wiring.

Just a question, the Teensy has two 3.3v pins (one with 250 mA limitation, and one without) and two GND pins.
Which ones am I supposed to be using? Whenever I tried anything on the bottom 3.3v, one part of the Teensy would get hot fast, so I'm guessing that's for something else.

Thanks for your response!
 
Teensy has one regulator for making 3.3V - those pins/pads are common and share the same source - the T_3.2 has the raised 250mA max (shared) limitation over the T_3.1's 100mA

The Pad would likely be more current limited than the PTH
 
Last edited:
I´ve the same issue, connect everything as Michael Meissner suggest and upload the test skecht from trellis and have no response in the serial monitor.
Check the voltage and connectivity across the teensy, trellis and the logic converter and seems correct. The high and low works in both side of the converter.

Any suggestion?
Thanks
 
Might help to see picture of setup, plus the sketch and library you are using.

Hopefully can see and or describe which level converter you are using, which pull-up resistors..
 
KurtE, the setup I´ve right now it´s exactly like the description and the photo.
I´m using this converter: https://www.sparkfun.com/products/12009
And a 2,2k pull-up. Also tested with 3,3k resistor.

I can´t get anything in the serial monitor. Not even the setup message:

Code:
  Serial.begin(9600);
  Serial.println("Trellis Demo");

The test sketch from adafruit. Wire library. (The sketch need any specific change for teensy?)

Code:
/*************************************************** 
  This is a test example for the Adafruit Trellis w/HT16K33

  Designed specifically to work with the Adafruit Trellis 
  ----> https://www.adafruit.com/products/1616
  ----> https://www.adafruit.com/products/1611

  These displays use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  MIT license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include "Adafruit_Trellis.h"

/*************************************************** 
  This example shows reading buttons and setting/clearing buttons in a loop
  "momentary" mode has the LED light up only when a button is pressed
  "latching" mode lets you turn the LED on/off when pressed

  Up to 8 matrices can be used but this example will show 4 or 1
 ****************************************************/

#define MOMENTARY 0
#define LATCHING 1
// set the mode here
#define MODE LATCHING 


Adafruit_Trellis matrix0 = Adafruit_Trellis();

// uncomment the below to add 3 more matrices
/*
Adafruit_Trellis matrix1 = Adafruit_Trellis();
Adafruit_Trellis matrix2 = Adafruit_Trellis();
Adafruit_Trellis matrix3 = Adafruit_Trellis();
// you can add another 4, up to 8
*/

// Just one
Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0);
// or use the below to select 4, up to 8 can be passed in
//Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0, &matrix1, &matrix2, &matrix3);

// set to however many you're working with here, up to 8
#define NUMTRELLIS 1

#define numKeys (NUMTRELLIS * 16)

// Connect Trellis Vin to 5V and Ground to ground.
// Connect the INT wire to pin #A2 (can change later!)
#define INTPIN A2
// Connect I2C SDA pin to your Arduino SDA line
// Connect I2C SCL pin to your Arduino SCL line
// All Trellises share the SDA, SCL and INT pin! 
// Even 8 tiles use only 3 wires max


void setup() {
  Serial.begin(9600);
  Serial.println("Trellis Demo");

  // INT pin requires a pullup
  pinMode(INTPIN, INPUT);
  digitalWrite(INTPIN, HIGH);
  
  // begin() with the addresses of each panel in order
  // I find it easiest if the addresses are in order
  trellis.begin(0x70);  // only one
  // trellis.begin(0x70, 0x71, 0x72, 0x73);  // or four!

  // light up all the LEDs in order
  for (uint8_t i=0; i<numKeys; i++) {
    trellis.setLED(i);
    trellis.writeDisplay();    
    delay(50);
  }
  // then turn them off
  for (uint8_t i=0; i<numKeys; i++) {
    trellis.clrLED(i);
    trellis.writeDisplay();    
    delay(50);
  }
}


void loop() {
  delay(30); // 30ms delay is required, dont remove me!
  
  if (MODE == MOMENTARY) {
    // If a button was just pressed or released...
    if (trellis.readSwitches()) {
      // go through every button
      for (uint8_t i=0; i<numKeys; i++) {
	// if it was pressed, turn it on
	if (trellis.justPressed(i)) {
	  Serial.print("v"); Serial.println(i);
	  trellis.setLED(i);
	} 
	// if it was released, turn it off
	if (trellis.justReleased(i)) {
	  Serial.print("^"); Serial.println(i);
	  trellis.clrLED(i);
	}
      }
      // tell the trellis to set the LEDs we requested
      trellis.writeDisplay();
    }
  }

  if (MODE == LATCHING) {
    // If a button was just pressed or released...
    if (trellis.readSwitches()) {
      // go through every button
      for (uint8_t i=0; i<numKeys; i++) {
        // if it was pressed...
	if (trellis.justPressed(i)) {
	  Serial.print("v"); Serial.println(i);
	  // Alternate the LED
	  if (trellis.isLED(i))
	    trellis.clrLED(i);
	  else
	    trellis.setLED(i);
        } 
      }
      // tell the trellis to set the LEDs we requested
      trellis.writeDisplay();
    }
  }
}

Thanks
 
Hopefully someone who has the Trellis can answer more about the electrical hookup... Again pictures are nice as, yes you say it is the same as the ones above, but sometimes we miss things...
Things like: I assume you are passing +5v and GND to the Trellis board.

I have not done very much I2C stuff with Teensy most of the time, I use more SPI and USART... But awhile ago did some experimenting with some old I2C sonar sensors SR08 and SR10, which required level shifting. First things I found was not all level shifters are created equal. I had some better luck with some and no luck with others... Looking back at the K66 beta thread, I do see that I mentioned that I had luck with a BSS138 level shifter board, but had to experiment with resistors or not resistors... (wish I would have stated which one worked )

Now for Serial.print not showing up. The Teensy is sort of like the Arduino Leonardo, in that the main processor does the USB and as such it takes a little time before the USB (Serial) is ready.

That is why you will see many places up on the forum, stating that we often add code at the beginning of our programs, that looks something like:
Code:
Serial.begin(115200);
while (!Serial && (millis() < 5000)) ;
delay(250);
Which is setup to wait for the Serial object to be there or timeout after 5 seconds (You can change the timeout, to whatever you want), plus I wait a little time to make sure it is ready...

Did you hook up the INTPIN (A2) to the shifter?

Also have you tested the Trellis to make sure it works? If it were me, I would pull at a +5v Arduino like an UNO or the like and see if it works with it. It would maybe rule out things like you put the LEDS in the wrong way. Also I assume once you started up the program that you tried pressing some of the buttons to see if you get anything printing out.

Not sure what else, maybe others will have ideas

Kurt
 
Okay, I tried with teensy, this time with a external 5v power supply. Following the guide of MichaelMeissner
Using 2.2k resistor, BSS138 level shifter board, and basic sketch without interrupt.

Also work with Pro Micro (5v) and a external power supply and works great.

Thanks!
 
Sorry to bring back an old thread, but ain't that level shifter already have a 10k pull up resistor built in? Correct me if i am wrong, but I think you don't need a pull up resistor with this device. They give the schematic on the sparkfun web site.

Frank


KurtE, the setup I´ve right now it´s exactly like the description and the photo.
I´m using this converter: https://www.sparkfun.com/products/12009
And a 2,2k pull-up. Also tested with 3,3k resistor.

I can´t get anything in the serial monitor. Not even the setup message:

Code:
  Serial.begin(9600);
  Serial.println("Trellis Demo");

The test sketch from adafruit. Wire library. (The sketch need any specific change for teensy?)

Code:
/*************************************************** 
  This is a test example for the Adafruit Trellis w/HT16K33

  Designed specifically to work with the Adafruit Trellis 
  ----> https://www.adafruit.com/products/1616
  ----> https://www.adafruit.com/products/1611

  These displays use I2C to communicate, 2 pins are required to  
  interface
  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  MIT license, all text above must be included in any redistribution
 ****************************************************/

#include <Wire.h>
#include "Adafruit_Trellis.h"

/*************************************************** 
  This example shows reading buttons and setting/clearing buttons in a loop
  "momentary" mode has the LED light up only when a button is pressed
  "latching" mode lets you turn the LED on/off when pressed

  Up to 8 matrices can be used but this example will show 4 or 1
 ****************************************************/

#define MOMENTARY 0
#define LATCHING 1
// set the mode here
#define MODE LATCHING 


Adafruit_Trellis matrix0 = Adafruit_Trellis();

// uncomment the below to add 3 more matrices
/*
Adafruit_Trellis matrix1 = Adafruit_Trellis();
Adafruit_Trellis matrix2 = Adafruit_Trellis();
Adafruit_Trellis matrix3 = Adafruit_Trellis();
// you can add another 4, up to 8
*/

// Just one
Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0);
// or use the below to select 4, up to 8 can be passed in
//Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0, &matrix1, &matrix2, &matrix3);

// set to however many you're working with here, up to 8
#define NUMTRELLIS 1

#define numKeys (NUMTRELLIS * 16)

// Connect Trellis Vin to 5V and Ground to ground.
// Connect the INT wire to pin #A2 (can change later!)
#define INTPIN A2
// Connect I2C SDA pin to your Arduino SDA line
// Connect I2C SCL pin to your Arduino SCL line
// All Trellises share the SDA, SCL and INT pin! 
// Even 8 tiles use only 3 wires max


void setup() {
  Serial.begin(9600);
  Serial.println("Trellis Demo");

  // INT pin requires a pullup
  pinMode(INTPIN, INPUT);
  digitalWrite(INTPIN, HIGH);
  
  // begin() with the addresses of each panel in order
  // I find it easiest if the addresses are in order
  trellis.begin(0x70);  // only one
  // trellis.begin(0x70, 0x71, 0x72, 0x73);  // or four!

  // light up all the LEDs in order
  for (uint8_t i=0; i<numKeys; i++) {
    trellis.setLED(i);
    trellis.writeDisplay();    
    delay(50);
  }
  // then turn them off
  for (uint8_t i=0; i<numKeys; i++) {
    trellis.clrLED(i);
    trellis.writeDisplay();    
    delay(50);
  }
}


void loop() {
  delay(30); // 30ms delay is required, dont remove me!
  
  if (MODE == MOMENTARY) {
    // If a button was just pressed or released...
    if (trellis.readSwitches()) {
      // go through every button
      for (uint8_t i=0; i<numKeys; i++) {
	// if it was pressed, turn it on
	if (trellis.justPressed(i)) {
	  Serial.print("v"); Serial.println(i);
	  trellis.setLED(i);
	} 
	// if it was released, turn it off
	if (trellis.justReleased(i)) {
	  Serial.print("^"); Serial.println(i);
	  trellis.clrLED(i);
	}
      }
      // tell the trellis to set the LEDs we requested
      trellis.writeDisplay();
    }
  }

  if (MODE == LATCHING) {
    // If a button was just pressed or released...
    if (trellis.readSwitches()) {
      // go through every button
      for (uint8_t i=0; i<numKeys; i++) {
        // if it was pressed...
	if (trellis.justPressed(i)) {
	  Serial.print("v"); Serial.println(i);
	  // Alternate the LED
	  if (trellis.isLED(i))
	    trellis.clrLED(i);
	  else
	    trellis.setLED(i);
        } 
      }
      // tell the trellis to set the LEDs we requested
      trellis.writeDisplay();
    }
  }
}

Thanks
 
Status
Not open for further replies.
Back
Top