Donner's Daily Dose of Drama

A low-cost traffic monitoring and data collection system

When I grew up in Europe in the 1970s and 1980s, there was a noticable shift in public opinion away from support for traffic-enabling policies towards support for traffic-restricting policies. This manifested itself in numerous construction projects all over the continent with the objective not to build something, but to “unbuild” (Rückbau). Communities began to reclaim space in residential areas from traffic by narrowing streets, adding islands with trees and plants, raising cross walks, adding speed bumps, building bike paths, and introducing and rigorously enforcing lower speed limits.

The term used for this type of road redesign was traffic-calming – “Verkehrsberuhigung”.

Speed limits in areas that were redone in such a fashion were generally 20 mph (30 kph) or less.

Initially, the outcry among drivers and the automobile lobby was enormous. Today, however, in countries like Germany or Austria there is hardly a city or town that has not undergone such sweeping changes and radically altered its character, from very rural villages to big cities like Munich or Vienna. In retrospect, it was a great idea that improved the quality of many people’s lives, and saved many lives in the process. Nobody today would suggest in earnest that going back to the time where car traffic took priority over the safety and well-being of residents, children, bicyclists, and pedestrians would be a good idea.

Alas, 20 years later in most parts of the US, time seems to have stopped in the 1970’s. Here, car traffic still takes priority over other forms of activities that happen on the streets and roadways. Police and public officials are more concerned with enabling traffic than with calming it, because they think that public opinion would not be supportive of anything that slows drivers down.

Such changes are long-overdue, however, and I think that the changes in the American political landscape that are about to happen, or already happening, give reason to hope that the public opinion may be ready for another shift – away from car traffic to more quality of life.

While many of us who are frustrated about a particular traffic situation may still be facing an uphill battle against local officials, local law enforcement, neighbors, and frankly, pretty much everybody else who drives a car – there is something that can be done!

Collecting data such as vehcile count, speed profiles (averages, time-of-day comparions, etc) can and will help to support the case against out-of-control traffic and in favor of measures that will help us reclaim the outdoors from the automobile. The following report illustrates how a system can be built and set up with minimal effort for less than $200 that records traffic and speed data to a computer for further analysis.

Hardware

First, we need a reasonably accurate Doppler Radar device. I went with a Sports Radar SR3600 speed gun that I bought used on Ebay for $130 for 2 reasons – it is small, uses very little power (it can run on battery if necessary), and it has a serial port that we can easily use to connect to a computer.

A small 100 mA power adapter is recommended. The batteries in the SR3600 would not last long, since it will be operating in continuous mode.

We also need a data cable. The SR3600 has an RJ-45 port that looks like an Ethernet jack, but it is in fact a combination of serial port and power feed. We can manufacture a cable that serves as both the data and power cable, which will greatly simplify the deployment of the device.

Sports Radar sells a cable & software kit for the SR3600 for close to $100. The software is outdated and not very flexible. Since I did not know the pin layout of the RJ-45 jack, and this information is only available with the kit, I had to order one. The cable that I received was wired incorrectly and did not work. I sent it back to the manufacturer after discussing the RMA, but never received a working replacement or a refund. Needless to say – I do not recommend the purchase option.

Manufacturing a custom cable for a fraction of the cost is the preferred solution, and more modern software for Microsoft Windows that is better suited for a long-term data logging application is available for free on this site – just keep reading.

In order to connect the SR3600 to a computer’s serial port, we can use a regular (not cross-over) Cat-5 or Cat-5e Ethernet cable with RJ45 connectors on both ends. Then, on the computer side, we will use a modular RJ-45 to 9-pin D-SUB adapter that we can buy on Ebay for less than $1 plus shipping.

The SR3600 has an 8-wire RJ45 connector. Only three of the pins are in use (1,5, and 6). Pins 5 and 6 will be connected to pin 5 and 2 of the serial port, as follows:

   RJ-45    RS232:
+12V  1  < ->   -
GND   6  < ->   5    GND
TX    5  < ->   2    RX

There are 2 options for the power supply. It can either be connected directly to the SR3600’s power connector, or it can be wired into the RJ-45/DB-9 modular adapter so that there is only 1 cable running between the computer and the laser gun, which can be very convenient, depending on the installation location.

If the Cat5 cable is used to carry both power and the serial data signal, the positive (+12V) wire should be connected to pin 1 of the Cat-5 cable. The Ground wire should be connected to the ground pin that is already in use for the serial connection.  Here is a detailed wiring diagram and an overview of the required components.

Cable pin layout
How to connect the SR3600 to a computer

Once the cable is done and confirmed to be working (for instance with the Windows HyperTerminal utility), the SR3600 can be deployed to its permanent location. Mine is aiming out through a basement window on the side of the house. It hits traffic at an angle, which introduced the problem that reported speeds are too low by a factor cos ?. We’ll take care of this in the software.

Cos ?

One limitation of Doppler radar technology is that if the detector is aimed at a moving object from an angle, the speed that is reported is lower than the actual speed. The factor depends on the angle (?) and is defined by its cosine. Obviously, the larger the angle, the greater the deviation (which can be compensated for), but also the greater are potential inaccuracies (which cannot be compensated for).

My software, the SR3500 Manager, reads a calibration factor from the configuration file and applies this factor to all measurements. The correct factor can be determined in two ways – either by measuring the angle and calculating its cosine, or by driving by at a number of different speeds and comparing the driven speed with the recorded speed, then deriving the factor from the difference. The latter is probably more practical and more accurate, because the angle can be difficult to measure.

Software

With the SR3600 set up and connected to a computer, the data logging software can be installed and configured. Here is an architecture overview:

The SportsRadarManager is the device driver that handles serial communication with the SR3600. Client applications can subscribe to the manager and receive a data message every time the SR3600 sends a speed reading.

One such client that is provided is SportsRadarDCS – a Windows data collection service that logs data to a SQL Server database. The service also acts as a WCF (Windows Communication Foundation) host.

All other components in the Visual Studio solution (download link below) are optional.

An experimental WCF client subscribes to the WCS host and gets callbacks every time a value is written to the database.

A web service exposes methods that can be used for statistical reporting on a web site, for instance. An sample web site is also included (SportsRadarWeb). Look at this live site that uses all this stuff – it will help you understand what the components do.

Option 1 – Build from source code (for the programmer)

– You need Visual Studio 2008
– Download this ZIP file with my solution
– Edit property and config files with your database connection, server names, and user names
– Build and run the solution

Option 2 – Binaries (for the lazy programmer)

– Download and install SQL Server Express from Microsoft
– Create the DCS database, tables, and functions with this script
– Install the service with this installation package
– Update the properties file in the installed directory with your database information
– Update the COM port in the properties file if you are not connecting to COM1
– Start the service – data will start to appear in the database.
– If not, check the Windows application log for errors.

Only if there is overwhelming demand will I consider packaging the solution with SQL Express to provide a one-click installation path. Or if someone else wants to volunteer, please contact me.

Exit mobile version