0
\$\begingroup\$

I'm working with NeoPixel led strip and a microcrontroller which run at 3.3V. As you can read in the NeoPixel documentation using a micro with 3.3V out on pin require the DATA signal to be shifted up from 3.3V to 5V to avoid unexpected behaviour. On the Adafruit page they suggest to use a 74AHCT125 converter IC.

Is it possible to achieve same result avoiding IC? (eg. with mosfet or similar).

NeoPixel data protocol is very strict about timing (800 KHz signal), so I think solution needs fast ON/OFF switching time.

\$\endgroup\$
2
  • \$\begingroup\$ What you need is a levelshifter. Google "levelshifter circuit" and press "Images" to see images of such circuits. Note that the most simple ones invert the signal. On Ebay you can also buy modules that do this for very little money. Do realize that you might get yourself into trouble or have issues if you do not use a "proper" levelshifter like the IC based ones. Especially with timing sensitive signals like Neopixels. They don't suggest that 74AHCT125 for no good reason. \$\endgroup\$ – Bimpelrekkie Jun 29 '17 at 15:10
  • \$\begingroup\$ @ Noisemaker, have you finished with this question now? Is there anything that you still need answering regards this question? \$\endgroup\$ – Andy aka Dec 9 '20 at 10:50
8
\$\begingroup\$

Here's quite a simple one and it is bi-directional too: -

enter image description here

When the data input from the 3.3 volt side is low, U1 turns on and connects the right hand data pin to the input data pin hence the output is also 0 volts. When the input pin is high, the transistor is turned off and the output on the right is pulled up to 5 volts.

Only thing to watch out for is speed of data - the rise time on the output 5 volt side is limited a little bit in reaching 5 volts from 3.3 volts. The first 3.3 volts is OK because the capacitance of the MOSFET couples the rising 3.3 volt data input signal to the output but, once the input side has settled at 3.3 volts, the remaining 1.7 volts are only attained via R3 charging up the internal parasitic capacitance of the BSS138 (about 20 pF including reverse transfer capacitance). RC time is therefore 200 ns which will be good for data rates up to 1 or 2 Mbps.

If you think you need faster then you can lower R3 maybe to 1 kohm. Then the only limiting factor is the specified rise and fall times of the MOSFET itself and these are maximums of 18 and 14 ns respectively but, watch out for the turn-off delay time - it is 36 ns compared to 5 ns for turn on-time. The effect of this will be to slightly alter the mark-space ratio of your data. It could be a problem but I suspect not at 2 Mbps if you lower R3 to 1 kohm.

\$\endgroup\$
4
  • \$\begingroup\$ That's what I was looking for. (Lots of these same solutions here, though.) Also addressed speed, which the OP needed addressed. + \$\endgroup\$ – jonk Jun 29 '17 at 15:55
  • \$\begingroup\$ One thing that bothers me is that the OP will probably need to go with \$1\:\textrm{k}\Omega\$ pull-ups to get the speed. And the I/O pins of MCUs are, to my mind, typically about \$100\:\Omega\$. Which means there will be an input divider operating, keeping it from getting close to ground, therefore keeping the output from getting close to ground. Depends on the input source impedance, though. Just annoying. \$\endgroup\$ – jonk Jun 29 '17 at 16:27
  • \$\begingroup\$ Will this invert data? \$\endgroup\$ – Noisemaker Jun 29 '17 at 18:10
  • \$\begingroup\$ No, it doesn't invert data. \$\endgroup\$ – Andy aka Jun 29 '17 at 19:30
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

This would be a simple FET driven circuit that will level shift your data line. You need two FET's to maintain the signal 'polarity'. The first FET "M2" will invert the signal and "M1" will invert again.

\$\endgroup\$
1
  • \$\begingroup\$ Can you address the speed of this circuit? The OP specifically mentioned very near 1 MHz rates and not merely level shifting. \$\endgroup\$ – jonk Jun 29 '17 at 15:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.