New to RPi. I plan on building a lighting setup consisting of ~ 64 Panels, which I want to control via the RPi. Is there a way to do that with the limited amount of pins the RPi supplies?
New to RPi. I plan on building a lighting setup consisting of ~ 64 Panels, which I want to control via the RPi. Is there a way to do that with the limited amount of pins the RPi supplies?
The RPi has 17 available IO pins. So driving 64 panels is going to be a challenge.
You could arrange them in an 8x8 matrix, but there is another potential problem. The amount of current you can draw from the IO pins of a Raspberry Pi is very limited, you may not be able drive 64 panels.
We need more information:
- What kind of light source are you going to use?
- How large/bright do these panels need to be?
- Are they each going to be a single colour or do you need them to change colour?
- Do you just want to turn them on and off or do you want to control the brightness?
- How far from the RPi will they be mounted?
- Is there any thing else the application needs to do beyond control the lights?
If you want advice on any of the above that's fine, but some of these I suspect are already fixed by what you want to do.
- Derek
Derek Campbell wrote:
The RPi has 17 available IO pins. So driving 64 panels is going to be a challenge.
Look up the Microchip GPIO Expanders MCP23017 / MCP23S17, these are 16bit expanders and you can daisy chain 8 of them per i2c bus or SPI chip select. By my count that lets you have 256 IO pins using just 5 on the Pi.
As with any GPIO expanders, you're going to be limited in some way on the frequency you can update them, but as Peter didn't specify what his lights are we have no way of knowing if that's a problem. Simple number of GPIO pins isn't a problem.
As I mentioned, by multiplexing you could fit it into 16 outputs, much like a seven segment display is driven.
As you suggest, I'll leave value judgements to the implementer.
Peter, we're talking about something like this http://www.adafruit.com/products/887 yes ?
There are various different versions of these as seen under 'Know Your LED Strips' here http://learn.adafruit.com/digital-led-strip some of which have individually addressable LEDs which would mean you could daisy chain them all and control everything with just a couple of pins.
As Derek suggests there are also various multi-channel PWM controllers like the TLC5947 24 channel device that could help, many of which will considerably reduce both pin count and complexity since you can tell the controller what you want and it'll take care of the hard stuff for you.
How you proceed maybe depends on whether you have your lighting strips already, or not. Either way there are lots of choices, for how to proceed.
Derek Campbell wrote:
If you don't need maximum output, you could consider multiplexing them, but I think Selsinork's suggestion will give you the maximum flexibility with respect to adding brightness control later.
Those expanders are pretty low cost and four will cover your needs.
The concern would be that doing software PWM with them becomes limited by SPI clock speed, so perhaps a purpose designed multi channel PWM controller would be a better starting point.
You're still right that more information is needed to help Peter get the best out of what he's trying to do 
selsinork wrote:
The concern would be that doing software PWM with them becomes limited by SPI clock speed, so perhaps a purpose designed multi channel PWM controller would be a better starting point.
Yes, definitely something to think about. SPI can be driven at 16MHz and even beyond with some care. A 100Hz rate would keep the PWM pulses invisible to the human eye, so I think there's a comfortable margin there to allow a usable brightness range.
I think I2C might be a better bet than SPI, given the need to connect 4 devices. That has a typical 100KHz bus speed which might be a bit closer to being limiting, though still useable I think.
Derek Campbell wrote:
Yes, definitely something to think about. SPI can be driven at 16MHz and even beyond with some care.
Assuming still talking about those MCP23S17's they have a max SPI rate of 10Mhz according to the datasheet, the BCM2835 arm peripherals data sheet suggests a theoretical 125MHz max for SPI but then goes on to say that's not actually possible, but without giving enough info to tell what is.
I think I2C might be a better bet than SPI, given the need to connect 4 devices. That has a typical 100KHz bus speed which might be a bit closer to being limiting, though still useable I think.
MCP23017 can do 1.7MHz i2c, Pi can do 400KHz.
The need to connect 4 of those to SPI shouldn't be a problem, you can configure 3 bits of addressing for each chip allowing 8 on a single spi chip select, they are quire nice that way 
Anyway, I think we've come to the same conclusion - it's certainly very possible to do it. Exactly how is up to Peter, but help is available here if he needs/wants it !
Just a short follow-up question. How do I control those chips (using code) then?
Here is a link that looks useful for I2C.
Thank you! Do you know where I can find a diagramm of how to hook up multiple MCP23017 chips up to one pie?
http://en.wikipedia.org/wiki/I²C#Design
Google is your friend ;-)
Thanks! Do I need those pullup resistors or does the RPi have internal ones?
Thanks! Do I need those pullup resistors or does the RPi have internal ones?
I believe the Pi has 1k8 pullups.
You may also want to consider how long your control wires will need to be.
Depending on how far apart your panels are, it may be better to employ a
communications or control technology (e.g., Z-Wave, Zigbee, Wi-Fi) and
build the power control into each of the panels (making them individually
controllable). The easiest way to do it is also the most expensive (buy
pre-built Z-Wave modules and put a RaZberry board on the RPi).
A more complicated, moderately less expensive method would be to use the
RaZberry on the RPi and incorporate something like the ZM3102 (
http://www.digikey.com/product-detail/en/ZM3102AU-CME1/703-1023-ND/1632504)
in each of the panels. You'd still need to design the power control though.
I'm currently loving Z-Wave technologies because you can poll the various
nodes for their settings (i.e., you can tell if a light is on or off, or if
it's set to a certain dim level). Done properly, it can be incorporated
into an existing home automation system.
- Tim