0

Controlling NeoPixel from Teensy
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Controlling NeoPixel from Teensy

by atrayan on Sun Dec 22, 2013 3:42 am

Is a logic level converter necessary to control NeoPixels from a Teensy 3.1? If so, which one would you recommend?

I'm using the NeoPixel NeoMatrix - is there a limit to the number of these I should daisy chain?

Many Thanks,
Lloyd

atrayan
 
Posts: 5
Joined: Tue Nov 26, 2013 4:15 pm

Re: Controlling NeoPixel from Teensy

by adafruit_support_rick on Sun Dec 22, 2013 11:14 am

A logic level converter is not strictly necessary, but it can make things a little more stable. I'd try without it first. You would only need to add the level converter if your pixels flicker or look unstable.

So long as the teensy has enough memory, you can daisy-chain as many as you want.

adafruit_support_rick
 
Posts: 34838
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Controlling NeoPixel from Teensy

by michaelmeissner on Sun Dec 22, 2013 3:14 pm

FWIW, I've powered 2 neopixel rings from my Teensy 3.0 that I power via the USB port, and I connect the VIN wire to the neopixels power pin to give the pixels the 5v they prefer.

michaelmeissner
 
Posts: 1311
Joined: Wed Aug 29, 2012 12:40 am

Re: Controlling NeoPixel from Teensy

by paulstoffregen on Mon Dec 23, 2013 12:15 pm

Usually NeoPixels work ok with the 3.3V signal, but a 5V signal is more reliable, especially if you have more than a few inches of wire or a large number of NeoPixels. With a large number, the varying power consumption causes small voltage changes on the ground wire, which can lead to signal issues.

A 74HCT245 chip (or any "74HCT" logic chip) works great. The HCT ones are meant to be powered by 5V, but they're able to properly receive 3.3V or even 2.5V signals at their inputs and of course translate it up to 5V at the output. I couldn't find a 74HCT245 in Adafruit's store (hint... if anyone from Adafruit support is reading this). You can get them at Digikey and other places.

Adafruit sells a 74LVX245 chip, but that one is meant to convert the other way. It's supposed to be powered by 3.3V (or less) and it's able to receive a 5V signal at its input. The LVX is perfect if you have a regular 5V Arduino and you need to send a signal to something that might be damaged by 5V.

Adafruit also sells a bidirectional TXB0108 converter, which is perfect for situations where you have relatively short wires and the signals need to change directions. The 8 bit bus to some LCDs is just one example (though most libraries never read anything back from displays). For NeoPixel, it might work if the wire is short. But I do know of at least one person who confirmed the TXB0108 does not work at all if the wire between the converter and the NeoPixel strip is too long.

If you do convert the signal up to 5V, which often isn't necessary, but it certainly is the best way, use a 74HCT245 or similar chip.

paulstoffregen
 
Posts: 431
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: Controlling NeoPixel from Teensy

by paulstoffregen on Mon Dec 23, 2013 6:35 pm

adafruit_support_rick wrote:So long as the teensy has enough memory, you can daisy-chain as many as you want.


Rick, did you know Teensy 3.1 has 64K of RAM? That's theoretically enough for 21000 NeoPixels!

paulstoffregen
 
Posts: 431
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: Controlling NeoPixel from Teensy

by michaelmeissner on Mon Dec 23, 2013 10:46 pm

Though if you are going to use a Teensy and a lot of lights, you really want to use the OctoWS2811 library that was created by the Teensy's creator to do 8 strips of Neopixel lights all at the same time. http://www.pjrc.com/teensy/td_libs_OctoWS2811.html

Note however, by the time you get to the hundreds of lights, you have to start planning how to power the lights effectively.

michaelmeissner
 
Posts: 1311
Joined: Wed Aug 29, 2012 12:40 am

Re: Controlling NeoPixel from Teensy

by adafruit_support_rick on Tue Dec 24, 2013 12:07 am

paulstoffregen wrote:Rick, did you know Teensy 3.1 has 64K of RAM? That's theoretically enough for 21000 NeoPixels!

What goes around comes around. I remember back to when when 64K of RAM seemed nearly infinite. And here we are again... :wink:

adafruit_support_rick
 
Posts: 34838
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Controlling NeoPixel from Teensy

by paulstoffregen on Tue Dec 24, 2013 12:14 am

For an idea of what 20000 NeoPixels might look like, as far as I know the Disorient Pyramid at Burning Man is the largest project yet, using about 16000 on 30/meter strips.

Image

http://www.nycresistor.com/2013/09/05/d ... t-pyramid/

paulstoffregen
 
Posts: 431
Joined: Sun Oct 11, 2009 11:23 am
Location: Portland, Oregon, USA

Re: Controlling NeoPixel from Teensy

by happyinmotion on Tue Dec 24, 2013 11:06 pm

Ok, another question about reliability of NeoPixels, Teensys, and level shifters.

I'm trying to run 180 NeoPixel LEDs off a Teensy 3.0, using the Adafruit_Neopixel library, as part of a costume, hence it's powered by a lithium battery to be portable and there's a one metre cable between the driver box and the strips. Separate UBECs for the strips and the electronics, of course, make sure the Teensy gets nice clean power.

