I am installing a simple non prototype signal sytem using the atlas products.
I started out planning to use BD20. I am now rethinking that as I would need to add a lot of resistors or resistance paint to rolling stock. I am wondering if anybody has experience with Arduino and could tell me if i could build a Detector using arduino and photo cell that would sent a 5 volt signal to my atlas Control board. Basicly I want to replace the BD 20 with photo cells. and if Possibel I would like to have multiple photo cells in a block, so if any one is tripped or covered it would send the 5 volts for that zone.
Thanks
Perry
Yes it is quite easy to do. There are several types of sensors you can use including IR and Photo. Each has it's advantages and disadvantages. The problem with photo sensors is they don't work when you want to do dark running (night time)
Don - Specializing in layout DC->DCC conversions
Modeling C&O transition era and steel industries There's Nothing Like Big Steam!
I built up a 14 block signal controller using a Arduino MEGA and IR optical detection. It has been in and operating for a little over two years and I’m very happy with it.I have several posts on my Blog about signaling. I have tried all kinds of detection systems and I now prefer IR optical over current detection.https://melvineperry.blogspot.com/p/blog-page_49.htmlThe Arduino IR sensors work very good and they are priced right too. Under $1.50 in bulk.https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2047675.m570.l1313&_nkw=IR+Infrared+Obstacle+Avoidance+Sensor+Module&_sacat=0
Good LuckMel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
If I could just mention that Mel's blog is a GOLDMINE of information on just about any topic you might be interested in.
I find myself referring to his posts often when I am starting a new project and looking for guidance.
Now that I am starting on Arduinos I am going to use a bunch of the sketches and wiring examples that he has posted for lighting and other activities.
Thanks Mel for all the work you have put into your blog to make it available to the model railroading community!
charles
AblebakercharlieThanks Mel for all the work you have put into your blog to make it available to the model railroading community!
I'll second that! Mel was the inspiration for me to learn Arduino. I haven't done nearly the complicated stuff Mel has done, but I'm working on it.
Thanks, Mel!
York1 John
Thanks group. I have not been able to access my account. I was locked out when I changed my email. I am not familiar with Blogs. I would like to read more of Mel's stuff. How do Blogs work?
I am an N scale person and one of my concerns in using I/R is drilling between the ties. But was actually looking at I/R. I have started to use the Atlas signal system so all I need is to decide on what type of detection to use. I/R or even Photo cell may be tricky as I have 3/4 ply with 1" foam on top.
Optical sensors for N scale would be difficult because size. The smallest I’ve worked with are a pair of 3mm LED type.You might try a hall effect sensor between the ties and magnets on the rolling stock and locomotives.
https://www.electronics-tutorials.ws/electromagnetism/hall-effect.html
I’ve tinkered around with hall effect sensors and they do work very reliably, the SEN14709 is priced right at about $1. I just found using the pre made IR modules much easier to use as I model HO scale. Size does make a difference. I can easily hide a 3mm sensor or emitter in HO goodies.
All of my across the track IR beams are at coupler height. Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
Tiny optical sensors are indeed available! I use them between the ties (no need to drill at all) on my HO scale layout but they're so small that I expect they could be hidden in N scale track too. They're about 2mm long, 1mm wide, and 1mm thick. IMO an optical sensor between the ties is the best way of detecting a train... They're basically invisible when surrounded by ballast and you can place them anywhere you want.
I was so pleased with these things that I posted about them a while ago but to my dismay no one shared my enthusiasm at that time.... However my previous post may still be of interest in this matter
http://cs.trains.com/mrr/f/744/t/291463.aspx
edit: this is the phototransistor I use, though there are probably others similar as well
http://www.mouser.ca/datasheet/2/143/PT19-21C-L41-TR8-1166191.pdf
My layout is N Scale.
I used photoresistors to work on my signal lights.
I was able to drill small holes in my N scale track. The holes were visible, but were not noticeable.
The downside of the photo sensors is that room light affects the results. I have a south facing window in the layout room, and my adjustments were made for the signals when the sun was out.
The issue was that on a cloudy day, if I happened to cast a shadow on the track, the signals were activated.
I spent a lot of time adjusting the sensors, and got them to a satisfactory level so the ambient light didn't cause too much of a problem.
However, if I build any more signals, I am going to switch to IR sensors.
speedybee Tiny optical sensors are indeed available! I use them between the ties (no need to drill at all) on my HO scale layout but they're so small that I expect they could be hidden in N scale track too. They're about 2mm long, 1mm wide, and 1mm thick. IMO an optical sensor between the ties is the best way of detecting a train... They're basically invisible when surrounded by ballast and you can place them anywhere you want. I was so pleased with these things that I posted about them a while ago but to my dismay no one shared my enthusiasm at that time.... However my previous post may still be of interest in this matter http://cs.trains.com/mrr/f/744/t/291463.aspx edit: this is the phototransistor I use, though there are probably others similar as well http://www.mouser.ca/datasheet/2/143/PT19-21C-L41-TR8-1166191.pdf
What are you using for your light source?Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
Just the ambient room light works fine. Although the sensitivity does peak in the IR range, the sensors work across a wide spectrum, still performing somewhat all the way to UV. I pull them up to 5V with a pull-up resistor and read the voltage on them with the Arduino's analog input, and simply comparing the reading to a threshold value reliably indicates whether the track is blocked or not.
There does need to be some light in the room, but it's ok whether dim or bright
edit: oops hit reply before I was finished typing
I do alot of night running with very little ambient light. They would not work as a direct replacement in the FC-51 module in reflective mode. I ordered some 940nm SMD (0603) emitters and receivers from Digikey. They might be a direct drop in replacement for the FC-51 module.Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
RR_Mel I do alot of night running with very little ambient light. They would not work as a direct replacement in the FC-51 module in reflective mode. I ordered some 940nm SMD (0603) emitters and receivers from Digikey. They might be a direct drop in replacement for the FC-51 module.Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
KEYESTUDIO Infrared PIR Motion Sensor Detector Module for Arduino DIY Project | eBay
This might also suit your needs. One piece. Bury it below the track, pointing upwards, or hide it on the backside of a tower building. It's infrared, so it will work in the dark. They all work on a similar principal. Some just have more bells and whistles like adjustability. You should be able to safely trim back the dome. It acts like a collector lens to measure over a wide angle. As you only care what's going on above the track, you only need the upward lens.Arduino - Motion Sensor | Arduino Tutorial (arduinogetstarted.com)
(1) PIR Motion Sensor with Arduino - YouTube
I’ve looked at the HC-SR501 its super slick but too big for model railroading at a 1” square and both are PIR looking for ambient IR not a pin point source for reflective or break beam detection. The FC-51 works great except for sensor size, the SMD sensors might work and the 0603 size would be perfect.Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California Turned 84 in July, aging is definitely not for wimps.
DigitalGriffinKEYESTUDIO Infrared PIR Motion Sensor Detector Module for Arduino DIY Project | eBay This might also suit your needs. One piece. Bury it below the track, pointing upwards, or hide it on the backside of a tower building. It's infrared, so it will work in the dark. They all work on a similar principal. Some just have more bells and whistles like adjustability. You should be able to safely trim back the dome. It acts like a collector lens to measure over a wide angle. As you only care what's going on above the track, you only need the upward lens.
This might also suit your needs. One piece. Bury it below the track, pointing upwards, or hide it on the backside of a tower building. It's infrared, so it will work in the dark. They all work on a similar principal. Some just have more bells and whistles like adjustability. You should be able to safely trim back the dome. It acts like a collector lens to measure over a wide angle. As you only care what's going on above the track, you only need the upward lens.
have you used this to detect a loco/rolling stock?
my understanding is a PIR sensor actually detects the movement of some IR source across its field. it relies on the heat (IR) of the object such as an animal. i can see how it might detect the heat of a loco, but not sure about rolling stock.
doubt a PIR detector is an inexpensive ($$) as a paired IR emitter/detector. while the emitter requires a series resistor like any other LED, the detector, a transistor can be connected directly between an Arduino digital pin with a pullup resistor and ground
not sure this thread's title, "Block Detector is accurate since it's considering optical dectection which monitor specific locations on a track and not a "block" determined electrically
greg - Philadelphia & Reading / Reading
gregc DigitalGriffin KEYESTUDIO Infrared PIR Motion Sensor Detector Module for Arduino DIY Project | eBay This might also suit your needs. One piece. Bury it below the track, pointing upwards, or hide it on the backside of a tower building. It's infrared, so it will work in the dark. They all work on a similar principal. Some just have more bells and whistles like adjustability. You should be able to safely trim back the dome. It acts like a collector lens to measure over a wide angle. As you only care what's going on above the track, you only need the upward lens. have you used this to detect a loco/rolling stock? my understanding is a PIR sensor actually detects the movement of some IR source across its field. it relies on the heat (IR) of the object such as an animal. i can see how it might detect the heat of a loco, but not sure about rolling stock. doubt a PIR detector is an inexpensive ($$) as a paired IR emitter/detector. while the emitter requires a series resistor like any other LED, the detector, a transistor can be connected directly between an Arduino digital pin with a pullup resistor and ground not sure this thread's title, "Block Detector is accurate since it's considering optical dectection which monitor specific locations on a track and not a "block" determined electrically
DigitalGriffin KEYESTUDIO Infrared PIR Motion Sensor Detector Module for Arduino DIY Project | eBay This might also suit your needs. One piece. Bury it below the track, pointing upwards, or hide it on the backside of a tower building. It's infrared, so it will work in the dark. They all work on a similar principal. Some just have more bells and whistles like adjustability. You should be able to safely trim back the dome. It acts like a collector lens to measure over a wide angle. As you only care what's going on above the track, you only need the upward lens.
But you are right, that deserves some caution. I'll have to try it with a plastic shim to see what happens.
For your entertainment you may view this video showing a wheel counting BOD in action. It is connected to JMRI via MQTT over wifi and is configurable via Bluetooth using any tablet or phone. This requires the use of ESP32 as a controller rather than Arduino. More details and discussion are on the MRH forum under "BOD using axle detection - demo". It's experimental of course but has worked well in testing.
https://youtu.be/XXx7MxsFI0o
George
Edgewood, WA
RR_Mel I do alot of night running with very little ambient light. They would not work as a direct replacement in the FC-51 module in reflective mode.
I do alot of night running with very little ambient light. They would not work as a direct replacement in the FC-51 module in reflective mode.
Fair enough... A single overhead IR source would do the trick, but if your emitter/receiver pairs in reflective mode work, great.
When I tried that a few years ago I found them unreliable. The room at the time had a lot of windows letting sunlight in and tricking the sensors into thinking there is a train there. And on the other hand, some of my rolling stock was a poor reflector of IR, and the detectors didn't see them at all.
Overall, I had better results with a simple single receiver between the rails that is lit by ambient light when the track is clear and cast into darkness when there's a train atop it.
Point is, there's more than one way to skin a figurative cat
Re: the PIR sensor though, I don't see that being a good solution. It's bulkier and more expensive and has no advantage that I can see. And since it's designed to detect motion, what happens when there's a stationary train on it? Won't it incorrectly report that the track is clear?
The trick to make the FC-51 work is tuning the focal point. With the sensors at tie level and the focal point at .4” above the rails they never miss.With the sensors on the board as is they work great from 2” to the side and above.In hidden areas I mounted connectors for vertical position of the board 2” from the out side rail and bent the sensors 90° and again they never miss.Mel My Model Railroad http://melvineperry.blogspot.com/ Bakersfield, California I'm beginning to realize that aging is not for wimps.
speedybeeRe: the PIR sensor though, I don't see that being a good solution. It's bulkier and more expensive and has no advantage that I can see. And since it's designed to detect motion, what happens when there's a stationary train on it? Won't it incorrectly report that the track is clear?
Good point. Not so good on stationary objects.
speedybeeA single overhead IR source would do the trick, but if your emitter/receiver pairs in reflective mode work, great. When I tried that a few years ago I found them unreliable. The room at the time had a lot of windows letting sunlight in and tricking the sensors into thinking there is a train there
When I tried that a few years ago I found them unreliable. The room at the time had a lot of windows letting sunlight in and tricking the sensors into thinking there is a train there
obviously more applicable with hidden trackage