Teensy 3.1 how do I output 5v?

Status
Not open for further replies.

a104

Member
Hello all,

I want to control a led strip and It needs the clock and Data output to be 5V.

I input 5V to teensy but I only get 3.3v on the pin 11 and 13.

Is there a way to make sure its 5V in the output?
 
To expand robsoles answer, the Teensy 3.1 is 3.3V logic for a range of reasons http://en.wikipedia.org/wiki/CPU_core_voltage so there is no way to magically make it produce 5 volts. Using a level converter is the default option, though a range of ICs or even discrete components will do the job though allowing the high enough clock rate will require care.

A quick and dirty solution for testing is to see if you can drop the LED supply voltage to 4.5 volts (check the data sheet) which pushes the 3.3V Teensy output just clear of the default 0.7 Vin for a solid HIGH read.
 
Do not use the mosfet+resistor level shifter circuits. They are far too slow. Ignore the terrible advice on Sparkfun and Adafruit's website which claims they are useful for all sorts of uses, including SPI. They're NOT.

You should use a 74HCT245 chip, like the one on the OctoWS2811 adaptor. On the product page, scroll to the end, for an update and links to info about using it with APA102.

Of course, you can build your own from just the chip, instead of buying the $10 adaptor. Just make sure you use a proper 74HCT type chip. Avoid those slow mosfet circuits. They are not good for this, despite the common but wrong advice you'll see at Sparkfun and many other sites.
 
Also, avoid the bidirectional chips like TXB0108. They work good for short wires going to one other chip, but they're poor for driving long lines, especially a very long LED strip with the clock going to them all.

Many people immediately recommend this chip and that slow mosfet circuit for all level shifting. Don't believe it. There is no bidirectional level shifter good for the use. You need a proper unidirectional buffer chip.
 
I'm a fan of the LFS0108 bidirectional translator but I've only used it to drive low current signals over short (~few cm) distances, mostly PWM, UART, and SPI.

This chip has very low on resistance which is why I use it to replace the mosfet + resistor network I originally started with. It also claims to handle push-pull and open-drain applications at speeds up to 100 MHz. Although I have only directly measured its performance at 3 MHz, it kept the clock signal edges nice and sharp going from 3V3 to 1V8. Presumably it would do the same at other rated voltages. But I did not do this test over long wires.

What is it about longer distances that makes this kind of solution inappropriate? Is it the wire resistance and capacitance that degrades the signal?
 
When used increase from 3 to 5V, the speed of the rising 5V edge depends on the pullup resistor. That's why they recommend low values, like 250 ohm. Don't believe for one moment that chip is somehow acting like a real buffer. It's just a passive switch that depends on a pullup resistor to increase the signal voltage.

Texas Instruments chose their words very carefully, to maximize the odds any casually reading their datasheet would see "push pull" and believe the chip somehow provides a true push-pull output. It doesn't! Together with the lack of detailed explanation of the circuit inside the chip, it's very deceptive marketing on TI's part.

Addressable LED signal projects should NOT use this chip. A real buffer chip, like a 74HCT245 or the 74LC1T125 buffer on Teensy-LC are the proper way.
 
Last edited:
Thanks Paul! Time to go shopping ... actually I might give a shot with the OctoWS2811 adaptor.
 
Last edited:
Addressable LED signal projects should NOT use this chip.

Agreed.

But cannot this chip be used for translating logic signals for I2C, PWM, UART and SPI? If not, I'd like to better understand why not so I can discontinue selling it.
 
I am a software guy, so this is based on how I understand the protocols, etc. It may or may not have any basis in reality. :confused:

For i2c, you need something that is bi-directional, but generally your wire length is pretty short. I2c is a slow protocol, so you do not needing fast transitions, and most of the level converters will work at base speed. If you go up to the faster speeds, then more attention needs to be paid to the details.

For WS2811/WS2812's (i.e. Adafruit neopixels), the protocol is all one directional, and there is no clock pulse, so every bit must be delivered to a exact timing window. This is one of the classic articles looking into level conversions with WS2812's: http://happyinmotion.com/?p=1247. The length is the entire length of the LED string, so you start seeing more issues due to wire length, etc. In WS2812's the data flows in a single direction, so you can use the 74HCT245's (which are fast, but single direction).

For small numbers of neopixels (32 or so), I've used the DSS circuits TXS-0102 (http://dsscircuits.com/sale/product/dssc0105) and the Pololu logic level converter (https://www.pololu.com/product/2595). Pololu suggest I add 10k pullups on both side (http://forum.pololu.com/viewtopic.php?f=3&t=8858) if needed. For the small set of neopixels I use, both with the pull-ups and without seem to work fine. Note, this was just looking at the pattern, it did not involve detailed measurements.

Of course with the LC, if I'm only using one stream of LEDs, the logic conversion in the LC works fine.

