Do NOT use BSS138 for logic level shifting (too slow!)

Short/Summary: Don’t use BSS138 to logic level shift data signal to DIN of first WS2812B. Diode trick will likely/probable. Ideally, should use level shifter capable of handling 800khz+ frequencies, multiple Mhz even.

Long:
Yet another LED board project… My 1st attempt failed, working on 2nd… Does this BSS138 based logic level shifter schematic and layout look okay to you? Trying to boost data signal from QTPY ESP32 to first WS2812B RGB LED. Maybe shifter isn’t required for such a tiny project? Am trying to minimize failure risk. This is my 1st custom PCB design, my goal is to learn and have fun, so any feedback/suggestions are appreciated.

Currently using BSS138AKDW-TP MCC(Micro Commercial Components) | C779245 - LCSC Electronics. Came up with my schematic based on info mostly from Adafruit learning docs/discord, https://www.digikey.com/en/blog/logic-level-shifting-basics and the YouTube rabbit hole. Didn’t realize WLED forum existed until recently.

schematic



Can just about visualize ~3V3 data signal on my cheapo DSO138 scope, but am unable to reliably visualize boosted ~5V signal with enough clarity to inspire confidence that the level shifter fragment of the circuit is good enough for ‘neopixel’ frequencies. Not sure if scope and/or BSS138 and/or me are the issue. I did temporarily hack code to set pin constantly high, this helped verify ~3v is boosted to ~5V. However success at constant 0hz doesn’t mean the circuit works at neopixel frequencies. Mentioning this, because am seeing misc interweb info saying BSS138 are only good up to 2mhz(?). Currently using 10K pull-up, anyone think lower value e.g. 2.2K would be better and help with working well at the 800khz that WS2812B use?

My 1st batch of boards failed/partially-fail various reasons. Found and fixed several problems as I work on 2nd version, for example:

  • Used WorldSemi WS2812B-mini 3535 RGB, the LEDs fail in various spots. Would use SK2812 (seem to be more reliable?) but no stock for size I want. Might use jlcpcb’s global part sourcing option.
  • Larger traces,
  • Larger clearances for traces and copper fills, so less antenna GND copper fill in tiny nooks.
  • Removed VIAs under LEDs, my poor attempt at thermal management.
  • Made board larger so parts not so close to the edge. In addition to my design issues, am concerned LEDs are being damaged during jlcpcb SMT assembly, or panel cutting.
  • Increasingly leaning towards using 5050, feels like assembly will be easier and more reliable.
  • Currently drooling over Amzn’s top selling scope ($400!), trying to find something good enough that’s much cheaper. Suggestions appreciated!

Thanks for reading, articulating a problem can be cathartic if nothing else :slightly_smiling_face:

On the level shifter:

The basic data stream for WS281x series is less than 1Mhz, but with some fairly tight timing requirements for the Hi and low pulses - down in the 150ns range. That means the ~2Mhz speed of the BSS138 device might not deal well with all of the data waveform, especially the faster bits.

Any of the 74AHCTxxx devices will do a better job ('08,'32,125,245), they’re cheap, fast and reliable.
If the size of the package is too much, the 74lvc2t45 is a tiny package with 2 independent shifters.
Much faster than the MOSFET and still very cheap.

On the scope:

If you’re looking for a scope to properly visualize the actual data stream, you need to start at the 10Mhz devices at minimum. When dealing with pulse widths of 100-150ns you’re talking 10Mhz, and more bandwidth (that means more than 10Mhz) is always better.

1 Like

Thank you @divsys !

Am abandoning BSS138, would still use for projects with lower frequency I2C signals.

Looked into the “diode trick”, seems to be straight forward and mostly work, but not always.

So, going to try this shifter…

Would appreciate feedback on whether this is good/bad idea. Need to use parts stocked by lcsc.com. Cheers!

That should be fine, it’s just a single channel version of the 74LVC2T45 I recommended above. Only “downside” to these devices is that they need both 3.3V and 5V supplies vs the 74AHCTxxx which are 5V only.
Not a big issue, you just need to know.
BTW, LCSC lists the 74AHCT1G17 which would work as well and is a single 5V supply device…

2 Likes

hello could I ask you for help !? :blush: I tried to integrate a SN74HTC125N but I can’t get it to work. I am attaching a photo of my link. where am i wrong? a thousand thanks

You also need a connection for the ~OE input of each gate.
The ~OE (read as Not Output Enable) needs to be LOW to enable the output of the gate.

Here’s a wiring diagram I stole from @tonyno who pinned it to Learning on the Discord site:


You’ll note all the used ~OE lines are grounded.
In addition the unused inputs are tied together (and grounded) as well.
This is to prevent “floating inputs” that can cause all kinds of trouble, flickering, etc for your strips.

Note the 100nF bypass capacitor from pin 14 to Ground.
That’s good insurance to prevent power supply noise from creating “glitches” on the outputs and more flickering, etc.

Edit: found better drawing -to steal- thanks @tonyno
Corrected for unused ~OE lines

2 Likes

hi thanks for the help. :v::wink: I tried both schemes, both the one that closes the channels with the GRD and the one with the 5v I inserted the 100 capacitor in both cases. I noticed that the flicker was canceled with the oe scheme and GRD , but I had to put in a 300 ohm resistor. so I was able to extend the data cable about 60 meters without flickering. :laughing:




1 Like

60 meters of wire between Controller (with logic level shifter 5v) and the first pixel?

That’s awesome, where are you buying your superconducting wires from? :smiley:

1 Like

Credo che mi posso spingere ancora di qualche metro non saprei. Domani provo a vedere, aggiungendo altro cavo. Il primo led e accesso, nessun sfarfallio. Dovrei provare a saturare tutti i canali del CIP per verificare che non ci sia troppo calo di tensione. Compro tutto da AliExpress. Anche se ultimamente i prezzi sono aumentati.

Glad you got it working.

If you want a more reliable means of putting your LEDs a long way from the MCU (and separate strips a long ways apart), lookup the section in the KB: Long Data Lines

2 Likes

Credo di non superare i 40 metri per il mio progetto. Ma è MOLTO interessante questo sistema con Convertitore RS485 TTL. Grazie mille per il tuo prezioso aiuto. :laughing:

Would like to know if there is 8 ports version of 74AHCTxxx? Been googling but don’t know if it is correct one. Any comment would be appreciated.

For 8 i/o’s look at:

74AHCT245

or

TXS0108E

Thank you so much. I found 244 version instead 245. Would it be difference?

I think the 244 looks to be surface mount (at least any that I saw). You may have a hard time soldering that unless you are well seasoned at working with small chips.

I don’t know if you are in the US or not but the 245 is easy to find on Amazon.

Thanks again for your help and the Amazon link . I am from Canada, this is what I found and it seem like regular chip.

And the one you linked as well. I am going to order this one instead.

I also got a bunch of this TXS0108E too but I couldn’t get it to work when I bought them couple year back. But for some reason it started to work now on my bench test and I am not sure I should use this one or get the one you linked.

I’m not sure if the 244 will work. Might need input from someone that knows a bit more about those.

Maybe @divsys or @srg74 ?

SN74AHCT245N This one is ok

Is working too