Trains.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Anyone out there using an Arduino for Occupancy Detection?

5069 views
8 replies
1 rating 2 rating 3 rating 4 rating 5 rating
  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Anyone out there using an Arduino for Occupancy Detection?
Posted by RR_Mel on Wednesday, November 30, 2016 10:42 AM

I’m upgrading my signaling system with an Arduino Mega 2560 R3.  I finally have a working sketch of a single target three pin bi-color Red/Yellow/Green LED system.  It wasn’t easy, my better half had to wear ear plugs for several days.
 
At this point I’m kicking around using an Arduino for optical occupancy detection.  The ability to easily change the parameters sounds pretty good to me.
 
I’m not interested in current detection, I went with optical detection a couple of years ago and I’m very happy with its operation.  My thinking is an Arduino would be much easier to adjust timing than individual IR detectors.
 
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    May 2004
  • 7,500 posts
Posted by 7j43k on Wednesday, November 30, 2016 11:56 AM

Well, not using.  Yet.  But:

It's usually easier and cheaper to mess with code rather than hardware.

Well, once you know how to do it, anyway.

A friend and I are working up an interlocking using both current and optical detection. It will be a paired double track crossover.  There will be 4 two head signals.  The logic will be through Arduino.  An especially neat thing is that we expect to add a simple toggle switch so that there is a choice between two kinds of logic for the interlocking:  the realistic and the simple.  Ya just have to throw a toggle.

 

Ed

 

 

  • Member since
    October 2006
  • From: Western, MA
  • 8,571 posts
Posted by richg1998 on Wednesday, November 30, 2016 12:13 PM

You might search the MRH forums for Arduino detection. I have seen some discussions there using the Arduino for different MRR operations.

Rich

If you ever fall over in public, pick yourself up and say “sorry it’s been a while since I inhabited a body.” And just walk away.

  • Member since
    May 2012
  • 602 posts
Posted by NP01 on Thursday, December 1, 2016 2:25 AM

After reading a lot, I decided to use the Digitrax system of current detection (BDL168) and signal driver (SE8C). Logic is on JMRI running on a MacBook air. 

Even with the above "off the shelf" approach, incredible amount  time is needed to wire the signals, blocks and to set up interlocking conditions. 

So, while the sticklers here would like to point out the voltage drop in the current detection and the excitement of custom code on Arduino, I think you can actually achieve something pretty amazing without the hassle by going with an approach that integrates all logic in a computer running JMRI. 

That is my $0.02. 

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Thursday, December 1, 2016 10:29 AM

I run dual mode, more running time using DC than DCC.  I used current detection for over 30 years without any problems, Twin-T then Paisley circuits for DC and DCC mode (MRC Prodigy Advance²).  I want occupancy detection of my entire mainline without having to do the wheel resistor mods.  I cut over to optical beams about 5 years ago and haven’t looked back since.  Anything blocking a beam at coupler height trips a detector.  Forget to pickup something after working around a track and it trips a detector.  Another advantage of optical detection is it works without power to the rails.
 
I’m currently using a homebrew IR detection system that detects anything blocking the beams.  I have two sets of 13 detectors for my dual loop mainline,  Two beams are over 10’ long and have never failed, the rest of my beams average about 3½’.  
 
I’m looking at using an Arduino with the existing IR sensors to drive my 16 block Arduino driven signal system.  My thinking is that the Arduino will be easier to adjust the timing from the individual detectors than tweaking each one.  I like to have an adjustable release delay from each block.  I also use the block detection for advance detection for my crossing signals and gates.
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    May 2004
  • 7,500 posts
Posted by 7j43k on Thursday, December 1, 2016 11:06 AM

I am very happy using the Free-mo MSS signaling concept which delivers an ABS signal system.  It uses current detection plus optical at each signal.  There is no computer involved, not even Arduino.

It also works easily with single track passing sidings.

When it goes beyond that, one starts getting involved with relays or Arduino.  Or a "real" computer, I s'pose.  Thus my interest in Arduino for my interlocking.  My first approach was with relays, but I ran into an Arduino guy (who KNOWS stuff!) and was impressed with how simple the hardware side was.  And inexpensive.  He's going to write the code, so I can duck that one for awhile, anyway. 

And there's still no central computer.  I AM thinking about CTC.  And then things change.

 

 

Ed

  • Member since
    January 2010
  • 169 posts
Posted by nycmodel on Friday, December 2, 2016 8:55 AM

I am currently setting up an Arduino to realistically handle two grade crossings within two signal blocks on a double track mainline. One crossing is a pair of flashers and the other a pair of crossing gates powered with a stall motor. Since I have many of the original Bruce Chubb Optimized Detectors laying around and some already in use I will be using them to provide the occupancy detection for the Arduino. 6 separate blocks each with an OD providing a logic LOW when a train is detected and a logic HIGH (via internal pullups) when there is no train. The Arduino drives several relays via simple transistor boosters to power the various devices.

                gates_down_1                          flashers_on_1
                |----                                  X
 -----------------| |-----------------------------------| |------------------       signal_block_1 entire length
    west_block_1               mid_block_1                    east_block_1
   
 -----------------| |-----------------------------------| |------------------       signal_block_2 entire length
    west_block_2  ----|        mid_block_2                 X  east_block_2
   
               gates_down_2                           flashers_on_2
              
  All 6 inputs are from Chubb Optimized detectors where HIGH = unoccupied and LOW = occupied
  All 4 outputs will turn on HIGH when the proper inputs are LOW, driving relays via transistors connected to the 12v supply. These relays will then activate crossing gates, flashers and block signals.

  • Member since
    January 2009
  • From: Bakersfield, CA 93308
  • 6,526 posts
Posted by RR_Mel on Friday, December 2, 2016 11:01 AM

Very interesting, keep us posted with your Arduino progress.
 
I went a similar route with my drivers, Randy got me involved with the 7 channel driver chips and they are much easier to assemble as well as a much cleaner circuit board, cheaper than transistors too ($1.46 each).  The UNL2003 is a 7 channel 500ma inverted driver, the TD62304AP is non inverting.
 
 
This is my Arduino MEGA 2560 with my driver shield ready to put in to service.  8 blocks, 8 single target bi color head signals.  Easily expanded to 16 blocks.
 
 
 
 
The Test or Monitoring LEDs are mounted to a dual row 16 pin connector for easy removal.  I arranged the 3 pin 5mm TEST LEDs with the anodes on one side and the red/green on the other side then glued them in place with Amazing Goop.
 
 
Mel
 
Modeling the early to mid 1950s SP in HO scale since 1951
 
My Model Railroad   
 
Bakersfield, California
 
I'm beginning to realize that aging is not for wimps.
 
  • Member since
    June 2009
  • From: QLD, Australia
  • 1,111 posts
Posted by tbdanny on Friday, December 2, 2016 2:06 PM

I'm using optical detection with an arduino to track trains in my staging yard.

The Location: Forests of the Pacific Northwest, Oregon
The Year: 1948
The Scale: On30
The Blog: http://bvlcorr.tumblr.com

Subscriber & Member Login

Login, or register today to interact in our online community, comment on articles, receive our newsletter, manage your account online and more!

Users Online

Search the Community

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT
Model Railroader Newsletter See all
Sign up for our FREE e-newsletter and get model railroad news in your inbox!