EEVblog Electronics Community Forum

Electronics => Projects, Designs, and Technical Stuff => Topic started by: CodyW on May 23, 2017, 12:32:10 pm

Title: Problem with NeoPixel Circuit
Post by: CodyW on May 23, 2017, 12:32:10 pm
Hi Everyone,

This is a board I've designed for light painting, more specifically, spinning orbs – [Orb Example] (https://www.flickr.com/photos/46707645@N02/8153479651/in/dateposted-public/)

I built the NeoPixel circuit up on a breadboard and used an Arduino Uno R3 to control it – [The circuit in action] (https://youtu.be/P-tKafG9Aq4). I replicated the circuit on my PCB, with the addition of a 5V LDO.

I assembled the board today and it doesn't work. When I apply power the NeoPixels turn on as a bright blue. This shouldn't happen until I've pressed one of the buttons. The Arduino boot-loader and the code I'm using uploaded fine and I've double checked the pinouts for the pinouts are correct. I'm completely stumped. Does anyone know what could be causing the problem?

Additional information: The micro is a ATMega328P-AU (U3) and the NeoPixels (U1) are in a four lead 5mm LED package. The top copper fill is the 5V supply and the bottom is the ground plane.

(https://c1.staticflickr.com/5/4222/33983933933_b2920b8e16_z.jpg) (https://flic.kr/p/TM3xzp)
 Orb Tool Schematic

(https://c1.staticflickr.com/5/4272/34678859212_82a0803d70_z.jpg) (https://flic.kr/p/UQsdDJ)
Orb Tool Layout
Title: Re: Problem with NeoPixel Circuit
Post by: Andy Watson on May 23, 2017, 12:46:43 pm
When I apply power the NeoPixels turn on as a bright blue. This shouldn't happen until I've pressed one of the buttons.
What steps have you taken to initialise the neo-pixels? I have found that most often they will power-up in totally off state, but there is no guarantee. They can and do power-up in any state. Try holding the data line low for at least the reset period of 50uS.
Title: Re: Problem with NeoPixel Circuit
Post by: tszaboo on May 23, 2017, 12:49:03 pm
I think it has something to do with your reset. Maybe your board does not have enought bypassing, the 328P will wake up later than the LEDs, lines are floating int meantime etc. Try adding a pulldown on the pin you are using for data.
Title: Re: Problem with NeoPixel Circuit
Post by: ajb on May 23, 2017, 03:28:12 pm
The atmega needs a pullup on the reset line and local bypass caps at each pair of power pins.  I don't see any +5V connections to the micro, but I'm guess you're using the top side copper pour for that?
Title: Re: Problem with NeoPixel Circuit
Post by: stj on May 23, 2017, 05:57:33 pm
why did you ground the data output on the final led?
i dont have the datasheet, but that just looks so wrong to me.
Title: Re: Problem with NeoPixel Circuit
Post by: BrianHG on May 23, 2017, 10:14:21 pm
why did you ground the data output on the final led?
i dont have the datasheet, but that just looks so wrong to me.
Yes, that is wrong.  You can damage the last Neopixel like that since that pin is an output.
Also, R1 should be 10 ohms or less.  You might be smearing the data driving the first Neopixel.  Note that my Neopixel projects used no resistor and worked fine, but, they used a PIC as a microcontroler.
Title: Re: Problem with NeoPixel Circuit
Post by: darrellg on May 23, 2017, 10:55:18 pm
Also, R1 should be 10 ohms or less.
Not according to the Adafruit NeoPixel Überguide at https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections (https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections), which says
Quote
Adding a ~470 ohm resistor between your microcontroller's data pin and the data input on the NeoPixels can help prevent spikes on the data line that can damage your first pixel. Please add one between your micro and NeoPixels! Our NeoPixel rings already have this resistor on there
Title: Re: Problem with NeoPixel Circuit
Post by: BrianHG on May 23, 2017, 11:56:05 pm
Funny, where would these spikes come from.  I've never seen spikes when I scoped the data lines.
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on May 25, 2017, 06:02:23 am
Thanks for the help, guys! I really appreciate it.

I've cut the last data out pin on my board so it shouldn't be grounded. Thank you for pointing that error out. I can't recall why I did that.

What pull up resistor value would you recommend for the reset pin? 1K?

The atmega needs a pullup on the reset line and local bypass caps at each pair of power pins.  I don't see any +5V connections to the micro, but I'm guess you're using the top side copper pour for that?

Yup, I'm using the top copper pour for power and the bottom for ground.

What steps have you taken to initialise the neo-pixels? I have found that most often they will power-up in totally off state, but there is no guarantee. They can and do power-up in any state. Try holding the data line low for at least the reset period of 50uS.

Thank you, Andy. I've added my code below so you can see how I initalise them. How could I hold data line low for 50us reset period? .

Code: [Select]
//what is this bit doing?
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN            12

// How many NeoPixels are attached to the Arduino?
#define NumPixels      6

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NumPixels, PIN, NEO_GRB + NEO_KHZ800);

const int BtnTrigger = 9;
const int BtnColourMode = 10;
const int BuzzerPin = 8;

int BtnTriggerState = 0;
int BtnColourModeState = 0;
int LastBtnTriggerState = 0;
int LastBtnColourModeState = 0;
int colour;
unsigned long timer = 0;

uint32_t white = pixels.Color(100, 100, 100); // 0
uint32_t magenta = pixels.Color(100, 0, 50);  // 1
uint32_t red = pixels.Color(100, 0, 0);       // 2
uint32_t orange = pixels.Color(100, 50, 0);   // 3
uint32_t yellow = pixels.Color(100, 100, 0);  // 4
uint32_t green = pixels.Color(0, 100, 0);     // 5
uint32_t cyan = pixels.Color(0, 100, 50);     // 6
uint32_t blue = pixels.Color(0, 0, 100);      // 7
uint32_t purple = pixels.Color(50, 0, 100);   // 8
uint32_t off = pixels.Color(0, 0, 0);         // 9

uint32_t colourMode[10] = {off, white, magenta, red, orange, yellow, green, cyan, blue, purple};

void setup(){
  pinMode(BtnTrigger, INPUT);
  pinMode(BtnColourMode, INPUT);
  pinMode(BuzzerPin, OUTPUT);
  pixels.begin(); // This initializes the NeoPixel library.
}

void buzzer(){
  digitalWrite(BuzzerPin, HIGH);
  delay(50);
  digitalWrite(BuzzerPin, LOW);
}

void trigger(){
  buzzer();
  delay(5000);
  for(int i = 0; i < NumPixels; i++){
    pixels.setPixelColor(i, colourMode[colour]);
    pixels.show(); // This sends the updated pixel color to the hardware.
   }
  delay(20000);
  for(int j = 0; j < NumPixels; j++){
    pixels.setPixelColor(j, colourMode[0]);
    pixels.show(); // This sends the updated pixel color to the hardware.
   }
}

void colourSelect(){
  buzzer();
  if (colour < 9){
    colour++;
    for(int k = 0; k < NumPixels; k++){
      pixels.setPixelColor(k, colourMode[colour]);
      pixels.show(); // This sends the updated pixel color to the hardware.
    } 
  }
  else {
    colour = 0;
  }
  delay(50); // Debounce
}

void loop(){
  int BtnTriggerState = digitalRead(BtnTrigger);
  int BtnColourModeState = digitalRead(BtnColourMode);
 
  if (BtnTriggerState != LastBtnTriggerState) {
    if (BtnTriggerState == HIGH) {
      timer = millis();
      colourSelect();
   
    }
    else if(timer >= 1000){
      //Millis    wait a second after the button has been pressed
      //when the button is pressed, t_i= 0. Turn off after t_f = 1000ms
      for(int l = 0; l < NumPixels; l++){
        pixels.setPixelColor(l, colourMode[0]);
        pixels.show();
      }   
    }
  }

 if (BtnColourModeState != LastBtnColourModeState) {
    if (BtnColourModeState == HIGH) {
      trigger();
    }
  }
  delay(50); // Debounce
  LastBtnTriggerState = BtnTriggerState;
  LastBtnColourModeState = BtnColourModeState;
}


Title: Re: Problem with NeoPixel Circuit
Post by: Siwastaja on May 25, 2017, 06:07:00 am
Funny, where would these spikes come from.  I've never seen spikes when I scoped the data lines.

From parasitic LC circuit.

See: https://www.eevblog.com/forum/projects/reducing-voltage-spike-on-transition/ (https://www.eevblog.com/forum/projects/reducing-voltage-spike-on-transition/)
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on May 26, 2017, 06:14:49 am
Bump. :)
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on May 28, 2017, 06:03:56 am
Last bump. :)
Title: Re: Problem with NeoPixel Circuit
Post by: Helix70 on May 28, 2017, 06:20:16 am
Does it operate correctly despite starting out blue?
Title: Re: Problem with NeoPixel Circuit
Post by: hamster_nz on May 28, 2017, 07:37:29 am
Just on the schematic Is there a pulldown resistor as well as the series resistor for each switch? Or are you using a weak internal pulldown on the MCU pin?