The Adafruit neopixel guidelines (https://learn.adafruit.com/adafruit-neopixel-uberguide) say to have a 300-500 Ohm resistor in front of the first neopixel LED, which IIRC, is to prevent ringing in long neopixel strings, and to have a large capacitor between power & ground to buffer power spikes.

If you are driving WS2812's at a distance, I saw this article about using RS-422/RS-485 drivers to send the data over long distances: http://www.teknynja.com/2014/02/driving-ws2812neopixels-rgb-leds-over.html

Whether you can use 74HCT245's for SPI probably depends on whether the communication is duplex or simplex. If it is duplex, you will probably be limited by the level converter speed.
 
Last edited:
Thanks Michael, I was wondering how one manages the bidirectional nature of some of the communication protocols with the 74HCT245.
 
Also, avoid the bidirectional chips like TXB0108. They work good for short wires going to one other chip, but they're poor for driving long lines, especially a very long LED strip with the clock going to them all.

Many people immediately recommend this chip and that slow mosfet circuit for all level shifting. Don't believe it. There is no bidirectional level shifter good for the use. You need a proper unidirectional buffer chip.
Nothing can be more true. TI and resellers like Sparkfun act like the TXB/TXS chips are the holy grail of bidirectional level shifting, but in reality they offer poor performance and often can't detect if the output is driven as an input and vice versa. I've once spent the better part of two weeks trying to get TXB0108 ic's functioning properly in my (by all means quite basic) application, but even with help from TI themselves it could not be done reliably.

I eventually solved the issue by using a high-to-low level shifter connected directly to the Teensy digital pins (so I could use interrupts) and placing a MOSFET driver connected to a MCP23008 SPI IO expander parallel over that. The outside connections could then be used as high-voltage input or output.
 
I've been working with UARTs in bi-directional mode - one serial like, half-duplex, with a block-oriented protocol (e.g., ISO7816) to coordinate turn-around of the one wire. All the SIM cards and SmartCard (credit cards with a chip) use this. The hardware UARTs have a special configuration mode for half duplex. And for that ISO standard, the character format is 9E1, meaning start bit, 8 data bits, 1 parity bit and 1.5 or 2 stop bits. The receiving side optionally asserts a 0 during the sender's stop bit to tell the sender there's been a parity error. That's why the special UART mode. I suppose many implementations don't use that parity since the block protocol has a CRC.

The sender and receiver negotiate per a standard on whether to use 1.8, 3.3 or 5V logic levels. It's curious.

All this to save a wire!
 
I am still a bit confused by this discussion.

I agree that for one-way signal transport over long lines or with UART, for example, unidirectional buffers are the way to go. I use the NLU1GT126 for Tx buffering. I have also used the LFS0108 and the Sparkfun-like FET/resistor network over short distances and they all work fine.

For bi-directional signal transport though, how can one avoid using a bidirectional translator. or rather, when using a proper buffer, how is the directionality specified? This is the confusing part to me.

According to TI's application note they claim the TXS series is good for open drain applications like I2C while the TXB is good for fast push pull applications like SPI. They claim the LFS can be used for either. For relatively short wire connections such as from a sensor chip to the GPIO of a Teensy, aren't these solutions adequate?
 
Last edited:
According to TI's application note they claim the TXS series is good for open drain applications like I2C while he TXB is good for fast push pull applications like SPI. They claim the LFS can be used for either. For relatively short wire connections such as from a sensor chip to the GPIO of a Teensy, aren't these solutions adequate?
I haven't tried the LFS, but my experience with the TXB/TXS devices is shaky at best. I used it for a Teensy to Arduino adapter board, but could never get it to function reliably. It's like in some cases charge is left on the IO pins, confusing the level shifter.

The 5V tolerant pins of the MK20DX256 eventually removed the need for level shifters on this board.

Traditional bidirectional level shifters use a DIR pin to set the direction. Requires another IO pin of your MCU though.
 
This sure is getting lots of attention :) Glad to get this much support from you all! Thanks guys.
 
It's like in some cases charge is left on the IO pins, confusing the level shifter.

I'm sure you know but for these switch-type or buffer-type translators, a pullup resistor is often needed to make sure the the signals being translated have a HIGH at the proper voltage, especially for bi-directional applications. You can get away without one (I do) for PWM and other GPIO translation if the signal is unidirectional and all you want it to translate from HIGH to LOW or LOW to HIGH. If you want multiple voltages out, then pullup it is!

Without a pullup in those cases that require one you could get an effect like you describe: a confused level shifter.
 
I'm sure you know but for these switch-type or buffer-type translators, a pullup resistor is often needed to make sure the the signals being translated have a HIGH at the proper voltage, especially for bi-directional applications. You can get away without one (I do) for PWM and other GPIO translation if the signal is unidirectional and all you want it to translate from HIGH to LOW or LOW to HIGH. If you want multiple voltages out, then pullup it is!

Without a pullup in those cases that require one you could get an effect like you describe: a confused level shifter.
That is completely correct. I used the TI recommended value for pull-up resistors on the high side, but this caused the high side output to sometimes float between Vol and Voh when the low side input was pulled low. Sometimes it worked, sometimes it didn't. Tried different IC's, different resistors, even a different PCB (breakout board), problems remained. I ended up putting the project on a indefinite hiatus, but maybe I'll finish it some rainy Sunday afternoon. :)
 
Status
Not open for further replies.
Back
Top