If you followed my series on setting up a continuous deployment system, then you are familiar with many of the tools we use at Votizen.com to run our deployment system. Once we setup our system, we decided to use a traffic light as one of our monitoring strategies, so the whole team can easily see the status of our system. This is the first article in a two part series, and it will discuss how to connect the traffic light to a phidget SBC. The next article will discuss the software that communicates with the phidget and the Python script we use to drive it.
You will need the following hardware:
- A basic traffic light. We bought ours from TrafficLights.com, the PS3 basic. There are ones that come with sequencers installed, but the phidget will manage the light, so the sequencer is unnecessary.
- A phidget SBC controller with Wi-Fi adapter from phidgets dot com. The Wi-Fi is optional, if you plan on using an ethernet cable instead, but wireless looks cooler. This device provides an easy interface for managing the input signals passed into your traffic light.
- Two phidget 3051 Dual Relay Boards to convert AC voltage into DC voltage.
- Three 3002 60cm sensor cables from TrafficLights.com
- Three L40W traffic signal bulb from Phidgets.com
- One wire connect that can handle at least 4 wires
- Adhesive to attach the boards to your light.
You will probably want:
- A Signal Mounting Arm Set to attach the light to a wall from TrafficLights.com.
Once you have the hardware, all you need is a continuous deployment server (CruiseControl for Votizen), and basic understanding of Python.
When you receive the light, open it up. Each light will have a white wire and a wire the color of the light (red, yellow, green). Additionally, there will be a white wire and red wire coming out of the power supply. Behind the yellow light you will see a board with 5 terminal pairs, attach all three white wires from the lights to the top-left most terminal, and the white wire from the power supply to the top-right most terminal.
Attach the two 3051 Dual Relay Boards to the back of the inside of the traffic light case, near the existing board. There will be four relays, but you will only need three. Next, cut about 25 centimeters from the ends of the green, yellow, and red light wires and set it aside for a moment. The bottom of the dual relays will have two identical paired inputs for connecting wires. In the left side of each relay attach the colored wire coming from the lights. In the right side of the same relay attach the wire that you cut. We attached the green and yellow lights to the same relay, with the green on the right and the yellow on the left. Lastly, with a wire connector, splice the red wire from the power supply together with all three of the recently cut colored wires attached to the relays (bottom of the relays in the pictures below).
Now the relays are properly connected to the lights and to the power supply. The next step is to attach the relays to the phidget SBC (see the top left of the previous two pictures). At the top of the dual relays is one connector for the sensor cable (top right) and another for two wires (top left). Connect the sensor wire from the green/yellow dual relay to the first sensor spot on the phidget SBC and the sensor wire from the red dual relay to the second sensor spot on the phidget SBC. The other connector on the top of the dual relay needs a wire run to the side of the phidget SBC (you will see 10 inputs, positions 0-9, where the input closest to the phidget SBC's power is 0).
Cut the ends from the 3rd sensor cable and used these wires to connect the phidget SBC outputs to the relays. First decide what light colors you want the wire colors to match up with (alternatively you could purchase a red, yellow, and green wire instead using the 3rd sensor cable; also note we did not use the color scheme that I suggest here... we have 2 white wires for some reason). I recommend using the red wire for the red light, the white wire for the yellow light, and the black wire for the green light. Connect the right lead from the yellow/green dual relay to the 0th position on the SBC (this is the green light) and the left lead from the yellow/green dual relay to the 1st position on the SBC (this is the yellow light). Lastly, connect the right lead from the red dual relay to the 2nd position on the SBC.
Now you have all the wires connected to your SBC. Mount your SBC to the back of the traffic light. If you attached everything as described, the inside should look something like:
And the left should look something like:
And the right should look something like:
Once you close everything back up, the final product should look something like:
The exact software implementation for driving the traffic light will be covered in the next article, but here is a short description of how the hardware works. Like most lights, each bulb in the traffic light is either on or off, depending on whether the circuit to the power source is closed or open. The phidget SBC is an easy to program tool that we use as a switch to open and close the circuit to each light (although, it can manage much more complicated sensory inputs and outputs). It has 10 possible boolean output channels, 3 of which have been wired to a light. To turn on a light tell the phidget SBC to open one of the channels connected to a light, closing the circuit. The dual relays convert the AC voltage that comes from the outlet into DC voltage that can be processed by the phidget and back to AC again to be used by the lights.
This article started becoming massive, so I split it into two. Next week, will be a followup article explaining how to install the phidget SBC driver and python client, and the script we use to drive the traffic light.