Looks like it might be floating to me....
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on May 28, 2017, 08:38:37 am
Thanks guys!

Does it operate correctly despite starting out blue?

It doesn't unfortunately.

Interestingly though, I swapped out the 5050 SMD NeoPixels I use in my bread board prototype circuit, for the 5mm through hole variety that I'm using on my PCB and I get the blue, but after a button press everything operates as normal.

Just on the schematic Is there a pulldown resistor as well as the series resistor for each switch? Or are you using a weak internal pulldown on the MCU pin?

Looks like it might be floating to me....

I'm just using the the pull down. It seemed to work fine on my bread board prototype. Would it be better practice to use a series resistor between the MCU pin and the switch along with the pulldown?

The only difference between my PCB and the bread board prototype is that I'm using and Arduino Uno R3 to control everything.


Title: Re: Problem with NeoPixel Circuit
Post by: hamster_nz on May 28, 2017, 08:46:51 am
Thanks guys!

Does it operate correctly despite starting out blue?

It doesn't unfortunately.

Interestingly though, I swapped out the 5050 SMD NeoPixels I use in my bread board prototype circuit, for the 5mm through hole variety that I'm using on my PCB and I get the blue, but after a button press everything operates as normal.

Just on the schematic Is there a pulldown resistor as well as the series resistor for each switch? Or are you using a weak internal pulldown on the MCU pin?

