‹ New Musical Instruments redThermoKontroll2 ›

redAlertLight

2013-10-17 11:30 electronics

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 backside. The 270 Ohm resistor is chosen to match 12V and the three LEDs are connected in series using thin copper wire.

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.

Backside...

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, 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 an 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 are schematics, Arduino firmware, parts list...


‹ New Musical Instruments redThermoKontroll2 ›