Go Down

Topic: [SOLVED] ATTiny85 WS2812 won't work (all white) -- but works on MSP430 (Read 4000 times) previous topic - next topic

andymule

I was super stoked to get my ATTiny85. I love tiny electronics. Well, they came in, and they run BLINK, but I cannot get them to control my WS2812 LEDs.

I've confirmed that my LEDs are all fine --  can control them easily from my MSP430 Launchpad.

I've tried lots of different things to get them to work with the ATTiny: three different LED libraries, three different ATTiny board definitions, I tried running my ATTiny at 16MHZ instead of 8MHZ, I tried different versions of Arduino (1.6+ and 1.0+), and I've tried different physical ATTinys themselves. I do have a capacitor on my power supply. I've confirmed that my ATTiny is running at 5v. I do have a resistor on my data channel. Again, my LEDs work perfectly on my MSP430 without any hardware change except moving the data wire. I'm at a loss. All they do is turn full bright white -- a blinding reminder of my failure.

Any ideas?

PaulRB

Quote
Any ideas?
Yeah. If you want help, follow the forum rules. Post your code, schematics, pictures etc. The forum rules are designed to help us non-psycic form members to help you.

I can tell you that an attiny85 can control ws2812 leds at 8MHz, I have done it myself.

andymule

Here is my working MSP430 setup running via Energia. In my mind, this proves that the LEDs themselves are functional:

Code:
Code: [Select]
#include <WS2811Driver.h>
WS2811Driver ledStrip = WS2811Driver(18, 2, NEO_GRB);
void setup(void){
  ledStrip.setBrightness(255);      //Set LED strip brightness to max
  ledStrip.begin();        // configure P1.6 for output
}
void loop() {
  rainbowCycle(10);
}
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< ledStrip.numPixels(); i++) {
      ledStrip.setPixelColor(i, Wheel(((i * 256 / ledStrip.numPixels()) + j) & 255));
    }
    ledStrip.show();
    delay(wait);
  }
}
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return ledStrip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return ledStrip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return ledStrip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}



My LEDs are powered from computer's USB port, running ~.9 amp 5V power. I stuck a capacitor here, as suggested.


They work perfectly:



Now, for the ATTiny85. I'm running it thru the Tiny AVR Programmer
VIA Sparkfun

I'm running a 5k resistor out of port 1, as suggested. This leads to my LEDs lighting up, but being completely unresponsive and looking just like this:


Here's my arduino code. It is identical to my Energia code but uses the standard Adafruit Neopixel library:
Code: [Select]
#include <Adafruit_NeoPixel.h>
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(18, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
void loop() {
  rainbowCycle(10);
}
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;
  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}



As i said in the original post: I've tried every variation of setting i could think of beyond this (ws2812 librarys, arduino versions, attiny board definitions, power config of hardware, clock speed, physical chip), so I'm out of ideas. 

Thanks!

Qdeathstar

are the grounds from the leds and the attiny tied together
A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

andymule

They weren't at the time explicitly shared grounds, but it was a previous configuration i had tried.

Here I am trying with shared grounds with the same result (non-responsive full-white LEDs)

PaulRB

5K sounds too high. Try 220R to 510R.

andymule

I've now tried 15k, 5k, 510, 220, and none-at-all. It seems like anything above 10k sends too low of a signal and they don't even turn on. Every other value has the same blinding result of all white with no responsiveness.

andymule

INTERESTING HINT:

Reducing the the size of the LED strip does in fact reduce the LEDs that get turned to full white. Reducing my strip size to 7 does, in fact, only light up 7 unresponsive LEDs. 

So... SOMETHING is getting through to them....

Code: [Select]
#include <Adafruit_NeoPixel.h>
#define PIN 1
Adafruit_NeoPixel strip = Adafruit_NeoPixel(7, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  strip.show();
  strip.setBrightness(20);
  strip.setPixelColor(1, 100, 0, 0);
  strip.setPixelColor(7, 0, 0, 0, 127);
  strip.show();
}

mcnobby

Sounds like timing to me, what happens if you switch the colour to off ? do they go off or still maintain white ?
http://www.youtube.com/user/Recovered
http://www.smartshow.lighting

mcnobby

Did you select the higher clock speed and burn the fuses ? I thought the ATTiny can only manage 8MHz with its internal resonator ? are you using an external crystal in the design ? Otherwise I think it defaults to 1MHz
http://www.youtube.com/user/Recovered
http://www.smartshow.lighting

andymule

I agree it seems like a timing thing...

ATTiny can actually go to 20MHz, I think.
ATTiny specs

I've confirmed that I am getting 5V to the chip.

For both chips I tried, I started both chips by flashing BLINK at 1MHz. I then tried using 8MHz and running the adafruit strandtest example (as included above), and it's already unresponsive.

That's what made me use the two other board definitions that allow the 85 to go to 16MHz -- I thought maybe it needed that jolt.

(some time passes here)

I actually just came across this link talking about 16MHz ATTiny85, and this line came up:
Quote
One caveat of programming is, when using a brand new chip, or when changing the clock speed, you need to choose Burn bootloader from the menu. This will set the fuses on the chip so that it runs at the selected clock speed.
ATTiny @ 16 MHz site

I've definitely never heard that before. This seems to commonly be an assumed piece of knowledge.

So, this is almost certainly the problem. I'm excited to get home and try it out. Thanks for the prod, mcnobby!

andymule

SO that's it.

If your LEDs aren't responding correctly, make sure you've burned your bootloader.
And everytime you change the clock setting (and probably some other possible board settings) make sure you burn your bootloader.

CHeers!


Go Up