Wireless Flex Sensor DMX Lighting Controller
Introduction
This piece was created during the Spring of 2011 as part of Hallways to Harbors, a live performance with site specific movement created in collaboration with choreographer Kenyon Acton. The initial idea was to have a dancer’s movement directly control lighting in the environment around them via sensors embedded in their costume. I decided early on to work with DMX protocol, because it was compatible with modular, reliable, inexpensive commercially available dimmer packs and eliminated the need for me to work directly with 120 volt circuitry. As the project evolved, xBee wireless transceivers became another logical tool to work with, given their (supposed) ease of use and their ability to perform analog to digital (ADC) conversions without additional components.
Parts
Transmitter
Receiver
For assembly
DMX Gear
4 channel DMX dimmer pack
3 pin DMX cable
Note: While 3 pin DMX uses the same XLR connectors as microphone cable, it is different. Microphone cable may work for shorter runs, but because of how the wires are configured and insulated it is more susceptible to interference than cables that are designed to carry data.
Online Resources
DMX
DmxSimple Library - This is the library I used to output a usable DMX signal with Arduino. Very easy to work with.
Tomek Ness'
DMX and Arduino Tutorial - Provides a brief (somewhat hard to follow) explanation of DMX, some sample code, and most importantly a schematic and some explanation on how to connect the DMX driver chip.
xBees
Flex Sensors & Voltage Dividers
Configuring the xBees
One of the first things to do is to configure the xBee modules. I assembled everything before doing this and ended up repeatedly tearing all of my hardware apart to troubleshoot the xBees.
When I ordered the xBees, most of the reviews I had read lead me to believe that they were a fairly straightforward "plug and play" sort of tool. This may be so if you're just using them as a serial line between two microcontrollers, but it was certainly not the case for this application. My confusion was amplified by the fact that many of the tutorials I read were either working with the more advanced series 2 xBees (which have slight differences in how they're configured) or working with the series 1 modules in API mode, which turned out to be unnecessary.
In order to enable the built-in analog to digital converters on the transmitter and change a few other settings, the xBees need to be connected to a computer. I used an FTDI USB to serial adapter along with the xBee explorer in my transmitter for this purpose, but it would be a lot easier to get something like Sparkfun's
xBee Explorer USB which has the USB port, conversion chip, voltage shifters, and header for the xBee all built into a single piece of hardware.
Although the manufacturer of the xBee's provides a special piece of software to configure their modules it only runs in windows, I found it significantly easier to work with a basic terminal program.
CoolTerm worked quite well for me.
Connecting to the xBees
- Connect one of the xBees to the USB explorer or whatever USB to serial device you're using and plug it into your computer. If the explorer has a power light, double check that it's on.
- Open a new terminal window in CoolTerm.
- Click the button at the top of the CoolTerm window to open the options dialog. Set the port to whatever USB port the xBee is connected to. Set the baudrate to 9600 (the default for new xBees) and enable local echo, which will make it so you can see what you type in the terminal.
- Type "+++" into the terminal window and hit enter. This is like saying "Hey, xBee, I'm talking to you." The xBee should reply "OK" on a new line in the terminal window and will continue listening for commands from the serial connection for 3 seconds.
- Before the 3 seconds is up, you can try just typing "AT" and hitting enter to see if the xBee is responding normally. It should reply "OK" again. All configuration commands start with "AT" and the xBee should always reply with an "OK" if everything is working and you are sending valid commands.
- Start configuring the xBees! Just type each of the commands below, followed by a return. Remember, if you wait more than 3 seconds between commands, you will need to type "+++" again or the xBee won't receive the next command you type.
Configuration Commands for the Transmitter xBee (chip antenna)
ATID3333 -Sets PAN ID. It doesn't really matter what the PAN ID is, as long s both modules are the set same.
ATMY2222 -Sets the source address. These should be different between the two xBees
ATCH03 -Sets channel. The 2 xBees need to be on the same channel.
ATD02 -Enables the analog to digital converter on input 0 (pin 20).
ATD12 -Enables the analog to digital converter on input 1 (pin 19).
ATD22 -Enables the analog to digital converter on input 2 (pin 18).
ATD32 -Enables the analog to digital converter on input 3 (pin 17).
ATWR -Saves the changes you just made so the xBee doesn't reset when you disconnect power.
Configuration Commands for the Reciever xBee (external antenna)
ATID3333
ATMY1111
ATCH03
ATWR
For more explanation of these commands the xBee user manual has a very nicely organized glossary of commands in chapter 3.
Assembling the Hardware
Transmitter
1. Prepare the xBee explorer board:
- Solder 10 pins of male header onto the top 10 holes in the left row of holes on the underside of the board. This provides connection to the ADC inputs and the voltage reference pin on the xBee.
- Solder 2 pins of male header to the top 2 holes in the right row of holes on the underside of the board. This provides connection to +3.3V and ground for the lower PCB.
- Solder the leads from your battery pack to the +5V and GND holes on the bottom of the board. I used a female header connection here, but there's really no need to. I also soldered female header to the DIN and DOUT connections to connect to the FTDI chip, but as I've mentioned before, it would be much easier to use a separate piece of hardware for this purpose.
2. Prepare the bottom PCB:
- Measure and cut the blank 15x15 PCB board to fit inside the transmitter enclosure. I also had to file grooves into the side of the board to get it to slide down into the enclosure.
- Using the placement of the header on the explorer as a guide for placement, solder matching female header onto the far right side of the PCB.
- Solder the screw terminals to the far left side of the PCB.
- Connect the appropriate jumpers and resistors for the voltage dividers. See schematic.
3. Prepare the flex sensors:
I found that the sensors were quite flimsy at the connector end, right by the pins. While most of sensor is made with two layers of plastic laminated together, this last 1/4" or so is only a single layer and breaks easily. After soldering on several feet of speaker wire, I ended up taping a small piece of plastic (cut from an orange juice jug) that overlapped with the solder joints on the pins and the bottom 1/2 inch of the sensor and covering everything with a piece of heat-shrink tubing.
4. Assemble everything:
Connect the sensors to the screw terminals, drop the custom PCB into the bottom of the enclosure, plug the xBee explorer in on top of that, and pop the lid on the enclosure. I filed down the edge of the lid just enough so it would close with all of the wires in place but put gentle pressure on them so they couldn't get ripped out from the board.
Reciever
1. Prepare the enclosure:
2. Assemble the protoshield:
3. Put everything together:
Code
I used two very helpful Arduino libraries:
DmxSimple and
NewSoftSerial. Dmx simple provides the ability to output DMX signal to the driver chip using the simple format "DmxSimple.write(channel, value)". NewSoftSerial makes it so the Arduino can communicate with the xBee (a serial device) on pins 2 and 3, while leaving pins 0 and 1 (the only pins that normally support a serial connection) open so the Arduino can still use its USB connection.
The code for this project breaks into three main parts.
- The first part listens for incoming signal from the xBee. When it recognizes a data packet from the xBee, it breaks it down and seperates each of the ADC samples into their own variable, which can be manipulated by the next part of the code. There is also the ability to view the incoming packets and the the variables that the program separates out from them in the serial monitor.
-
Attaching the Costume, Calibrating, & Troubleshooting
The finished product in action
Jim's examples of markup