📜 ⬆️ ⬇️

Build traffic lights in the office




For a long time I had the idea to visualize build statuses in some simple and effective way. Under the cut, I'll tell you how a real traffic light appeared in my office, how it works and why it is needed at all.


Search for traffic lights.

Finding a traffic light was the most difficult task. I wanted to find exactly the written off traffic light, warm and lamp. As it turned out, there are simply no such traffic lights in Runet. There are several companies specializing in the production of signaling lighting equipment, including traffic lights, but, unfortunately, these are either LED traffic lights or lamp lights (for signaling at car washes or conveyor lines), but not road. The proposals of Russian and Belarusian companies look like this:



In addition, the new traffic light is not cheap. Prices for a three-piece traffic light start at $ 300.

Written off (or stolen) road traffic lights can be found on ebay, the blessing of the sea offers. Classic American and English traffic lights look amazing, but at the expense of the “vintage” console, prices for normal options start at $ 400. Plus, you need to consider the cost of delivering a large and heavy load.



By luck, after a few weeks of searching, I managed to find a way out to people at the traffic police (this is happening in Belarus), who are engaged in the replacement of street traffic lights. Through them, I found out that the lamp traffic light, which has served 15 years, is dismantled and disposed of. Glass lenses go to the cement plant, iron reflectors for scrap metal, plastic shells (yes, they are all plastic for a long time) for recycling. One of these traffic lights still continued its work, only now in a comfortable office.


Subject



The size of the traffic light is determined by the diameter of the lenses. In our country there are traffic lights with lenses of 10, 20 and 30 centimeters, and the latter are more common. Depending on the width of the street and the saturation of the movement choose one or another type. I got the biggest one - the total height of the traffic light exceeds a meter. Driving along the street you do not even notice how huge it is. The size of such a traffic light is the first thing that amazes people in the office. There were suggestions that this is some specially increased version or even a railway traffic light.

The housing and visors of the domestic traffic light produced in the mid-nineties are made of sturdy plastic, 5 millimeters thick. Lenses from colored glass, grooved from the inside, reflectors from iron. In the traffic light, there are 3 separate interchangeable sections, bolted together. Sections can be opened - there are curtains on the left, and unpretentious spring latches on the right. There is no security system against hooligans at such a traffic light, it can be opened with a flick of the wrist. Besides the 60 watt bulbs and wires, there's nothing inside.



I got the traffic light in good condition, not counting a small crack in one of the sections, which judging by the appearance appeared quite recently (possibly during dismantling or transportation). Inside, I was awaited by a mountain of dead insects and layers of stuck road soot, so I had to spend one evening to restore order. In addition, the reflectors noticeably rotted during service, but they cope with their task regularly. I laundered the traffic light, replaced the light bulbs and plugged it directly into an outlet in my kitchen. Here's what happened:




Electronics

To switch the traffic light signals, it was decided to use a 16-channel controller (there is simply no less) MP710 and 4-channel MP701 relay, produced by MASTER KIT . At the heart of the controller chip Attiny45 . It works at a frequency of 20 MHz, has a memory of as much as 4kb. The 16 channels of the controller can be switched in a huge number of modes, such as slow fading, strobe, etc. On the back of the controller there are 16 LEDs, very convenient for debugging code. Initially, a script is loaded into the chip, showing the capabilities of the controller:



All this magnificence can come in handy except for the implementation of the New Year's garland. I think in most projects would be enough just on / off.

From the electronics in my traffic light there is still the usual household voltage regulator. He had to finish the already assembled and installed structure: the light from the traffic light is not very pleasant and hurts the eyes, I want to mute it a little. Now the traffic light works for about one third of its maximum power, that is, somewhere per watt 20. I will say that this is quite enough for its tasks. If desired, you can turn the knob to a larger voltage or turn off the traffic light altogether.

When debugging a relay, it is worth considering that it does not have any fuses, any connection error will become fatal, so you cannot do without a multimeter. Another thing to remember is that the length of the usb wire is limited. It was experimentally found that the resistance of the wire over 13 meters does not allow the signal to pass normally.



On the manufacturer's website, you can download software for controlling the controller for Windows. The program is intended solely for debugging, the interface looks like this:



In addition, it is possible to manage the controller via FTP. The scheme is approximately as follows: on a Windows machine, you have a service running that checks a configuration file on a remote server with a certain period. This option is interesting except for educational purposes, and there is no desire to use it in a real application.

I needed to use only 3 channels of the controller. Using the Libhid library , I wrote 3 very simple scripts, the tasks of each of which included extinguishing all channels and turning on one corresponding to a red, yellow, or green light. Next, I will tell on what principle these same lights turn on.


Logics

The logic of the traffic light is as follows: on Jenkins server, project builds are launched, which are essentially Selenium test suites. Projects about 10, in each order of hundreds of tests. Every minute, krone runs a php script that checks the status of all recent builds. If at least one of the builds fails (at least one test fails), the php script calls a program that includes a red light. If all builds are green, then the light bulb, respectively, lights up green. In the event that a valid response from the Jenkins server does not come (the server is lying or not the Internet, for example), a yellow traffic light comes on. The task of the developers is to check what is wrong if the traffic light is red. That's all the logic :).


Alternatives

The electronic part of the traffic light could be implemented in a different way. When choosing a controller to implement my idea, I was guided by the fact that in the office, in any case, there are computers to which this controller can be connected. Later, experimentally, I was convinced that the idea would not be feasible with the MP710 controller, if the length of the USB wire exceeded 13 meters. Believe me, this is not so much, because the wire from the traffic light does not go directly to the computer (as from an iron to a power outlet), but along the wall and floor / desktop boxes. In addition, in my implementation, the minus is that the user of the computer in which the controller is turned on may restart or simply turn off the machine, in which case the yellow light comes on.


Full independence could be obtained using Arduino + Ethernet Shield .

image

image

Another independent option would be the Raspberry Pi board or any equivalent.

image

Such a solution would be a bit more expensive than the one I chose (if you do not take into account the cost of the computer to which the controller is connected), but there would be complete independence and autonomy. Maybe next time I will.


Cost of

Calculate the objective cost of the entire device is not easy, because most of it is the cost of traffic lights, which can vary depending on your region / tastes / luck. Conventionally, we will take it equal to $ 300, which corresponds to a new traffic light, which is not difficult to find in almost any city.

MP710 Controller$ 30
MP701 Relay$ 17
Wires, USB extensions, box, fasteners, brightness control$ 40
Traffic light$ 300
123Total: $ 387


In my opinion, the solution was effective. I will be glad to answer your questions in the comments.


')

Source: https://habr.com/ru/post/169097/


All Articles