Build Light – How to build your own Extreme Feedback Device

comSysto is always interested in cutting egde continous delivery technologies as you can read in our previous article “Build Light – Continuous Delivery meets Reengineering an USB driver“. And when a big player in continous delivery like ThoughtWorks is calling for an Extreme Feedback Devices Competition – comSysto must take part in it. ThoughtWorks is currently searching for the best build light and for this competition we decide to connect a real traffic light to our build server. Today we will show how we connect the traffic light to a computer and how you can build your own Extreme Feedback Device.

German Traffic Light

Real Traffic Light

comSysto has developed a tool called Build Light before the competition was announced by ThoughtWorks. Build Light is a small tool that standardize the polling of the build servers  Jenkins and Bamboo with specific build server adapters. Build Light contains the following layers. There is a Build Light Runner on top which starts the application and reads a configuration file which is defined within the build server. The runner opens a thread that is responsible for the continuous polling of the build results. This thread switches the lamps of the traffic light related to the build status. This thread is called ColorSwitcher. At the moment there is one stable and one unstable driver available for Build Light. The stable driver controls the Cleware Traffic Light which is a simple USB traffic light. The Driver is available in Maven Central Repository as well. If you want more information about this driver, we recommend to read the article “Build Light – Continuous Delivery meets Reengineering an USB driver“. Currently we stabilize a driver for the Arduino platform which is used to control the real traffic light and the Ardunio driver will be explained later in this blog post.

Build Light Architecture

Build Light Architecture

Now the question is: How can we connect the traffic light to our computer? Two things must be done. First, we have to develop a hardware that controls lamps of traffic light and second we have to develop a driver that connects the build server status to the corresponding traffic lamps that can be used by Build Light. As none electronical engineers two approaches came to our mind for connecting the traffic light to a computer. Feel free to comment this post if you have easier ideas. The first approach is to use the GPIO-Port of a Raspberry PI. GPIO stands for General-purpose input/output and is a generic pin on an integrated circuit whose behavior can be controlled by the user at run time. This means that you can choose one of the GPIO pins and e.g. switch a relay by setting the output of the pin to a binary high value.

Raspberry PI GPIO Port

Raspberry PI GPIO Port

Another approach is to use the Arduino platform to control the traffic light. An Arduino is a single-board microcontroller which consists of an Atmel 8-bit AVR microcontroller with complementary components to facilitate programming and incorporation into other circuits. The Arduino board is programmed over an RS-232 serial connection, but the way this is implemented varies by hardware version. Most of the Arduino boards use an USB-to-serial bridge which means that an Arduino can be used as a normal USB device. This is a major benefit because the traffic light can be used  on any computer as well as the Raspberry PI while using the CPIO-Ports of a Raspberry PI would bound the traffic light only to the Raspberry PI. Futhermore, the Arduino Uno provides 14 digital I/O pins, six of which can produce pulse-width modulated (PWM) signals, and six analog inputs. You can use the digital I/O pins like the GPIO pin of the Raspberry PI for switching a relay. We decided to use the Arduino plattform for our contol unit because as we have mentioned the Arduino can be used with any computer and this is a major benefit when you can connect the build server only from specific computer and you can’t get a network access for a Raspberry PI.

IMG_1176

Arduino + Relay Shield

The traffic light is a 230V AC device and the Arduino is a 5V DC device which means that there are two electrical circuits. The DC circuit of the Arduino must control the AC circuit of the traffic light. Relays are usually used where it is necessary to control a circuit by a low-power signal with complete electrical isolation between control and controlled circuits.

How to drive relays with an Arduino

Schematic: How to drive Relays with an Arduino

You can see in the schematic which assembly parts are needed to switch a relay with an Arduino. Luckily, you don’t have to build a board on your own. If you google for “Arduino Relay Shield” you will find many preassembled relay shields. These relay shields can easily be plugged to the Arduino with jumper cables like you can see it in the picture above. Arduino and Relay Shield are the parts which we used to assemble our control unit for the traffic light. We have to isolate the power cables of the traffic light and connect them to the relay output pins like you can see in the pictures below. The input pin of a relay have to be connected to the Arduino pins, in our case we choose the first no serial pins and PWM Pins of the Arduino which are pins 2, 4 and 7.

Isolate lamps for the control unit

Isolate lamps of the traffic light for the control unit

IMG_1185

Traffic Light Control Unit

After we have our control unit we can start the development of a driver. Now, we have to write a protocol for the communication between the Arduino and the computer but luckily there is one which is called Firmata. Firmata is a generic protocol and it is intended to work with any host computer software package. The aim of Firmata is to allow people to completely control the Arduino from a host computer. Firmata is delivered with the Arduino SDK.

Standard Firmata

Standard Firmata

We are able to write a generic Arduino driver that can be used for other projects as well. The goal of this driver is that you only have to buy an Arduino and a relay shield and you can use it. What you have to do is to decide which action should be performed by the pins 2, 4 and 7. The green lamp is connected to pin 2 in case of the traffic light. That means pin 2 stands for a passed build. Pin 4 is related to the building state of your build server and pin 7 is related to a failed build.

As soon as the driver is stable, we will inform you in a following post. The Arduino driver will be available in the Maven repository like the  the Cleware driver. Stay tuned for more information and have fun with building your own device. If you want to develop drivers or build server adapters for Build Light do not hesitate to fork the project and make a pull request. We are currently working on a TeamCity Adapter and a GPIO Driver for the Raspberry PI.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s