Level shifting

SteveSFX

Well-known member
Hello all

I want to jump over to Teensy 4.1's, as 3.2's appear to be impossible to find at the moment.

So, I want to incorporate level shifting in my board design and I see that Sparkfun and other people use a small 3 pin device. Any idea what that part is? BS170?

I understand that I can use something like a 74HCTxx. I basically want to make all the pins 5v tolerant.

But, I assume the analogue pins still have to stay 3.3v input? Would level shifting these analogue pins make them read 0-5v?

Also, if I make the 3.3v pins 5v tolerant with a level shifter, will it still operate correctly at 3.3v high?

I could voltage divide, but I would like to do the job properly

Thanks
 
Well, the answers to your questions are pretty much the standard Engineering response to any question: "It depends".

So, I want to incorporate level shifting in my board design and I see that Sparkfun and other people use a small 3 pin device. Any idea what that part is? BS170?

I understand that I can use something like a 74HCTxx. I basically want to make all the pins 5v tolerant.

The Sparkfun level shifters use BSS138 mosfets, the schematics are readily available: http://cdn.sparkfun.com/datasheets/BreakoutBoards/Logic_Level_Bidirectional.pdf
Resistive and mosfet shifters are slower than a 74HCT125, but cheaper. Do you intend to read high frequency signals?
There are several threads on level shifting all over the forum, e.g. https://forum.pjrc.com/threads/5542...for-TTL-LCD-serial-signals?highlight=74HCT125

But, I assume the analogue pins still have to stay 3.3v input? Would level shifting these analogue pins make them read 0-5v?

You can't use digital level shifting on an analog input as it'll saturate the signal to the HIGH logic voltage level. Again, the solution depends on your needs: Depending on what type of signal you intend to sample, a simple resistive voltage divider might suffice. A more robust solution would involve opamps, which have great input impedance and also serve as a voltage buffer.

Also, if I make the 3.3v pins 5v tolerant with a level shifter, will it still operate correctly at 3.3v high?

A logic HIGH at 3.3V logic is usually around 2.4V, which should be plenty to drive any 5V input pin HIGH with no problems. See here too: https://learn.sparkfun.com/tutorials/logic-levels/33-v-cmos-logic-levels
 
Am I correct in thinking that if I use a 74HCT125 to level shift, it is only one direction? (3.3v>5v) ?
 
Yes, confirmed, using 74HCT125 powered with 5V, the level shifting is unidirectional from 3.3V to 5V.

And as a general rule, for unidirectional signals, using a unidirectional buffer is almost always better that using a bidirectional level shifter. Also know that the BSS138-based (or similar mosfet & two resistor) level shifters, like the Sparkfun product mentioned in msg #2, are far too slow for TriantaduoWS2811.

Another general rule is each of these 74HC chips should have a 0.1uF ceramic capacitor connected its power and GND pins, located as close as reasonably possible with minimized wire length. X5R or X7R type ceramic is best. If you build that TriantaduoWS2811 shifter circuit using 1 74HCT125 to level shift and 4 74HC595, plan on using 5 capacitors, one for each chip. The 74HC chips need power in short but large pulses. Ceramic capacitors located close by provide those pulses of current from the energy stored nearby. Without the capacitors, those brief but large pulses of current have to flow through lengthy wires, which can cause all sorts of noise and interference problems. Using the capacitors prevents those issues.
 
Thank you Paul
Still in my learning years with all this (not that I have many years left lol). As a rule, I always put a 100nf directly across the supply of my IC pins in any design as close as possible.
 
OK. Now apologies for the awful MS Paint diagram... all I had to hand

I was trying to design some kind of multiple option for inputs and/or outputs on a Teensy 4.1 pin. I have some nice small 3 position rotary pcb switches that I could use up.

Does this circuit even seem logical? I know the Mocd208 opto-isolator part works, as I have used this before.

Position 1: Shifted 3.3v to 5v output
Position 2: Analogue in via a voltage divider
Position 3: Optically isolated digital input

If this was practical, would there be any side effect of combining those 3 input/output terminals (into one pin)? Would the 12k/22k voltage divider upset the level shifter? (probably)

Input selector.png
 
The 74HCT125 enables are active low, you would tie that to ground instead of +5 volts.

Side effects of connecting switch 1,2,3 together puts the 10K and 22k resistors in parallel. You could just not use the 10K resistor and the 22k would provide the pulldown. If you were receiving an analog signal, the input to the 74HCT125 would not be just high or low. When the input is in the range of 0.8 to 2 volts, the 74hct125 could oscillate and draw extra current.

Personally I would ask why you want to complicate things. Why not just decide before hand what the job of each Teensy pin will be and provide the correct circuit.
 
Back
Top