Looks like it might be floating to me....

I'm just using the the pull down. It seemed to work fine on my bread board prototype. Would it be better practice to use a series resistor between the MCU pin and the switch along with the pulldown?

The only difference between my PCB and the bread board prototype is that I'm using and Arduino Uno R3 to control everything.

It might be working on the breadboard through luck - just to be sure, maybe bodge 10k between the far side of the R2 & R3 (by the switch) and ground? That way when the switch isn't pushed, it will see 10k+470 to ground, and when pushed it will see 470 to +5V.

I would be more inclined to use the MCU's internal pullup, ("pinMode(x,INPUT_PULLUP)" in Arduino speak), and have the switch drag it down to ground.
Title: Re: Problem with NeoPixel Circuit
Post by: Helix70 on May 28, 2017, 09:00:54 am
There is your clue. The uno has much better decoupling and probably handles the reset pin differently. Have a look at the uno schematic. In short, ceramic caps right next to the power pins, add an electrolytic reservoir on the 5v rail too, use a ground plane instead of thin traces for ground, and use appropriate pull up resistors for the reset. Your pcb isn't using smd neo pixels, are they on wire looms?
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on May 28, 2017, 02:45:06 pm
Thank you hamster_nz and Helix70!

I'll drop the Arduino Uno and build up the full circuit on the bread board once I receive the breakout boards I've ordered and make the changes that you guys have suggested. Hopefully that solves the problem. Thank you!
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on June 11, 2017, 07:59:42 am
Hi Everyone,

I've built the circuit up on the breadboard using a few breakout boards. I added a 10K pull up and a signal diode on the on the reset pin and with

On my breadboard, I am using the broken out 5050 NeoPixels by Adafruit instead of the through-hole 5mm variety.

Before I added in the 5V voltage regulator [MIC5219], I powered the circuit from the Arduino and it works perfectly. I then swapped that over for the LDO which is on a breakout board and the NeoPixels turn on pink and flickered when the circuit is powered on and just stay like that (they should be off when power is applied and not flicker). I triple checked the connections, measured the output of the LDO and it's outputting 5V. I swapped out the LDO's output filter cap, C7 from 10uF to 2200uF (it's what I had) and it still shows pink on power up. The flickering stopped though.

It seems like a power issue but apart from that I have no idea what's going on. Any ideas?

Cody

Current schematic:
(https://c1.staticflickr.com/5/4201/34844326710_b3fba359b8_z.jpg) (https://flic.kr/p/V65hnC)
Title: Re: Problem with NeoPixel Circuit
Post by: stj on June 11, 2017, 10:31:04 am
can you give me a link for 5mm neo-pixels please, i'v not seen them.
Title: Re: Problem with NeoPixel Circuit
Post by: darrellg on June 11, 2017, 03:19:05 pm
It seems like a power issue but apart from that I have no idea what's going on. Any ideas?
The symptoms you describe sound like you don't have all the grounds connected together.
Title: Re: Problem with NeoPixel Circuit
Post by: CodyW on June 12, 2017, 06:27:22 am
can you give me a link for 5mm neo-pixels please, i'v not seen them.

Here we go, stj: https://www.adafruit.com/product/1938. (https://www.adafruit.com/product/1938.) There's also an 8mm version:https://www.adafruit.com/product/1734 (https://www.adafruit.com/product/1734)

The symptoms you describe sound like you don't have all the grounds connected together.

Thank you, darrellg!