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.
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?
I believe the Pi has 1k8 pullups.
also worthy of note is that there are kernel drivers for these that will allow you to make them look like any other supported GPIO and to control them via /sys/class/gpio/gpio<n>/value just like the onboard ones.
You probably need to recompile your kernel to do so though.
There are also various gpio led drivers as well as ones that can handle some of the led pwm chips.
If there's a suitable driver available for the hardware you choose and your use case, it may be simpler to use it than to completely reinvent everything yourself.. Of course if you do that you don't learn quite so much in the process, but all depends on what you want to get out of the experience.
also worthy of note is that there are kernel drivers for these that will allow you to make them look like any other supported GPIO and to control them via /sys/class/gpio/gpio<n>/value just like the onboard ones.
You probably need to recompile your kernel to do so though.
There are also various gpio led drivers as well as ones that can handle some of the led pwm chips.
If there's a suitable driver available for the hardware you choose and your use case, it may be simpler to use it than to completely reinvent everything yourself.. Of course if you do that you don't learn quite so much in the process, but all depends on what you want to get out of the experience.