redAlertLight

for a new piece i'm working on (redAlert) i wanted hundreds of red leds attached to special 'blobs' or lamps spread out on stage (designed by Jenny Michel). each led should be able to be freely placed and controlled individually and they had to be fairly bright. and because of the custom led placement i couldn't have used led strips - strips have a fixed distance between the leds.

so i built three circuits that could drive 32 pwm channels each and thereby got 96 pwm channels in total. each channel connects three leds in series (in a single package) and a resistor. that makes in total 288 leds.

the led i selected was the LED 5252 uh rt/1700mcd. it has 120 degrees spread angle and comes in a 5x5mm 6pin smd package that's possible to solder by hand. i bought it from segor where it costs 0.42 euro if you buy +100.

here a picture of it from the back side. the 270ohm resistor is chosen to match 12v and the three leds are connected in series using thin copper wire.

redAlertLight01

the three boards are controlled wirelessly and i send osc commands from supercollider to control all the leds. there's a class for supercollider attached below that helps with addressing and packaging of the network data. one can build and connect as many of these 32ch boards as one likes.

for actually generating the 12v pwm i used on each board two tlc5490 in combination with four uln2803a. and i also added a barebone arduino to get a stable spi communication with the tlc5490.

redAlertLight00

back side...
redAlertLight02

for receiving wireless osc data i added a raspberry pi (model a) with an usb wlan stick. on the rpi there's just a small python program that receives osc and sends out serial commands to the arduino.

last i have a tp-link TL-WR703N with open wrt installed acting as a router. when the boards start up they try to connect to this router and gets an ip assigned dynamically. this ip i use in supercollider to differentiate between the three boards.

installation instructions

//--
* put 2013-09-25-wheezy-raspbian.img on a sd-card with Pi Filler
* put the card in a raspberry pi MODEL B, connect ethernet and 5v
* find the IP with LanScan.app

(* ssh-keygen -R 192.168.1.51)
* ssh pi@192.168.1.51
* default password: raspberry
* sudo raspi-config
* select 'Expand Filesystem', change password, reboot and log in with ssh again

* sudo apt-get update
* sudo apt-get upgrade
* sudo pico /etc/inittab
* comment out the line 'T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100' near the bottom and save
* sudo pico /boot/cmdline.txt
* remove 'console=ttyAMA0,115200 kgdboc=ttyAMA0,115200' and save
* sudo reboot

* sudo apt-get install python-serial
* git clone git://gitorious.org/pyosc/devel.git
* cd devel
* sudo ./setup.py install
* cd ~

//--set up wlan on the rpi
* sudo nano /etc/network/interfaces
* edit to say...
        auto wlan0
        allow-hotplug wlan0
        iface wlan0 inet dhcp
                wpa-ssid SSID_NAME
                wpa-psk SSID_PASS
                wireless-power off
* sudo ifdown wlan0
* sudo ifup wlan0

//--copy file from laptop to rpi
* scp redAlertLight.py pi@192.168.1.51:/home/pi/

//--automatically start the python program at startup
* sudo pico /etc/rc.local
* add the following before the exit line: (sleep 1; python /home/pi/redAlertLight.py) & # autostart

//now move the sd card over to model a, connect the circuit and try

//--useful if you log in via ssh and want to stop the python program
* sudo pkill python

here is the python code...

#redFrik 2013

import serial
import socket
import OSC
import threading
import time
import os

addy= '0.0.0.0', 15000  #from sc
osc_server= OSC.OSCServer(addy)

port= serial.Serial('/dev/ttyAMA0', 115200)     #to atmega168
port.open()

def osc_led(addr, tags, data, source):
        #print tags
        #print "incoming osc data: %s" % data
        arr= bytearray()
        arr.append(254)
        for val in data:        #data has size 16 (24bit ints)
                hi_val= val>>12
                lo_val= val&4095
                #here can be optimized later to send fewer bytes (48 instead of 64)
                arr.append(hi_val>>8)
                arr.append(hi_val&255)
                arr.append(lo_val>>8)
                arr.append(lo_val&255)
        arr.append(255)
        port.write(arr)

osc_server.addMsgHandler("/led", osc_led)

def osc_stop(addr, tags, data, source):
        #print tags
        #print "shutting down"
        shutdown()

osc_server.addMsgHandler("/stop", osc_stop)

thread= threading.Thread(target= osc_server.serve_forever)
thread.start()

def all_led_off():
        osc_led(None, None, [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], None)

def shutdown():
        close()
        os.system("sudo halt")
        exit()

def close():
        print "\nclosing"
        osc_server.close()
        all_led_off()
        port.close()
        #thread.join()

def main():
        try:
                while True:
                        line= port.readline()
                        if line.startswith("stop"):
                                shutdown()
        except KeyboardInterrupt:
                close()

if __name__ == "__main__":
        main()

attached is schematics, arduino firmware, partslist...

AttachmentSize
Image icon redAlertLight_schem.png1.5 MB
Package icon redAlert_mega168.zip1.1 KB
Plain text icon partlist.txt533 bytes
Package icon RedAlertLight.zip7.58 KB