A simple and cost effective sensor approach

Post Reply
sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

A simple and cost effective sensor approach

Post by sv1iw » 09.11.2016, 20:01

Based on an idea and software from my friend Laszlo Rozsahegyi (http://forum.rocrail.net/viewtopic.php?f=11&t=10120). When I first started to build my layout I was looking, as everyone else I guess, what would have been the best sensors to use for loco detection. Cost was not an issue but I was looking for something simple and effective. After a lot of research and evaluation of the different methods Laszlo suggested that infra red would have been a good solution as sensors and an Arduino MEGA could support 48 of them (an Arduino UNO will support eight) with a sketch he had wrote. I liked the idea and thought it was worth to try. The boards are coming from E-Bay (China, Hong Long etc), they are small, cheap but they have 2x5mm leds on board, not so easy to mount them on c-track lines. E-Bay to the rescue and I got 3 mm leds instead which could easily installed on the track bed. Two holes of 3mm were opened side by side of the central rail and the leds were mounted under the track. Some glue to secure them in place and Dupon cables (used for arduino connections) were used to connect them with the board which was mounted out of sight and under the layout (see photos at the end of the message).

The little board was secured with a 3mm screw under the layout and the output driven from the infra red led board was guided through a plastic channel on the long sides of the layout at the back, where the Mega is mounted. Since the boards have reverse logic you have to tic the reverse check mark when defining the sensor in Rocrail. So far the system works excellent it is stable and utilized with minimal cost and complexity.
A few words of caution. Do not mount the leds too far apart or the detection may not happen in some locos. Also be aware that if mounted too close you may damage the protective plastic of the central post under the track. The little boards have a small blue potentiometer which controls the sensitivity of the infra red led detection, it will stay stable when adjusted correctly once. The MEGA board is defined as CS2 interface and the virtual serial is taken from the USB port. If you need more info feel free to send me a PM or mail to sv1iw[at]raag.org. I will be glad to help if needed and supply the MEGA sketch.

Keep rocking... Manos SV1IW

Photos
http://sv1iw.ignorelist.com/sensors/PICT7331.JPG
http://sv1iw.ignorelist.com/sensors/PICT7337.JPG
http://sv1iw.ignorelist.com/sensors/PICT7339.JPG
http://sv1iw.ignorelist.com/sensors/PICT7340.JPG
http://sv1iw.ignorelist.com/sensors/PICT7343.JPG
http://sv1iw.ignorelist.com/sensors/PICT7348.JPG
http://sv1iw.ignorelist.com/sensors/PICT7349.JPG
http://sv1iw.ignorelist.com/sensors/PICT7357.JPG
http://sv1iw.ignorelist.com/sensors/PICT7358.JPG
http://sv1iw.ignorelist.com/sensors/PICT7360.JPG
Last edited by sv1iw on 13.11.2016, 00:41, edited 1 time in total.

sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

Re: A simple and cost effective sensor approach

Post by sv1iw » 10.11.2016, 20:34

Some reference to the arduino object avoidance board and the extra infrared leds needed

The boards: http://www.ebay.com/itm/10-X-Infrared-O ... SwgQ9VrfV6

The 3mm sensors http://www.ebay.com/itm/10pairs-3mm-LED ... SwaNBUeC~H

The output pin from the board connects to the arduino digital pin...

Regards Manos SV1IW

sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

Re: A simple and cost effective sensor approach

Post by sv1iw » 12.09.2017, 13:02

A final word. You can add a 10K resistor from pin 5 of the LM555 to ground (or the LM393 chip as ir boards may have one or the other). This will compress and lower the dead band of voltage detection which unmodified is from 1~3V. The detection of loco is a lot smoother.

Regards
Manos Darkadakis
SV1IW

sv1iw
Posts: 46
Joined: 16.09.2014, 21:40

Re: A simple and cost effective sensor approach

Post by sv1iw » 20.08.2018, 15:04

For those who have followed this thread some updated information regarding the use of Infra red sensors.
The sensor I used embedded on my HO layout can be found on E-bay and is a 3 pin one potentiometer sensor.
s-l225.jpg
s-l225.jpg (9.58 KiB) Viewed 120 times
I was lucky to have the lay out on a room facing North so the sun has not really an impact on the ir behavior. Lately I was testing the same sensor in a basic layout in another room facing SE where ambient light was much more and affected ir's behavior. It was almost impossible for the sensor to function correctly during day time. Then I remembered that in the past I had purchase another type of infra red sensor with 4 pins and two potentiometers.
s-l225_2.jpg
s-l225_2.jpg (9.93 KiB) Viewed 120 times
Well this one has a totally different behavior in ambient light and is almost unaffected from sunlight. I suppose it will not work in a garden layout but inside the house is perfectly acceptable. You can see both sensors in the attached pictures. Please also note that in the second sensor I did not test it by replacing and extending the led under the track bed. Also one of them is a 3 pin one and in the first board both led are 2 pin. Still in the tests with the boards "as is" the second one is definitely a winner...

pesitalia
Posts: 2
Joined: 25.11.2018, 20:26

Re: A simple and cost effective sensor approach

Post by pesitalia » 29.11.2018, 16:21

Hi Manos,
Following your instruction, I have just installed an arduino mega with about 40 IR sensors used as 'position sensors' in my layout. I have connected the arduino to rocrail via serial port. Everything is fine except that I cannot find a way to instruct rocrail to automatically query all sensors at startup, in order to view their actual status in the track plan as soon as it opens up. In fact they are all green, as it there was communication between transmitter and receiver , which is not the case for some of them because of a loco actually located between T and R blocking any communication. For your info I have installed the transmitter in the rail plane looking up and the shielded receiver about 10 cm above the plane looking down to avoid any interference from ambient light. If I change status to a sensor by moving the loco away and then return it to its original postion , the relevant sensor on track plan will behave correctly as it will change status from green to red .
At rocrail startup I have tried to launch 'start of day' and 'query sensors' from the top menu but nothing happens; 'sensor monitor' windows is empty until I change status to a sensor, whchi will make it appear immediately in the windows showing its correct status. Can you hepl me on this?
Regards
Carlo Borra

Post Reply

Return to “DIY Hardware”