I'm having a devil of a job making it reliable. Sometimes the strips work just fine and run the animations that I'm expecting, mostly they stall, sometimes the don't light at all. All this is at 400 kHz, 800 kHz is worse. Running the same strips from a 5 V Arduino is very reliable, suggesting that the strips themselves are fine.

Without a level shifter, the reliability was terrible. Touching the cable made the strips stop updating. Putting the cable near the UBECs made the strips stop updating (noise, I presume). So a level shifter is clearly needed. I've tried several level converters to go from the 3.3 V of the Teensy to the 5 V that the NeoPixels like. The best I've found so far, in terms of getting a reliable output, is the PCA9306 (https://www.sparkfun.com/products/retired/10403). However, the set-up I have is still far from bomb-proof. Now here's something odd. With no LEDs connected to the output of the level shifter, I get the following output on the data line:

Data 5V side no LEDs.png
Data output from level shifter with no LEDs attached
Data 5V side no LEDs.png (22.04 KiB) Viewed 3737 times


Looks pretty good, 5 V high pulses, timing fits the protocol, leading edges slightly rounded but nothing more than you'd expect.

However, attaching the LEDs to the output of the level shifter gives:

Data 5V side 180 LEDs.png
Data output from level shifter with 180 LEDs attached
Data 5V side 180 LEDs.png (21.17 KiB) Viewed 3737 times


And there's something not too good. The pulse height is 3.0 Volts. So no wonder the strips are not happy. The Voltage feeding the LED side of the shifter is a solid 5.0 V.

Here's where I start scratching my head. The level shifter is clearly wired up right, or it wouldn't be producing good pulses when no LEDs are attached. I mean, it's a level shifter, right? Connect ground, V1, V2, data in, data out. Done that, checked that, it works. So I don't think there's a problem there. However, there's clearly a problem when the level shifter is attached to the NeoPixel LED strips. I don't know what that problem is.

Anyone seen anything like this before? (Grasping at straws here, the PCA9306 is bi-directional, so could it be trying to convert reflected data from the 5 V LED side to the 3.3 V Teensy side? Like I said, straws.) Anything I might have overlooked? Any ideas about how to fix this?

happyinmotion
 
Posts: 42
Joined: Tue Nov 01, 2011 6:15 pm

Re: Controlling NeoPixel from Teensy

by adafruit_support_mike on Thu Dec 26, 2013 12:41 am

The PCA9306 is made for I2C buses. I2C devices can't generate HIGH output by themselves.. they need a pull-up resistor.

An I2C bus is a distributed, active-low OR gate. All logic gates have two parts: a pull-up network (for I2C, the pull-up resistor) and a pull-down network (everything else). The basic rule is that only one of the two networks is in control at any time.

Devices that can deliver both HIGH and LOW output have pull-up and pull-down networks in their output stage. That would be a problem for an I2C bus if one device is trying to send the bus HIGH (its pull-up network is active) while another is trying to send it LOW (its pull-down network is active). At best, the bus voltage will be somewhere between HIGH and LOW. At worst, the two networks will form a short circuit between the supply rails.. a condition called 'crowbarring'.

I2C avoids that problem by only putting a pull-down network in the part of a device that talks to the bus. Having multiple pull-down networks active at the same time doesn't cause any problems.

It looks like you're seeing weak leakage from the high-side voltage when the output is floating, but the leakage isn't strong enough to drive the data pins. When you actually have to send a signal through the device, the switch falls to the low-side input voltage.

Try putting a 1k pull-up resistor on the high lines and see if that helps.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 45167
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling NeoPixel from Teensy

by happyinmotion on Thu Dec 26, 2013 5:45 am

Ah, that makes perfect sense. Thanks.

I'll try adding a resistor tomorrow, as it's late here in NZ right now. I presume you mean between the +5V powering the strip and data line on the strip side of the level shifter?

happyinmotion
 
Posts: 42
Joined: Tue Nov 01, 2011 6:15 pm

Re: Controlling NeoPixel from Teensy

by happyinmotion on Fri Dec 27, 2013 1:23 am

Well then, tried adding a 1k pull-up. It didn't change the behaviour at all. So then I checked the schematic for the breakout board of the PCA9306 shifter. Yup, it's already got a 1k pull-up for the I2C lines:
http://dlnmh9ip6v2uc.cloudfront.net/dat ... eakout.pdf

So the lack of a pull-up was a great theory and explained the observed behaviour, but that isn't the problem.

My next theory, after some more head-scratching and asking people who know more electronics than me, is that the black NeoPixel data line is demanding more current than the PCA9306 level shifter can deliver, hence the shifter's pulses are only reaching 3.something Volts, not 5 Volts. Sadly, I don't have a fast current probe, so I can't prove this is the problem.

A solution is to use one of the white strip NeoPixels as a shifter. I've tried putting one between the level shifter and the black strip of 180 NeoPixels. That works fine, very reliable, and the white NeoPixel LED seems happy to take in 3.3 V data pulses and outputs steady 5 V pulses to the rest of the LEDs. (Why there's a difference between the white and black NeoPixel strips, I don't know.) That approach will require me to alter my pattern generating code to generate data for 180+1 LEDs, but that's my back-up plan.

I'd still like to get a level shifter to work, as it seems that plenty of people are wanting to run these strips off the Teensy. Hence I'm going to try a bunch of level converters and see which can reliably connect a 3.3 V Teensy to a 5 V NeoPixel strip.

Paul suggested the 74HCT245. DSS have a nice little TXS0102-based board http://dsscircuits.com/i2c-level-converter.html. Adafruit has an 8-channel TXB0108-based board http://www.adafruit.com/products/395. Sparkfun have the MOSFET based https://www.sparkfun.com/products/11978 and the PCA9306-based https://www.sparkfun.com/products/11955.

I've just ordered one of each of those, coz I want to try them all and work out something that'll be successfull. I'll get back to you all when they arrive and I can test them. I'm in NZ, so it'll be a couple of weeks.

happyinmotion
 
Posts: 42
Joined: Tue Nov 01, 2011 6:15 pm

Re: Controlling NeoPixel from Teensy

by adafruit_support_mike on Sat Dec 28, 2013 11:34 pm

Well, it was a nice idea, and a good example of why an ounce of experimentation is worth a ton of theory.

Paul's suggestion of the 74HCT245 is probably the best solution. It's made to drive other logic chips and produces clean HIGH and LOW voltages directly. It's also made for frequencies up to about 25MHz, so 400-800kHz will be cake. Any I2C driver you use will have the same "needs a pull-up network" problem.
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 45167
Joined: Thu Feb 11, 2010 2:51 pm

Re: Controlling NeoPixel from Teensy

by happyinmotion on Sun Jan 05, 2014 2:44 am

Ok, I'm back from holiday and I've spent the day testing level shifters on black and white NeoPixel strips. TL;DR: Black strips should be set on fire, coz they suck.

I've tested controlling the 5 Volt NeoPixel strips with the 3.3 Volt Teensy 3.0, using either a 74HCT245 logic level shifter or a single LED from a white NeoPixel strip as a shifter. Both of these work absolutely fine if they are powering white strips. I've tested them with the 60 per metre strips, one ten LEDs long, the other fifty-nine. The black strips I used for testing were 36 LEDs long, 120, and a 180 LED cut in four places and soldered up as a 36x5 array. It's the 180 I'd like to use for my current project. All of this was tested at 400 kHz. The test pattern was a rainbow cycle on the first ten LEDs, rather than trying to power the entire length of each strip.

Without a level shifter, driving the black strips direct from the Teensy output gave poor results. The 120 LED strip would get good data and display the test pattern, the 36 and 180 LED strips wouldn't. Attaching an osciloscope to the 120 LED strip data line stopped the pattern from running. This was the case when powering the Teensy and the strip via USB or via a DC wall-plug. The white strips were fine.

Adding in the 74HCT245 changed matters somewhat with the black strips. The 36 LED strip would run and could cope with having a scope attached if on USB power, but not on DC power. The 120 LED strip wouldn't run the test pattern at all, nor would the 180 LED strip. The white strips were fine. Here's the data that was coming out of the 74HCT245 and into the 180 LED strip. Looks pretty good to me but it wasn't working.

Data - 5V start of strip - 74HCT245 - no cable - 180 LEDs - partial.png
Data - 5V start of strip - 74HCT245 - no cable - 180 LEDs - partial.png (22.96 KiB) Viewed 3617 times


Swapping the 74HCT245 for a single NeoPixel LED from a white strip is another suggestion that's been made. So I tried it. Again, this got the 36 LED black strip to work, under both USB and DC power, but neither of the longer ones. Here's the data coming out of the white LED strip and into the black 180 LED strip. Again, looks good to me but isn't working:

Data - 5V start of strip - White LED shifter - Long Black Strip - fails.png
Data - 5V start of strip - White LED shifter - Long Black Strip - fails.png (21.23 KiB) Viewed 3617 times


The black strips are getting good data, the timing is right, the pulses are square. And still they are not working.

As far as I'm concerned, the white NeoPixel strips always work, the black ones don't, and it's not clear to me why. Hence I've just put an order in for 180 LED's worth of the white strip and I'm hoping it'll be here in time for the event I'm making this project for. And I'm hoping that a white strip 180 LEDs long will be as reliable as a strip 59 LEDs long. This is not ideal.

happyinmotion
 
Posts: 42
Joined: Tue Nov 01, 2011 6:15 pm

Re: Controlling NeoPixel from Teensy

by adafruit_support_mike on Sun Jan 05, 2014 3:24 am

It sounds like your problems are related to the number of pixels, not to the signals themselves.

Refresh my memory if you've already posted the infomration somewhere: what are you using as a power supply?
When you void a product warranty, you give up your right to sue the manufacturer if something goes wrong and accept full responsibility for whatever happens next. And then you truly own the product.

adafruit_support_mike
 
Posts: 45167
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.