0

is a capacitor/resistor necessary if i am powering NeoPixels
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

is a capacitor/resistor necessary if i am powering NeoPixels

by Izmuntil on Wed Sep 03, 2014 6:24 pm

sorry for the barrage of questions in advance.

i have been looking at the Uberguide, and the various guides that are posted on adafruit and i noticed a few things, i dont know if they are inconsistencies or not, but i just want to make sure before i start cutting any wires that are difficult to replace.

1. in the Uberguide it says to attach a capacitor to the power supply, except i am powering mine via a battery that connects right into Gemma, do i need a capacitor? if so, where would it even go? many guides i see dont use one of these, including the Scanner Shades (the one i am using as my wiring diagram)

2. the Uberguide also says to attach a resistor between the NeoPixel strip and Gemma, the only photo i have of a guide using one is with a breadboard, so is it necessary if i am not using a breadboard and simply following a guide?

3. my strip of NeoPixels came with 2 JST connectors on both ends. if i am following a guide that uses only 3 wires, i assume that i am supposed to cut the JST connector off, but i am hesitant to do that when the Uberguide has a picture of it in use, but that ties into question 1

edit: oops title, i mean "powering NeoPixels with a battery through Gemma"

Izmuntil
 
Posts: 17
Joined: Sun Aug 10, 2014 4:13 am

Re: is a capacitor/resistor necessary if i am powering NeoPi

by adafruit_support_mike on Thu Sep 04, 2014 3:05 am

The capacitor isn't strictly necessary, but it's a good idea.

NeoPixels use PWM to control their LEDs, so the demand for current changes suddenly when the controller turns an LED on or off. Those sudden changes in current flow can generate spikes in the supply rail.

Technically, it has to do with the fact that any conductor with current flowing through it generates a magnetic field. Sudden changes in the current make the magnetic field expand and contract, and the changes in the magnetic field have an effect on the current. Expanding steals energy that would make the current flow, contracting dumps energy into the current that's trying to slow down.

The upshot is that PWM causes spikes in the supply rails.

If the spikes are big enough, they can make a microcontroller reset, and in some cases can damage the input circuts that read signals on the wire.

A capacitor connected between the supply rails absorbs the spikes. Capacitors store current as a fixed electrical field, and changes in voltage change the strength of the field. If the voltage rises the field gets stronger, and if the voltage falls the field gets weaker. Making the field stronger absorbs current, while letting the field get weaker releases current.

Long story short, the capacitor compensates for the inductance of the wiring. When the magnetic field tries to steal energy, the capacitor releases some more current. When the magnetic field tries to dump energy into the current, the cap absorbs it.

The result is that the cap keeps the supply rails smooth.

You want to connect the cap as close as possible to the demand for current because that makes the inductive current loop smaller (and weaker). Put it as close to the point where power enters the NeoPixel strip as possible.

The resistor also compensates for inductance in the wires, but in a different way.

Electrical signals behave like waves, and one of the interesting things about waves is that they don't generate flow.

If you put a ping pong ball into a tub of water and start making waves, the ball will move up and down as the waves pass, but won't move side to side very much. The water molecules do more or less the same thing: the approaching wave imposes pressure, but the water molecules can't push the ones ahead of them out of the way. Instead, they push in the direction that offers the least resistance: up against the air.

Rising vertically absorbs the energy of the incoming wave, but when there's no more incoming energy the highest part of the wave starts to fall again. That pushes down on the molecules below, which put pressure on the molecules ahead of the wave, which absorb the energy by moving vertically, etc.

That works fine until the wave hits the side of the tub.

The side of the tub doesn't absorb energy from the wave as easily as water, so when the molecules at the top of the wave fall and start putting pressure on the molecules below, the path of least resistance will be back the direction the wave came from.

When that happens, we say the wave has reflected off the side of the tub.

Those general mechanics carry over to electrical signals as well, but instead of 'altitude' we have 'voltage', and the factor that controls how easily electrical waves can flow into some part of the circuit is the resistance.

A wire has very low resistance, which means electrical waves can flow through it easily. The input circuits that read signals in a wire have very high resistance (usually around 10M), and that difference makes the water-to-tub thing look tame.

Any time an electrical signal flows through a change in resistance, some of the energy goes forward and some gets reflected back. For the high-impedance input circuits in a NeoPixel, almost all of the energy gets reflected.

That isn't so bad for circuits where the wiring is short, but if you add a couple feet of wire's worth of inductance, the reflection can pretty much double the voltage in the wire for a short period of time. Under the right circumstances, that increase in voltage can short out the NeoPixel's input.

Putting a resistor on the wire just before the input reduces the problem in a couple of ways.

First, it moves the point of reflection away from the NeoPixel's input. A 200 ohm resistor lets signals flow a lot more easily than a 10M input impedance, but it's still a lot higher than the resitance of a wire. A lot of energy will be reflected at the point where the wire meets the resistor, but the peak won't go as high because the resistor does allow more energy to pass through.

