Make a Glowing, Wearable, EL-Wire, Blinky Light Using Open Source Tools

by Mikey Sklar
June 24, 2005

On a business trip to Seattle earlier this year, I received the usual geek industry schwag, plus an ultra-shiny, silver, European sling bag. I loved the bag, but found myself unwilling to wear it because of the prominently displayed Xbox gaming station logo on the exterior pouch. As an open source advocate, I was not willing to promote a Microsoft product on my back. I considered ripping the logo off, potentially destroying the bag, but then I had a better idea: I decided to use open source software to create a glowing light pattern right on top of the Xbox logo.

I set out with the goal to use as few commercial products as possible and an Apple Computer, dispelling any notions that this kind of project can only be created using a PC. The project led me to design and etch my own circuit board and program a microcontroller using open source tools. I can even apply the knowledge I acquired while making this bag to numerous future electronics projects.

This article documents the way I did it, for interested DIYers. In it, I describe the electronic design automation (EDA) software tools and microcontroller programming apparatus used to control the blinking patterns. All the software tools are open source (except for the Keyspan driver) and can run under Mac OS X. I also cover the physical tools and electronics necessary to fabricate and assemble the printed circuit board (PCB) and the lights themselves.

Software Setup

This may seem like a simple blinky bag, but it took a lot of software to make the blink pattern. Except for the Keyspan driver, all of these programs (the EDA and microcontroller software) can be installed via Fink, which is a package manager for Mac OS X. You can see my Fink configuration files for these packages on my personal website.

  • Fink: Unix open source package manager for Mac OS X, based on Debian tools (dpkg/apt-get).
  • picp: Command line interface to PICSTART Plus and Warp-13 programmers.
  • gputils: Collection of tools for the Microchip PIC microcontrollers. Includes the assembler used in this project, gpasm.
  • gpsim: Software simulator for Microchip PIC microcontrollers.
  • geda-gschem: Schematic capture program/tool which is part of gEDA (an open source suite of Electronic Design Automation tools).
  • PCB: Interactive circuit board editor for X11. Able to import part and netlist data from geda-gschem.
  • Keyspan USB driver: High-speed USB adapter that supports db9 serial devices up to 230Kbps. There is a newer USA-19HS model that I've not tried yet. It replaced the 19QW model I have been using.

Parts

Computer Hardware

  • Computer (running Mac OS X)
  • Microchip PIC programmer PICStart Plus
  • Keyspan serial-to-USB adapter 19QW

Computer hardware you'll need.

Hand Tools

  • Soldering iron and solder
  • Wire strippers/cutters
  • X-Acto knife
  • Lighter
  • Clothing iron

Hand tools you'll want to have for this project.

MAKE IT:

1. Solder electroluminescent (EL) wire to ribbon connector.

The external part of the bag that glows is made from angel hair EL wire (about 1.2mm thick). This glowing EL wire requires a high-frequency AC signal (2kHz-8kHz) to glow. I used commercially available inverters to produce this high frequency signal. The smaller inverters can use 1.5V-12V DC battery inputs and output around 110V-190V AC.

The EL wire usually costs about $1.20 a foot when purchased online. The wire is a little tricky to work with.

a. Use a lighter and burn off about 1" of colored housing from the end of the EL wire.

b. Peel back EL wire fine hairs and burn away exposed white phosphor tip. Scrape the phosphor with an X-Acto knife, leaving a clean metal core to solder with.

c. Wrap a small piece of copper tape around the edge of the colored plastic sheath. Include the EL wire fine hairs in this piece of copper tape, and use a very small amount of solder to securely adhere the EL wire fine hairs to the copper tape.


Preparing the EL wire.

d. Strip the ends of a 5" piece of thin hookup wire (hookup wire in this case being a copper wire with plastic housing, 22-32 gauge) and solder to the copper tape. The tail of the hookup wire should be in the same direction as the EL wire housing.

2. Connect the EL wire to the ribbon cable.

It's time to hook up the EL wire to the ribbon cable. Strip the leads off one side of the ribbon cable. Place 1.5" of heat shrink tubing over the leads of the ribbon cable. Solder the inner core of the EL wire to the ribbon cable. Apply heat (via a lighter, hairdryer, or heatgun) to the heat shrink on each lead. Make sure that no copper tape or inner core is exposed; they can give a nasty shock.

a. Connect all the copper tape leads that were soldered. Solder those leads, but leave them un-heatshrinked for the moment. We need to connect that to the circuit board later.


