Large Scale Central

A Talking Defect Detector - my latest Arduino Project

Good day - My wife and I have traveled across the country on Amtrak a number of times and I always take along a scanner to monitor the train’s radio communications. The defect detector reports were always of interest.

This inspired me to try my hand at creating one for model railroads. After a few weeks of work I finally have it (mostly) working and thought it might be of interest to some of you.

The detector uses two small lasers and two phototransistors that sit across the track from one another. A passing train breaks the beams allowing the Arduino to compute the train’s speed, length and number of axles. It also has a temperature sensor.

Once a train has passed the Arduino uses a small MP3 player to speak its report just as the real ones do!

I have placed a short video on YouTube here:

http://youtu.be/jQUcPKKRVdA

Photos, code and details of its construction are on my web page here:

http://www.trainelectronics.com/Arduino/DefectDetector/

You will note that the video and web page photos are of an HO implementation but there is no reason that this unit would not work equally well with G-scale. In fact I plan on bringing one along to the ECLSTS in March and to demonstrate it during my seminar.

Please let me know if you have any questions or ideas for enhancements beyond the ones I have listed.

thanks!

dave

Hey dave, I wish you the best of luck. I hope your version fairs better than the one I had worked with an electronics firm in MD to design and produce.

JD - I have already accomplished my primary goal which is to get it to work and to learn more about programming in “C” along the way.

What kind of problem did you run into?

dave

So, I assume you can read the speed, and then with the 2 sensors effectively compute the length of each car?

I guess you can measure the length of the car by measuring the wheelbase, and making the assumption of when you hit a new car, and then can measure the distance between the “adjacent trucks” of the 2 cars and thus add those “pieces” the the wheelbase.

Do you do a little clever stuff to handle steam locos, and/or cars with more than 2 trucks? I’d also guess you have to do that if you are looking just above the rail.

If you were looking “higher” than the trucks/wheels, then flat cars might have an issue.

Be interested in this stuff, but I realize that these algorithms may be part of your “secret sauce” and respect that if you don’t want to go into detail.

Regards, Greg

Greg - the code is on my web page and has no secrets - That is something of the culture of the Arduino - it is an open source device and most folks freely publish their code. In fact, I use lots of other programmer’s routines to get this all to work.

I don’t measure the length of each car but of the entire train - that just involves a computation using the speed and the time that passes between the first and last axle passing. The biggest challenge with those computations is that you are limited to working with integers so I have to multiply stuff by 1000 or 10000 do the computation then divide them back to normal. Not a big deal but something more to deal with!

The sensors are just at the top of the rails so they (usually) ignore anything other than wheels.

dave

thanks Dave, I guess I was thinking of the cool things you could do, like have a running and total car count… Sounds like a neat product.

Regards, Greg

Greg - lots of possibilities! My main objectives were to keep to the real units in terms of what it does… so far so good!

dave

The one I have heard reported the numbers of axles and the number of “hot boxes” (hopefully zero). Its was the one down in Waynesburg PA. I do not know if that is typical of defect detectors, and what they report.

Dave next you will need to “enhance” you defect detector to report dragging equipment. :wink:

David - I considered that - it would be an easy add-on - just put a low laser that shoots between holes in the rails or use a movable barrier between the rails like the big boys do it!

dave

NEAT.

I would be interested in your sketch if you make it available. I can see all types of uses such as coupling/uncoupling on sidings as an example (no voice needed) running two trains on the same track, ect…

Not to sidetrack this great thread, but I have used many of sensor modules designed for the Arduino as stand alone devices. I use the IR reflective sensors to activate a relay that changes the lights on my signal towers. Light sensors to turn on may passenger car lights at night or going through my tunnels. The Hall effect sensors to activate servos in my crossing gates. No Arduino or code. Just supply 5v and use the pin on high to activate a relay.

This is way neat, I’m a big Ardunio/Atmel fan too. Cool stuff Dave, I love this.

Good day, all - I have been working on the software for the Defect Detector and the code has grown from less than 500 lines to well over 1000! This is almost all due to adding menus so that more than a dozen options can be changed from the LCD screen.

You can now individually activate or deactivate each of the reports (like temperature, speed and length) and you can set the mile marker number (000.1 through 999.9), the scale and the probability that defects will be detected.

I currently only allow for one defect report at a time. This report identifies a randomly selected axle in the range of what was counted and a randomly selected North, South, East or West side of the track. For those of you who don’t want all four directions it is simple to rename files so that you only get East & West or North and South.

I tried to break the program up into many, small routines so that others can more easily figure out what is going on. I know that there are much more efficient ways to write this code but what I have done works and is fairly easy to understand.

I have added the new code and a number of photos to my web page here:

http://www.trainelectronics.com/Arduino/DefectDetector/

I plan on adding another video once I finish up a few other things.

The next step is to add a small radio transmitter to the detector so that you actually pick up the report on a scanner, just like the real thing!

Stay tuned!

dave

David Bodnar said:

The next step is to add a small radio transmitter to the detector so that you actually pick up the report on a scanner, just like the real thing!

Stay tuned!

dave

What a cool idea!

Now that is cool! I wonder how I can sell my buddy, with the huge HO layout, this idea. He’ll probably tell me they didn’t exist back then.

Oh goody, so I can have my neighbor hear, on his scanner, that my 17 axle, northbound train, has a hot box on the 26th axle, south side. :wink:

Just kidding Dave. I think all this stuff is interesting., Although my 19th century, narrow gauge railroad, would never even imagine that such technology would ever exist. We are still marveling about the electrick lamp.

It has been great fun to put the whole thing together, gents - adding the radio should be the last major item to check off of the list.

dave

Hey Dave, it’s not on the price list, can you put it there or email me?

You know how I like your stuff!

Greg

Greg - no plans to make this a commercial product right now - it is still under development and I like to see folks build up and learn from doing the Arduino projects themselves. That is why I publish the code and design.

I may put together some kits as I ordered a good number of the circuit boards.

dave

sign me up for the board at least please, that is actually what prompted me, I could do it myself from your excellent instructions, but just very busy making integrated circuits and other goodies for work…

Greg

DefaultNew voice, radio transmitter & menus video


A suggestion was made to use Microsoft’s “text to speech” function for the audio on the defect detector. This has turned out to add more realism to the defect detector. I redid the system with Microsoft’s voice and made a new video. This also includes a demonstration of the setup menus and the radio transmitter.
The new video is here:

YouTube (Short URL)

the original video is here:

YouTube (Short URL)

Details are on my web page here:

http://www.trainelectronics.com/Arduino/DefectDetector/

Enjoy!

dave