Second, all resistors convert electrical energy to heat. Inductors and capacitors absorb energy in a form that can be released again, but resistors aren't reversible that way. The energy they absorb can no longer be used by the circuit. In this case that's a good thing, because the energy in question could potentially damage the NeoPixel.

So.. the series resistor on the input protects the NeoPixel's input circuit by causing most of the energy in the wire to reflect back to the source before it ever reaches the pixel, then burns away any excess energy that could cause a reflection at the point where the resistor meets the NeoPixel.

Again, you want the shortest possible path between the resistor and the NeoPixel. Seatbelts and airbags don't do any good if you put them 10' ahead of the car.

The more NeoPixels you have, the more good a capacitor does. The longer the wire between the microcontroller and the first NeoPixel, the more good a series resistor does.

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

Re: is a capacitor/resistor necessary if i am powering NeoPi

by Izmuntil on Fri Sep 05, 2014 3:25 pm

alright, i have gone to my local electronics store (who didnt know as much about wiring and such as i hoped) and bought a 1000 µF 16V Capacitor, the 16V was the smallest they had. i also bought some resistors from them, 2 200 ohm resistors, one at .5 Watts and the other at .25 Watts. also got 2 more at 300 ohms (.5 and .25 again). there was nothing in the uberguide that said anything about the Wattage of the resistors, so im unsure if the .5 or the .25 is better.

also, besides the photo on the uberguide, i dont have any clue where to solder the capacitor. the photo with the capacitor isnt even attached to the wire itself, just attached to the battery, which is different from what i will be doing as i am using a Li Poly battery . i understand that it should be as close as possible to the first NeoPixel, but besides that, should i solder it between the Vout (red) wire and the ground (black) wire (thats what the guy who helped me said)? should it just be on the red wire?

the same goes for the resistor. i dont see any guide using one so i dont know where to put it. yea i know, as close to the first NeoPixel as possible, but should i cut the white wire and solder the resistor between the ends? is there a photo on Adafruit that shows how to do these things?

thank you in advance

Izmuntil
 
Posts: 17
Joined: Sun Aug 10, 2014 4:13 am

Re: is a capacitor/resistor necessary if i am powering NeoPi

by adafruit_support_mike on Fri Sep 05, 2014 10:04 pm

The capacitor's 16v rating means you don't want the voltage across its terminals to rise above that value. NeoPixels run at 5v, so that capacitor will work fine.

The wattage rating of the resistors wasn't mentioned because only a small amount of power will flow through it. 250mW resistors are more than strong enough.

You want to connect the capacitor between the red and black wires, and since you probably have an electrolytic capacitor, you'll need to connect it in a specific way: There will be a stripe on the can with '-' marked on it. That lead connects to the GND wire (usually black) and the other lead connects to the VCC wire (usually read).

The resistor connects to the NeoPixel strip's data-in wire, one end connected to the NeoPixel strip, the other end connected to the wire that comes from the Arduino.

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

Re: is a capacitor/resistor necessary if i am powering NeoPi

by Izmuntil on Fri Sep 05, 2014 11:36 pm

thank you for clearing that up.
a few more things to clear up and i think i'll have enough confidence to start trying it out for myself.
- i should connect the resistor from the white wire TO the NeoPixel strip itself, i shouldnt connect it in the middle of the white wire(both ends touching white wire), which sounds like i'll need to cut off the protective covering and scrape the white wire off of the NeoPixel so i can solder the resistor there, correct?
- should i do all this before i even test the NeoPixels, or would connecting Gemma to my computer attaching some alligator clips between it and the NeoPixel strip run the same risk as if i was using it with a battery out in the field?

Izmuntil
 
Posts: 17
Joined: Sun Aug 10, 2014 4:13 am

Re: is a capacitor/resistor necessary if i am powering NeoPi

by adafruit_support_mike on Sat Sep 06, 2014 12:22 am

Connecting the resistor directly to the NeoPixel strip would be ideal, but you can also cut the input wire an inch or two from the end of the strip and connect the resistor there. Wires less than a couple of inches long don't cause much trouble at the speeds NeoPixels use.

It's a good idea to connect the capacitor and resistor before lighting the strip the first time, but isn't strictly necessary. The strip will work without them, but without them the pixels are a bit more vulnerable to damage. If you keep your wires short (less than a foot), the strip should be fine.

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

Re: is a capacitor/resistor necessary if i am powering NeoPi

by Izmuntil on Sat Sep 06, 2014 2:47 am

it has worked! thank you so much :)
i did a strandTest and it worked on the first try. i did notice that when i powered up the NeoPixel strip the first LED turned a bright white, without me coding anything, is this normal?

Izmuntil
 
Posts: 17
Joined: Sun Aug 10, 2014 4:13 am

Re: is a capacitor/resistor necessary if i am powering NeoPi

by adafruit_support_mike on Sun Sep 07, 2014 12:59 am

That was probably just garbage data in the pixel's control register.

All mechanical connections produce a burst of on/off noise when they make or break contact. If the pixel thought the noise looked like data, it would set its output to whatever it thought it was being told. White would be a nearly equal balance of red, green, and blue, which is statistically reasonable for random noise.

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

Please be positive and constructive with your questions and comments.