Level-shifting options? Primer?

Status
Not open for further replies.

epicycloid

Well-known member
To date, mainly due to Teensy 3.1's 5V pin tolerance, I have been able to get away with not having to do any level-shifting. But I think those days are drawing to an end. When a Teensy++ 3.x arrives, it clearly won't be 5V tolerant any more. And I need the GPIO pins, so I'll lean towards a ++ version when it gets here.

Is there a primer or someplace that sums up the pros & cons of the various level-shifting solutions?

Which specific level shifting options have Teensy users found best suited?

Do people use different types of level shifters on dedicated outputs vs. dedicated inputs vs. bi-directional signals? E.g. if I know I'm only sending outputs to a motor driver, but also have some I2C bi-directional device, would it be best to optimize and use different level shifters on each?

My primary need will likely be for stepper drivers, in the 4,000 to 10,000 steps per second range, on multiple motors/drivers simultaneously. I've read about the delays and issues with some of the level shifters used with I2C, but I'm not very clear on when timing with those becomes an issue.

Thanks,

--Jon
 
10,000/s steps is a magnitude less than i2c.

sometimes i use bs108 n-fets for outputs. (ok, it's a time ago.. i used them with 5v outputs..but if i remember correctly they should work with 3.3V too?)
 
Last edited:
Maybe Paul's not yet released peripheral expansion add-on board will be applicable.

The upcoming board is more "peripheral add-on" than "expansion". It will have a pair of 5V buffers for driving APA102 LEDs. But otherwise, it's *not* about I/O expansion. It'll be the same 0.7 inch width as Teensy, and just a little longer to allow mounting holes and a few connections.

The main thing it's intended to add is commonly needed set of peripherals, which don't involve many external connections.

Perhaps an I/O expansion board should be made? My preference is to allow Onehorse and others to make most peripheral boards. The fewer I make, the more I can focus on solving tough software challenges and libraries, and adding features to the platform itself (like support for debug).
 
Regarding level shifting, I have 2 main pieces of advice:

#1 - There is no universal solution. Adafruit, Sparkfun, Seeed and others have promoted various boards, especially the mosfet+resistors, as general purpose solutions you can just keep in your spare parts draw and apply whenever you have a signal to convert. It's a seductive idea, that you don't have to worry about details, that you can just use an all-purpose bidirectional converter whenever you need to interface different signal levels. It's become almost a myth or urban legend, which certainly sells a lot of boards for those companies. Sadly, it's terrible advice. Don't believe this myth. There is no universal solution!

#2 - Unidirectional buffers almost always work better than bidirectional circuits, of course if your signal is always in the same direction. Especially for higher speed signals, like SPI and addressable LEDs, always use unidirectional buffers.
 
Thanks for the advice Paul. For unidirectional do you have a preferred chip(s)? Or do they tend to be more application specific?

For I/O expansion or added pins, which has been my main need, I really like the idea of HWGuy's Breakout Board R2. It looks very simple, and gives me the bottom pins via a less dicey soldering approach, in the same width. I think for anyone who needs the additional bottom pins, it looks like the easiest option out there at the moment, until the T++ 3.x anyway. I ordered a bunch, plus the color-coordinated purple T3.1's. We'll see when they get here.
 
The three I accidentally ordered in May were Purple - the ship email said this: "3x Teensy 3.1 - Made in the USA, Purple OSH Park Edition". Time for me to order boards from OSH.
 
Dang, and I just soldered the regular headers on my last 4 purple ones yesterday... if I had only known I could have waited and saved those to go with HWGuy's boards.

Michael -- Just curious... how long did it take to get your boards?
 
Last edited:
For unidirectional do you have a preferred chip(s)? Or do they tend to be more application specific?

It's always wise to consider the needs of your specific application!

Since Teensy 3.1 is 5V tolerant, usually the main need is converting its 3.3V output to full 5V signals. Even that isn't very commonly needed, since almost everything these days runs on 3.3V (or less, with 3.3V tolerant inputs) or has "TTL compatible" inputs if 5V. But some products, especially addressable LEDs, need full 5V signals. The "74HCT" chips work very well.

Some applications are sensitive to propagation delay. Especially older logic chips meant to 5V can add dozens of nanoseconds delay when run at the low end of their voltage range. Recently problems were reported with a SD card breakout board, which had (slow) buffer chips to allow 5V SPI signals from regular Arduino boards. It was probably marginal even with 8 Mbit/sec SPI from regular Arduino (quite a lot of the products in this "maker market" are very poorly designed), and couldn't work at all with Teensy 3.1's 24 Mbit/sec SPI. That's particularly sad, because all SD cards are rated for at least 25 Mbit/sec speed, and many support 50 Mbit/sec.

Signal rise and fall times sometimes matter. Faster is not always better. For driving long wires, fast edges create a lot of unnecessary noise. If the wires are "long", where "long" means more than about 1/10th the bandwidth of the rise/fall times, transmission line effects and signal reflections can become a problem. Some types of signals, like PWM and WS2811 LED protocol are corrupted by lack of symmetry in rise vs fall times.

I'm always reluctant to recommend specific parts without talking about specific applications. I know Sparkfun, Adafruit and others do this and it's very comforting for people to know "good" part numbers. It also increases their sales. Sometimes it works out well too. Somtimes. But there are so many applications with widely varying needs, so recommending specific parts for a broad range of unspecified applications is rarely a good idea.
 
Dang, and I just soldered the regular headers on my last 4 purple ones yesterday... if I had only known I could have waited and saved those to go with HWGuy's boards.

Michael -- Just curious... how long did it take to get your boards?

I ordered the boards on August 18th. They were mailed out (from Oregon) on August 26th. I got delivery in Massachusetts on September 1st. OSH park groups the orders until a full panel is made and then it is sent out to be created. I imagine it depends on how many orders they have before it is sent out.
 
For context I am a ME, who worked my career in the computer industry, and have dabbled with electronics since boyhood, but I am in no way an EE. In other words I can understand logic, design and connect things up, and write software, but I'm clueless with regard to noise issues, RF, propagation issues, transmission theory, and most nitty-gritty component selection, etc. I have an older Tek 2211 'scope, but I'm far from confident using it for problem solving.

My application is in two versions right now, a "proof of concept" and a "prototype". Proof of concept is on my bench, prototype is mounted on a lathe in the shop*.

Proof of concept consists of:
- plexiglas stand with Teensy 3.1, 2 encoders, 4 buttons & an ILI9341 display, 0.1µF/104 debounce caps on encoders and pushbuttons
- ~12" jumpers to a breadboard with...
- 24V in, DC-DC converter to 5V, 2 Pololu stepper drivers
- 2 small NEMA 17 stepper motors

Prototype consists of:
- enclosure with Teensy 3.1, 2 encoders, 4 buttons & an ILI9341 display, 0.1µF/104 debounce caps on encoders and pushbuttons
- ~36" of wire (e.g. DB-15 with 15 wires +/-) going to the components below the bench top with...
- a DIN rail with 24VDC / 120W PSU, a DIN enclosure with 5V DC-DC converter (power up to Teensy etc.), larger stepper drivers
- 2 larger NEMA 23 stepper motors @ 2A & 2.8A
- 3x optical endstops (passing their signals back up to the Teensy via 36" wires)

The ILI9341, encoders and buttons are for a menu based UI. I am still working on the UI and motion control in software on the proof of concept on my bench. Once I am happy with all that, I'll move in earnest to the prototype electronics. I am working on the prototype in parallel, but mostly the mechanical so far (making mechanical parts, brackets, dealing with belts/pulleys, etc.), and collecting the various components.

My main concern is that the larger stepper drivers really want to see a full 5V for step, direction & enable signals (and for some reason I don't understand, also reverse the step/direction signal logic connections, e.g. common positive), and combined with the 36" of wire carrying the logic signals down to them, I suspect I'm in for a rude surprise or two.

I need to select and test level shifter(s), and probably some other things I don't know about yet, to move from the proof of concept to the prototype. Any advice on the the best level shifter and any other pitfalls ahead would be most appreciated.

--Jon



* In an effort to "virtualize" some traditional capabilities for ornamental turning.
 
I ordered the boards on August 18th. They were mailed out (from Oregon) on August 26th. I got delivery in Massachusetts on September 1st. OSH park groups the orders until a full panel is made and then it is sent out to be created. I imagine it depends on how many orders they have before it is sent out.

Thanks Michael. I have only ordered Teensy's from them, no boards, and I know they wait until a panel is full, but I just didn't know if that is "days" or "weeks".
 
Most the time when I order boards to be fabricated, it is shipped off to fabrication within 1 maybe 2 days.

The last one I ordered was on the Aug 28th and it was shipped off the same day. It is expected back today...
 
Thanks, the whole process is a learning experience. The OSH Park website (and emails) tell me my boards, including some others I ordered, have been assigned to the Sept. 9th panel.

What would be cool is if Laen added a "% full" indicator on the website, so you could kinda gauge how close a panel might actually be to being ordered.

P.S. For newbies like me, it was cool to see Laen interviewed a while ago, explaining the whole panel filling process... James "Laen" Neal from OSH Park. (Too long, but more fun than watching normal TV.)
 
My guess is your board will ship off today or tomorrow... FYI my latest prototype board shipped from them today:
e04e95bd2fb59c94fd9d6358dd64ea89.png

It is just an experiment to see if I can use a Teensy 3.1 instead of an Arbotix Pro in some of my newer robots. I have the board setup to same size as the other board, and it is setup to take either an Adafruit or a sparkfun IMU, plus have circuit setup to completely shut off the power to the bioloid servos...

Sorry for the hijack...
 
Thank you. Good reading. I don't expect my timing to be as demanding as the Neopixels appear to be, but it is educational to read what you and the commenters experienced.

I ended up buying some 74AHCT125's and 74LVC245's to experiment with (based on Paul's comments and the chips Adafruit selected to sell). But to the non-EE the options seem mind-boggling to sort through.

I also bought a couple of the Pololu MOSFET based shifters too, just to see how they work and learn. Acknowledging Paul's advice above, that they are not a universal solution. Maybe those will provide inspiration to hone my 'scope skills.
 
Since part of this thread was a discussion about the OSH Park boards and process, just thought I'd link to my post on the original thread for the 48 pin Teensy. I got my boards today, and they are great. HWGuy's design is great. And the boards got here faster than I expected. Good learning experience.

I just have a bunch of soldering to do now as I move on from the "proof of concept" to real prototypes.
 
Status
Not open for further replies.
Back
Top