Teensy 3.1 and 5V TTL Serial?

Status
Not open for further replies.

dc_in_sf

Member
I have a Sparkfun serial LCD display that I bought to use with a Teensy 2.0 that ended up in getting built into a different project and now I have a Teensy 3.1 on the way and am wondering if I need a level shifter to drive it?

I realize that the Teensy 3.1 has 5V tolerant inputs, but not sure how to tell if the Sparkfun backpack will work with what I presume would be 3.3V signals coming out of the Teensy 3.1. The backpack appears to use a PIC16F88 according to the sparkfun schematic and the data sheet for that is here AFAICT but it is a bit overwhelming for a newbie like me.

I can just give it a go when the 3.1 shows up, but was wondering if I should have something like one of these bi-directional translators from Sparkfun in my box of things.

NB. My soldering skills are in the truly awful range right now, so breakouts are the way to go for me until I get better.
 
Wow - that unit is $30 - it does looks like it wants 5v serial signals. If you search on the part: TXB0104 - it seems to work in some cases.

If you are starting from scratch - you could get this for $8 and a Teensy 3.1 for under $30 and have a much better display that would be compatible - more fully featured and in color.
https://www.pjrc.com/store/display_ili9341.html

You could chose a font a format to emulate the 4 line 20 characters - but with res of 320x240 you could do much more, and it is a rocket fast solution that works perfectly with the T_3.1.
 
Yeah not the cheapest unit, it was an impulse buy, and in retrospect if I wanted an old school LCD display I should have just got a bare bones unit rather than one with a serial interface.

But its in the parts box now so have to figure out how to use it :)
 
I believe I have one of those (yes when I clicked the link It say I bought one July 16th 2013 what a hoot) and I believe it worked with the teensy, however I got a number of the pjrc sourced graphics displays and never went back for 'experimenting'. However I also got the parallel input 2 line version (way back when) and the serial is a much appreciated upgrade.

Cheers Kb
 
Most of those PIC chips work TTL level signals (more than 2.0 volts is high), so odds are very good it will simply work. I'd give it a try the simplest, easiest way before adding the complexity of extra buffer chips.

Just be careful connecting the power. Pretty much any electronic part can be ruined by improper power connection. But feeding a 3V signal to a 5V input will at worst just not work. Odds of permanent damage are virtually zero.
 
I just tested with a T3.0 worked just fine. Note to pay attention to the JST wire connectors, I got mine with a 3 wire JST and the colors (black red and yellow) did not correspond to what I expected. while the black is ground (thnakfully) my yellow is +5v and the Red is serial in to the display. Once I sorted that out works like a champ.

Kb
 
sample code

I modified one of the examples I found to try a couple of the features. One thing I noted is the display hangs if you issue a backlight command and don't wait slightly before sending more data. I found a wait of 4 ms was enough I use 5 here. I would have to remove power from the display and restore it before it would work again.

For this example I used HW serial2 on a Teensy 3.0

Code:
// SparkFun Serial LCD example 2
// Format and display fake RPM and temperature data

// This sketch is for Arduino versions 1.0 and later
// If you're using an Arduino version older than 1.0, use
// the other example code available on the tutorial page.

void setup()
{ 
  Serial.begin(9600);
  Serial2.begin(9600); // set up serial port for 9600 baud
  delay(2000); // wait for display to boot up

  Serial2.write(124); // backlight control
  Serial2.write(145); // 128 off 140 150 157 full
  delay(5); // display seems to hang after backlight command 
            // if there is no delay here
  Serial2.write(254); // clear display
  Serial2.write(0x01);
  Serial2.write(254); // cursor to beginning of first line
  Serial2.write(128);

  Serial2.write("RPM:                "); // clear display + legends
  Serial2.write("TEMP:               ");
  delay(1000);
  Serial2.write(254); // display off
  Serial2.write(0x08); // 
  delay (2000);
  Serial2.write(254); // display on
  Serial2.write(0x0C); // 
  delay(200);

  
  Serial.print("testing");
} 

int temp, rpm;
char tempstring[10], rpmstring[10]; // create string arrays

void loop() 
{ 
  temp = random(1000); // make some fake data
  rpm = random(10000);

  sprintf(tempstring,"%4d",rpm); // create strings from the numbers
  sprintf(rpmstring,"%4d",temp); // right-justify to 4 spaces

  Serial2.write(254); // cursor to 7th position on first line
  Serial2.write(134);
 
  Serial2.write(rpmstring); // write out the RPM value

  Serial2.write(254); // cursor to 7th position on second line
  Serial2.write(198);

  Serial2.write(tempstring); // write out the TEMP value
  
  delay(1000); // short delay
}

Cheers Kb
 
I have two of those which I have used both with a Teensy LC and a 3.1 with no extra circuitry in between and they worked fine.

I did have to be a little bit careful with a delay after certain comands like fretless_kb said, but for a very "newb" programmer such as myself it's very simple to make it work. Also doesn't tie up many pins if that is an issue.
 
Thanks all for the info. Looking forward to playing with the display when the 3.1 arrives - though I just ordered a couple of those 320x240 displays pjrc ss well... Slowly moving off Sparkfun as my principal supplier :)
 
Status
Not open for further replies.
Back
Top