controlling 100 LEDs on BBB using PWM

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

controlling 100 LEDs on BBB using PWM

Post by lynton »

Hi, I have an art project with 100 leds that we need to control, along with some sensors to detect the outside world and then
display various configurations of the LED's i.e. blinking, fading etc.

I have a BBB RevC on order but unsure of what "capes" or other components I need to be able to make this work.

I am a programmer but also very new to electronics and microcontrollers so I'm after some hardware advise here please.

It looks like the PWM GPIO pins are the way to go but only, i think, 4 PWM pins are available on the BBB.

This product looks like it might be useful
Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface

So I guess this means that with four of these I can get up to 16 x 4 = 64 LEDS controlled this way,
or is it possible to attach more than 4 by chaining them or something ?

Would I need any other components or capes to attach these to the BBB ?
Does this 16-Channel 12-bit PWM/Servo Driver - I2C interface work with the BBB ?

Is this the way to go ? Or can you suggest some other way to gain PWM control over 100 LEDS.

I'm quite new to this so apologies if there is something obvious I have missed.

thanks
Lynton

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: controlling 100 LEDs on BBB using PWM

Post by adafruit_support_mike »

The 16-channel servo driver is a good device, but also take a look at these:

https://www.adafruit.com/product/1455 - 12 channel LED driver
https://www.adafruit.com/products/1429 - 24 channel LED driver

We have a tutorial for the 16-channel driver here: https://learn.adafruit.com/16-channel-pwm-servo-driver , and a combined tutorial for the 12 and 24 channel drivers here: https://learn.adafruit.com/tlc5947-tlc5 ... r-breakout

Give those a look and see if any of them catch your interest. If you have questions, feel free to ask.

User avatar
paulf8080
 
Posts: 208
Joined: Sat Jan 18, 2014 10:25 pm

Re: controlling 100 LEDs on BBB using PWM

Post by paulf8080 »

There are problems with changing the brightness of LEDs with pulse widths. Your eye detects the peak brightness not the average brightness and LEDs are so fast the light does pulse. Motors and incandescent bulbs will average the low and high pulse widths.

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

thanks for that Mike,

the 24 channel LED driver sounds like what I need so 4 of those would get me 96 leds which is exactly what I need.

I notice that the tutorials are for arduino not the BBB so can you tell me if these 24 channel LED drivers are compatible with the beaglebone black
including the programming libraries or are they arduino only ?

Also what cables do I need to chain them together ?

thanks for your help

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: controlling 100 LEDs on BBB using PWM

Post by adafruit_support_mike »

The libraries are Arduino only, but the BBB is capable of sending I2C signals (which the PWM chips use). You'd need to use the Arduino code as a reference for your own BBB code.