EL wire connected to the ribbon cable.

b. Use a thread and needle or a tool like a Buttoneer to attach the EL wire to the backpack. (A Buttoneer is designed to attach buttons to shirts without the use of needle or thread).

3. Install Fink.

You should be running Mac OS X Panther (10.3) or Tiger (10.4).

a. If you haven't already, install the X11, X11 SDK, and the Xcode development tools. These usually come with the OS X installation media. If you are running Tiger, you can download the X11 SDK at http://developer.apple.com/tools/xcode/index.html.

b. Obtain the latest Fink binary at http://fink.sourceforge.net/download/index.php.

c. Click on fink-ver-installer.dmg file, click on the mounted image icon, and click on the fink-installer package. Fink will prompt you to update your .profile; go ahead and let it. This will automatically put all Fink packages in your PATH.

d. Start up X11 from Applications/Utilities folder. Launch a Terminal window from X11 Applications menu (xterm).

  • Update Fink: fink selfupdate
  • Update Fink: fink update-all
  • Modify fink.conf MirrorOrder line: /sw/etc/fink.conf --> MirrorOrder: MasterLast

4. Install the software packages.

a. Grab the collection of Fink info files from my website. Copy all the Fink info/patch files into your local Fink info directory, and have Fink index them:

sudo cp -p ~/Desktop/fink/*/* /sw/fink/dists/local/main/finkinfo
fink index

b. Install these software packages:

  • geda-gschem (part of geda-bundle)
  • PCB
  • gputils
  • gpsim
  • picp

c. Run the command:

fink -y install geda-bundle pcb gputils gpsim picp

You can go watch a movie while the package building goes on. gschem and PCB take a particularly long time. It takes hours on my Apple G4 800MHz desktop. Fortunately, package building is a one-time deal.

5. Design the circuit.

As homebrew hardware enthusiasts advance their skillsets, they often start creating printed circuit boards for their projects. A printed circuit board (or PCB) most often consists of copper traces that interconnect components on a piece of fiberglass.

The PCB used in this project is single-sided, for ease of home fabrication. Boards with two or more layer can also be homemade, but it's a more complicated process, so these are usually fabricated in professional shops.

There are significant advantages to using a PCB over point-to-point breadboards:

  • Reliable connections between components (fewer loose wires)
  • Density improvements (smaller project size)
  • Reproducible design (make more, share with others)

In this project, I use three pieces of software to create the plans for a PCB.

  • gschem: design the schematic
  • gschem2pcb: convert electronic part attributes to PCB format
  • PCB: draw copper traces for electronic parts connections

gschem

gschem is a fairly simple GUI for diagramming the electronic components of a system. In this project, I used gschem for the following:

  • Labels for all electronic parts used in project
  • Attributes of parts (part size, aka footprint, part name/number)
  • Logical layout of electronic component connections
  • Naming of connections (nets) between electronics

Screen shot of the gschem application (click for larger view).

gschem2pcb

gschem2pcb is a fairly simple bourne shell script. It takes one argument, a schematic file produced by gschem, and creates a netlist and PCB file. The netlist file contains the names of all the nets and the electronic parts those nets connect. The PCB file generated is a listing of all electronic parts. Both the netlist and PCB file can be imported into the program called PCB. This means that the majority of the work for most projects is done in gschem, and PCB only deals with the actual physical layout of the parts and copper traces.

PCB: Detangle the rat's nest.

Finally, we have reached the last step in our electronic design automation software flow. PCB is a rather confusing name in this case, as it can mean either the open source software package for laying out a circuit board, or the circuit board itself. By the time we get to PCB, we can forget about all the logical connections, and why certain parts connect to each other. At this point, the focus is on pure geometry, kind of like connect-the-dots.

After importing the parts list and netlist generated by gschem2pcb, we press a key and get what's called a "rat's nest." PCB displays the connections that need to be made to each component based on the netlist information. It's our job to rearrange each of those connections in such a way that components and copper traces do not overlap. This can be a real art, and it's something that human brains do well. I find it quite relaxing on simple boards such as this one. Note that while attempting to detangle the rat's nest, it's perfectly fine to change components' orientations.


Screen shot from PCB (click for larger view).

When the circuit layout in pcb is complete, you can generate a gerber file of the circuit board to send to any commercial board shop for fabrication. But if you're feeling crafty, cheap, or in a hurry, you can make a simple one-layer board at home.

6. Compile and burn the code.

I've said it before: making blinking lights takes work. First, you write or adapt the control code, refining it on a simulator. Then you burn it onto the PIC controller. I used three pieces of software to do all of this.

  • gpasm: compile the blinky code
  • gpsim: simulate the PIC microcontroller, for debugging the code
  • picp: burn the code onto the PIC

Below, I've included the assembly code put together for this backpack. This source includes six functions written for the PIC 16F84 microcontroller. These functions do simple pattern manipulations with the lights. The program runs in an infinite loop.

;
; EL Ring Bag display code 
;
        list	p=p16f84
        radix	hex
	include "p16f84.inc"

;
; high speed 20mhz osc
; disable watchdog timer
;
	__config _HS_OSC & _WDT_OFF       

#define	page0 bcf STATUS,5
#define	page1 bsf STATUS,5

count	equ 0x0c	; counter storage
ncount	equ 0x0d	; count down storage register
mcount	equ 0x0e	; count down storage register
ocount	equ 0x0f	; count down storage register
shift	equ 0x24	; temporary pattern register	
w	equ 0		; working register flag
f	equ 1		; file register flag
c	equ 0		; carry flag

	org 0		 ; reset vector
	call 5		 ; call start of program
       	org 4		 ; interrupt vector
	call 5		 ; call start of program
       	org 5		 ; start of program memory

       	clrf PORTA	 ; clear port a data register
       	clrf PORTB	 ; clear port b data register

       	page1		 ; page1

       	clrf TRISA	 ; disable port A inputs
       	clrf TRISB	 ; set all port B as output (clear direction reg)

       	page0		 ; page0

        bcf     STATUS,C        ; disable carry flag
        movlw   b'00000001'     ; initial bit pattern
        movwf   shift           ; store pattern

;
; Clockwise Rotation
;
clockw  movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
 	call	pause		; count to 65,000
	clrf	PORTB		; all EL off
        rlf	shift,f		; next EL on
	btfss	STATUS,0	; test carry flag
	goto	clockw		; re-run until carry flag set

;
; Setup bit for reverse function
;
revs	movlw   b'10000000'     ; initial bit pattern
        movwf   shift           ; store pattern

;
; Counter Clockwise Rotation
;
reverse	movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,000
	clrf	PORTB		; all EL off
        rrf	shift,f		; start from highest bit in portb
	btfss	STATUS,0	; test carry flag
	goto	reverse		; re-run until carry flag set
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,000
	clrf	PORTB		; all EL off

;
; Setup bit for skipen function
;
skipse 	movlw   b'00000001'     ; initial bit pattern
        movwf   shift           ; store pattern

;
; Rotate every even bit including zero in portb
;
skipen	movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off
	rlf	shift,f 	; skipping a wire with two instructions (1)
	rlf	shift,f 	; skipping a wire with two instructions (2)
	btfss	STATUS,0	; test carry flag
	goto	skipen		; re-run until carry flag set
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off

;
; Rotate every odd bit including zero in portb
;
skipod	movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
 	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off
	rlf	shift,f 	; skipping a wire with two instructions (1)
	rlf	shift,f 	; skipping a wire with two instructions (2)
	btfss	STATUS,0	; test carry flag
	goto	skipod		; re-run until carry flag set
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off

;
; Initialize across bit
;
acrossi	movlw   b'00010001'     ; initial bit pattern
        movwf   shift           ; store pattern
;
; Flash each piece of EL directly across from each other
;
across	movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off 
	rlf	shift,f 	; skipping a wire with two instructions (2)
	btfss	STATUS,0	; test carry flag
	goto	across		; re-run until carry flag set
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off

;
; flash setup
;
flashs	movlw   b'01010101'     ; initial bit pattern
        movwf   shift           ; store pattern

;
; Flash all of each color 
;
flash	movf	shift,w		; puts the contents of shift into W
	movwf	PORTB		; puts the contents of W into portb
  	call	pause		; count to 65,0000
	clrf	PORTB		; all EL off 
	rlf	shift,f 	; skipping a wire with two instructions (2)
	btfss	STATUS,0	; test carry flag
	goto	flash		; re-run until carry flag set
	goto	clockw		; back to the first function

pause	movlw	0xff 
	movwf	mcount
loadn	movlw	0xff
	movwf	ncount
deco	nop
	nop
	nop
	nop
	nop
	decfsz	ocount,f
	goto	deco
	decfsz	mcount,f
	goto	loadn
	return
end

gpasm

gpasm is a assembler provided with the gputils package, and you can use it to assemble your source code (like the code provided above), under Mac OS X.

Here's an example command to compile assembly code:

gpasm glowbag.asm

This will produce three new files:

  • glowbag.hex
  • glowbag.cod
  • glowbag.lst

glowbag.hex is the file you'll need to burn onto to the PIC microcontroller, and you'll use glow-bag.cod for simulation testing.

gpsim

gpsim has the ability to simulate a PIC microcontroller under Mac OS X. This functionality saved me a great deal of time on this project. Otherwise, I would have to physically burn a ROM, and put it back into a socket to test each code change--a rather time-consuming process, especially considering how easy it is to bend microcontroller pins.

Here's an example command to start the simulator:

gpsim -s glowbag.cod


Using gpsim (click for larger view).

picp

The gpasm command gave us a hex file. After dealing with the bugs in simulation, it's time to finally make the microcontroller useful. This is a simple process of connecting the PIC programmer to your computer directly via serial or USB-to-serial adapter, and then using a program like picp to copy the hex file over to the microcontroller.

Here's an example command to copy a hexfile to PIC microcontroller:

picp /dev/tty.USA19QW1P1.1 16f84 -wp glowbag.hex

7. Fabricate the circuit board.

Designing a PCB in software is one thing, but to make a circuit board we can actually carry with us in the physical world requires more work. Here's how I made a circuit board at home within a few hours, using easily obtained, inexpensive chemicals and parts. I generally recommend sending out to have boards made, but it's a fun exercise to try this fabrication process yourself.

You need to print the bottom layer, copper portion of the circuit we created with the open source PCB software. PCB knows how to generate both postscript and encapsulated postscript. I used ps2pdf on Mac OS X and printed my design from the Preview program. If I had a laser printer, I could have printed directly onto the Press-N-Peel toner transfer film. Unfortunately, I only have an inkjet, so I found a nearby photocopier and used this to transfer the circuit design from my inkjet printout onto the toner transfer film.

Now you can use the toner transfer film to transfer the artwork onto a blank PCB, which is piece of fiberglass covered with copper on one side.


Using the toner transfer film.

I use a hot household iron with a piece of white paper between the bottom of the iron and the toner transfer film. After about ten minutes of firm pressing and frequent movement at low heat, I toss the whole board, along with the toner transfer film, into a plastic container filled with cold water.

Soak the board for ten minutes and slowly remove the Press-N-Peel transfer film.


The design transferred to the board.

Here comes the nasty part. We need to remove all the copper except for our circuit outline. Removing copper can require some pretty nasty chemicals. The easiest one to obtain, ferric chloride, is (oddly enough) one of the worst choices for the environment.

I've been buying powdered ferric chloride and adding water to it in a plastic bin. Soaking the copper board will eat away all the copper in about 15 minutes with very light wiping using a soft sponge. Wear gloves, and try to not spill any, as it stains easily, and metal, in particular, can be easily damaged.

At this point, the bottom copper traces of the circuit are complete. Since this is a single-layer design, we are done with the PCB etching process.

It's a lot easier to solder the components in when there is a silkscreen guide on the topside of the PCB. The silkscreen shows the outline of the parts, as well as their identifying letter/number descriptions (e.g., R1 for resistor 1). To print this info onto the top of the board, you use the same transfer process as above, but you do it on the board's other, non-copper side, and you skip the etching bath. Just go back into PCB, print out the silkscreen layer, and follow steps 1 and 2.

Finally, drill holes in the board (use a drill press), and solder in the components. Done!


Stuffing the completed circuit into the bag.

Conclusion

From concept to completion, this bag took just under twenty-five hours to make.

Photo.
The completed bag.

This may seem like a silly use of one's time, but the DIY skills that I acquired during the process are what's most important, and I can apply the same skills to many electronics projects in the future. For example, I later created a sound-reactive EL wire fabric poster to hang over performing DJs. Another important aspect of the work is that, thanks to open source software, I did it all on my Apple computer. Along the way, I configured these open source tools to fit my needs and got assistance from the knowledgeable open source community. I realize that the average passerby doesn't know that the glowing light pattern on top of my Xbox logo was designed and built using open source, but for those curious enough to ask, I am happy to tell them.