Ultrasonic Train Detection

Moderator: Moderators

Ultrasonic Train Detection

Postby Merdeka » 11.02.2015, 15:35

Hi All,

I've been playing around with a test setup using HC-SR04 ultrasonic sensors for train detection. Common believe seems to be that you can not use this type of sensors because the tracks would interfere. My 3 track test layout has been running for several hours without any problems.

So maybe it is a reliable way of train detection given that the track are spaced apart appropriately.
In my test layout i'm using Marklin C-Track with the standard 77,5 mm spacing. I'm thinking about using it in the fiddle/staging yard and in the hidden areas.

In this setup i'm using an Arduino Leonardo connected to 3 HC-SR04 sensors. The sensors are using one pin per sensor on the Arduino and are debounced 50ms. This Arduino is an i2c slave unit to a master Arduino that handles the conversion to loconet. In my case I went one step further and the master has an ethernet shield to talk to the loconet using UDP multicast. The same idea as the GCA101.

The code is all in beta stage but it does seem to work without any issues.

The sensors are about 0,85 eurocents a piece from China. Add an Arduino Pro Mini for 2,50 and you have slave unit that can talk to at least 10 sensors at the same time. The Master can talk to multiple slaves to it doesn't break the bank :D

Image

Image

Image

Image

https://www.youtube.com/watch?v=AhNFrX2sPCk

Tell me what you think and maybe I can clean up the code a bit so others can use it.

Cheers,

Timo
Last edited by Merdeka on 11.02.2015, 15:57, edited 3 times in total.
Merdeka
 

Re: Ultrasonic Train Detection

Postby Merdeka » 11.02.2015, 15:44

Forgot to mention.

These sensors can measure the distance in cm pretty accurate. Comparable to distance sensors in modern cars.
The distance to the track can be adjusted in software and lower flatbed goods cars can also be detected.

I could add a potmeter to make the adjustment easier but to be honest i'm to lazy atm. And i don't need it. I used a standard ruler to set it up once and it works fine. For me reprogramming the Arduino is faster and easier than using a potmeter.
Merdeka
 

Re: Ultrasonic Train Detection

Postby sv1iw » 23.01.2016, 23:53

Hi Timo
I know is a long time since your post but I was not very frequent on the forum but the last month. I am also surprised that there wasn't any messages as I consider this as a very good idea with just minimum cost. I am about to test a similar way of detection using infra red motion detectors for less 1$ each feeding an arduino mega which will give me 48 sensors on a single board.
I wonder if you can update us on your projext whixh seems very interesting...

Regards Manos
SV1IW
Manos Darkadakis
SV1IW
When all else fails use
"Amateur Radio"
sv1iw
 

Re: Ultrasonic Train Detection

Postby minitreintje » 24.01.2016, 10:40

It's an interesting method :)
I am looking also for a method to detect trains on Märklin C-rails without modifying the rails.


Dylan
minitreintje
 

Re: Ultrasonic Train Detection

Postby eroncelli » 24.01.2016, 11:04

Modifying C tracks is the easiest and cheapest way to get detection in Maerklin system; moreover is "not visible".

Ultrasonic system is a nice application, but very difficult to "dissimulate".
HO Maerklin, CS2+MS2, PC with Win10, Android phone, electronics by IEK, decoder by Maerklin-ESU-TAMS
".. and let your dog enjoy Rocrail"
eroncelli
 

Re: Ultrasonic Train Detection

Postby minitreintje » 25.01.2016, 15:42

I know, however a part of my layout is already done with ballast so I have to break everything down to add some S88 sensors...
This would be the solution for my problem :) Or a Raspberry Pi with some cameras :)


Dylan
minitreintje
 

Re: Ultrasonic Train Detection

Postby rjversluis » 25.01.2016, 15:54

minitreintje wrote:I know, however a part of my layout is already done with ballast so I have to break everything down to add some S88 sensors...
This would be the solution for my problem :) Or a Raspberry Pi with some cameras :)

HAL Sensors? You only need to drill a tiny hole.
Best Regards, Rob.
:!: PS: Do not forget to attach the usual files.
:!: PS: Nicht vergessen die übliche Dateien an zu hängen.
[ macOS - Linux] - [ N: CBus - CAN-GCA ] - [ 0: RocNetNode - GCA-Pi ]
rjversluis
Site Admin
 

Re: Ultrasonic Train Detection

Postby minitreintje » 25.01.2016, 16:00

Then I need to add some magnets under my trains... But it's a good idea.

Dylan
minitreintje
 

Re: Ultrasonic Train Detection

Postby sv1iw » 25.01.2016, 23:31

Dylan try the infrared motion detectors. You need just two small holes in the track bed or mask them with a small bush if you do not want to harm the track bed and you have a cheap and reliable sensor.
http://www.ebay.com/itm/121144698203?_t ... EBIDX%3AIT
Add a small relay if some short of ground isolation is needed...

Regards Manos
SV1IW
Manos Darkadakis
SV1IW
When all else fails use
"Amateur Radio"
sv1iw
 

Re: Ultrasonic Train Detection

Postby minitreintje » 26.01.2016, 10:03

I ordered some PIR and IR-sensors to experiment a little :)

Dylan
minitreintje
 


Return to DIY Hardware