Our Adafruit_Python_GPIO library (https://github.com/adafruit/Adafruit_Python_GPIO) makes it easier to generate the I2C signals, so you can concentrate on sending commands and data.

To connect the boards, you'd just need to wire the signals with the same names together (SDA, SCK, Vin, GND). For short runs of wire (a few inches) you can get away with just about anything, but longer runs (a few feet) are best done with twisted-pair phone wire.

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

thanks mike, this sounds achievable

Would the wiring to the BBB be similar to the tutorial for the arduino ?

Are there any other hardware components I might need for this set up to work with 6 chained driver boards
eg additional I2C boards ?

Can you recommend components / connectors needed to supply additional power to the drivers to power 48 RGB LEDs.

Do you think it may be easier to purchase an arduino and pass logic from the BBB to the arduio ?

Thanks for any pointers you can offer, I'm pretty new to all this so all advise is gold to me. I know I have a lot to learn but want to try to buy correct hardware the first time around.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: controlling 100 LEDs on BBB using PWM

Post by adafruit_support_mike »

Depending on how complicated your control system will be, you might be able to do the whole thing with an Arduino.

With the Arduino (or any microcontroller) your code 'runs on the bare metal'.. it has total control of the chip. In a board like the BBB or RasPi, the operating system has primary control of the chip, and your code uses services provided by the OS on its terms. Boards with an OS are much more powerful, but boards like he Arduino give you much more control.

Microcontrollers are good at talking with other chips because your code is already running down at the 'this pin does that' level. The electrical signals and timing are easy to control. You can build a fairly sophisticated control system with one too.

Microcontrollers do have limits though, and that's where the full-Linux boards come into play. Those give you virtually unlimited storage and memory, and the power to run complex software.

Putting the two together is a legitimate strategy, and a lot of development is being done at that level right now. The microcontroller becomes sort of a generic peripheral handling communication between the full-Linux board and the external chips.

The easiest way to transmit data between a BBB and an Arduino is through a UART or Serial connection. On the BBB, those show up as serial ports. On the Arduino, the chip has built-in circuits to handle the communication, and the Arduino code libraries have a Serial class that makes it easier to communicate with that hardware at the programming level.

The exact hardware you'll need to handle the communication depends on how you want to arrange things physically, but the connections between boards can be handled with phone wire. The main hardware issue will be using separtate power supplies for the LED drivers, because those will want more current than an Arduino or BBB can provide on its own.

Each red, green, or blue LED will want up to 20mA, so 24 of them per driver would consume up to 480mA.. roughly half an amp. To run four drivers, your upper limit on power will be about 2A. In most cases you can get away with using a smaller power supply, since getting the whole roughly-2A load would involve running all the LEDs flat-out at the same time. That doesn't happen often, so as a rule of thumb you can generally get away with a supply which provides 1/3 of the upper-limit current.

In this case, we have a nice 5v @ 2A supply that doesn't cost much more than a 1A supply (https://www.adafruit.com/products/276), so you may as well use that.

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

thanks for your detailed response.

I am thinking of going the BBB + arduino way, mainly because the Adafruit code libraries exist for the arduino
so no code porting to BBB to worry about.

I am slightly worried about a possible BANNED hit with this approach.
and that passing data over serial from BBB -> arduino may be slow.

Do you think that performance will be an issue with this approach ?

Also with the additional power supply what other bits do I need to wire the supply up to the LED drivers.

And one more please, rather than using the 6 drivers chained together (project changed a bit and is now going to have 48 RGB LEDS)
are the any LED Drivers that can handle more than 24 channels ?

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

Just found this product
12mm Diffused Thin Digital RGB LED Pixels (Strand of 25).

It looks like I could achieve the same thing much easier with these strips as each LED has its own WS2801 LED driver chip in it.

I would need each single LED in the strip to be about 2 meters apart though.

Would these work at that distance apart and can you easily extend them ?

Are there any pro or cons to this approach over the breakout board approach ?

thanks
lynton

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: controlling 100 LEDs on BBB using PWM

Post by adafruit_support_mike »

Spacing WS2812s apart is fairly easy because each chip acts as a buffer for the rest of the strip/strand. A chip copies the first 24 bits of input it sees to its own control registers, then copies everything else to its DO pin.

That means you don't have to worry about controlling an entire strip, you just have to get the signal to the first pixel.

The WS2812 datasheets say you can space pixels up to 10m apart, but we think that sounds.. optimistic. Spacing of a couple meters shouldn't be much of a problem though.


To make the BBB/Arduino system work better, move as much of the basic blinky-stuff code into the Arduino, and leave the BBB to make the complicated decisions.

Your Arduino code could contain a function that moves a single lit pixel down the string, taking the color of the pixel and the amount of time between steps as parameters. All the BBB would need to do is tell the Arduino "use this color and this dwell time." The amount of data is small, so the transmission will be fast.

You could add another routine that brings the pixel back down the strip from the end to the beginning, then a couple that do roughly the same thing but leave pixels lit as the pattern moves along.

The BBB's job would be to decide what effect you want, then generate a message that tells the Arduino "use pattern P with color C and dwell time D". Again, the transmission itself will be small, simple, and fast.

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

hi thanks that exactly what I was hoping to hear.

I was talking about the LEDs with the WS2801 though not the WS2812
did you just make a typo here ? or if not can you see any problems with the WS2801 LED strips ?

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: controlling 100 LEDs on BBB using PWM

Post by adafruit_support_mike »

That was a mistake on my part.. so many people use NeoPixels that the WS2812 datasheet is sort of spring-loaded in my mind.

The WS2801 controls the LEDs differently, but uses the same "take what you need and pass the rest along" model for sending data along the strand. The WS2801 datasheet quotes a 6m distance between chips, so spacing them at 2m should be no problem.

User avatar
lynton
 
Posts: 10
Joined: Fri Jun 13, 2014 12:45 am

Re: controlling 100 LEDs on BBB using PWM

Post by lynton »

Thanks mike for all your responses,

I think I have a solution now for the LED's.

I will try out an RGB LED string , each LED connected with WS2801 PWM, with the BBB sending serial data like "Pattern A" to a C program on the arduino using the adafruit lib LED strip https://github.com/adafruit/Adafruit-WS2801-Library library.

I will add 2 meter extensions between the PWM chip and the LED's.

Now onto robotic arms, SSC-32 controllers and additional arduino's ... but that's for another topic of course :).

thanks again,
lynton

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”