Different way to do detection....

crusader27529 Mar 10, 2016

  1. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    IMHO, Model RR train detection is the Holy Grail for the hobbyist, because with effective detection, simple signaling can be accomplished.

    Detection has not progressed much in the last 20 years, and simplistic photocell detection is not the answer. Other methods include current monitoring, but that requires modifying the rolling stock to allow current flow across the rails. Besides the cost of the metal wheels for the cars, unless you modify all the cars, the results are lacking, specifically in the case of a derailment at any level. If you do modify all the cars, the total current that is needed quickly exceeds what most controllers can supply.

    What's needed is a method the detect ALL rolling stock without modification, and be close to 100% reliable in that detection....AND require little changes to the layout to implement.....AND is affordable.

    I present to you the SignalGenie (SG for short).

    It uses quadrature detection....if you really want to understand how it works, look it up. Basically, if 2 sensors are located close to each other, and the THINGS that need to be detected are large enough to cover both sensors at the same time, when that THING crosses the detector, a direction can be determined. That allows us to determine if the THING is entering or exiting a block! All that's needed is something to count the pulses, and either add or subtract from the number of cars in a block to tell if the block is clear. If the number of cars in a block is not zero, the block is occupied. It's as simple as that....negative values are not allowed.

    Initially, I wanted to use two light pipes connected to an IR source in the side of a short dedicated piece of track as detectors, and count the transitions of wheel flanges that went by, but the issues of the light intensity and fragility of the fiber optics didn't work. Also, custom electronics were too expensive. The current design idea is to use enclosures to mount the sensors and detector, and probably have Red/Green signaling as well. Driving the sensors/detector pair would be a Arduino SHIELD with the required electronics. The shield would be available as a completed unit or as a kit, or as a bare PCB. With the cost of Arduino clones from Asia (China mostly), I can't make a clone at cost for what I can buy from Asia. The shields will have no required components on them, and will just be a place to connect to the track-side hardware and the counters. There will be appropriate locations for extra indicators if desired, but they're not required. The track-side hardware will be just the IR emitter, 2 detectors and the basic Red/Green signal components for both the East and West directions.
     
    Last edited: Mar 10, 2016
  2. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    The counter shield will also have no components on it, and is just a place where it connects to the detector modules and a turnout, if the block has one. The UNO will supply enough pins, and the PRO micro will also work.

    The counter needs to be able to respond correctly to inputs from both the East and West detectors, simultaneously. All such communication will include an ACK for reliable communications.

    The most reliable thing to detect would be the rolling stock itself, but the differences in height may cause problems. We need something that's standard on each car and locomotive.....that probably would be the wheels or trucks. Smaller things that may hang that low on a piece of rolling stock, like a glad-hand, wouldn't be large enough to cover both sensors, so it would be ignored. Larger items, like a locomotive with no spacing between the trucks would be counted as 1 transition.

    The counter module connects to a detector from the West and one from the East directions. It also connects to a North direction is a turnout is involved.

    Logically, the SG has inputs from E & W....there are 2 types of modules involved in the process. First there is a detector module which is placed at the boundary on a block. The detector feeds a counter module.

    So, the block detector transitions need to inform BOTH the E & W blocks of the detection. An E movement will CUP the E counter, AND CDN the W counter.

    Thinking about simplistic signaling, in reality all I need to control are the signals facing the block from both directions, and nothing more. These correspond directly to the occupancy status of the block(s).

    So, there will be an IR PCB, a detector PCB and the shield for the Arduino. The signals will also be/have a PCB associated with them.


    How It All Goes Together

    The system consists of 2 major modules, with 3 supporting modules. The major modules are the detector module and the counter/occupancy module.

    Let's start with the detector module.....the detector connects to and supplies the drive for the IR module, and actually generates the IR signal. There is a Sensor module that senses the IR signal, and also connects to the detector module. There are optional signal modules that consist of drivers for red/green LEDs for both EAST & WEST directions. These signal modules would normally be placed at or near the block boundaries for obvious reasons.

    The detector module communicates to the counter modules, both in the EAST or WEST directions whenever an East or West transition is detected. The signals are CUP (count up) and CDN (count down) and ACK (for acknowledge that the counter has received the count). The signals are prefixed by the first letter of the direction, so there's a WCUP for west and ECUP for east. The other signals are WCDN, WACK, ECDN and EACK. This provides for positive communications between the 2 major modules.

    The signal modules just have an input to define the state of the signals, and will show only red or green. They are controlled from the counter module. The counter only controls the signals facing the block entrance.....the signals facing the exit of the blocks are the entry facing signals for the next or previous block, so they're controlled by the next or previous counter module(s).

    The counter module keeps track of the counts in and out of the block from the east and west direction, but also have inputs from a non-east and non-west input called NORTH. This is used when the block contains a turnout. A block may contain only one turnout. Using turnouts requires a switched input from the turnout so the counter can determine the state of the turnout. This state is ONLY used to control signals if the block is unoccupied. If the block is occupied, the state of the approaching signals will be RED without regard to turnout state.

    The counter connects to the detectors at both ends of the block with the CUP, CDN and ACK lines. If there is no block to connect to, both the CUP & CDN signals need to be connected the the ACK input to complete the positive communications link.

    The detector and counter module have locations for LEDs to show the function of the specific modules.....they are completely optional. Both modules have a standard and miniature size. The standard size is designed to connect to the Arduino UNO, and the miniature size is configured for the Arduino PRO. Because of the small size of the PRO version, only the detection LEDs are on the module.

    It's recommended that you use at least one UNO module with all the optional LEDs installed to setup the detector placement, as aligning the sensor and IR modules is important. Operation of the IR and sensor modules requires aligning them. The system is designed to be installed across one track, and the added LEDs allow easy setup by observing the LEDs. The other LEDs show the status of the communications between detector and counter modules, which is most important for correct operation of the entire system.

    Placement of the IR and sensor modules is important both in vertical and horizontal dimensions. These modules should be set so as to detect the wheels or trucks of any cars passing. The height of the rails above the base of the track will vary greatly depending on the layout, and this must be taken into account. IR is different than visible light in the many materials are transparent ti IR. Many plastics, specifically styrene, have properties that allow IR to pass through. This will allow placement of the IR and sensor modules inside structures in many cases.

    The system requires either regulated 5 volts (an old PC power supply works will for this) or a DC input from 7 to 15 volts. 9 volts is optimal, but 12 volts is fine. The lower the voltage, the less heat will be generated by the on-board voltage regulators on the Arduino modules.

    Personally, I would install the detection LEDs on all the modules, because the detection is the most important part for system operation, and can be used to troubleshoot any issues. Also, a digital camera (basic or on a phone) usually can show IR, so that can also be used to troubleshoot.

    If multiple detectors are close to each other, the best way to prevent crosstalk issues is to place the IR modules facing in opposite directions.

    The system requires few components beyond the detector chips and IR source components, and the PCB that connects to the Arduino modules mostly only have convenient places to connect wires.....although most likely the wiring would be a rats nest, you can certainly build your own system.....I will supply HEX files (not source code) for free.

    The primary reason for configuring this as separate Arduino based module is simply the number of pins needed. A MEGA Arduino could be used, but the wiring to this module from multiple detectors and/or counters would rapidly become unmanageable. Also, using simpler modules allow the design to actually be modular, and NOT a custom design, so non-technical users can also use it. Obviously, someone with more technical ability can do whatever they want, so, at least for now, the architecture will remain as is.

    Currently, the detection is functional, but the communications to the counter is still being debugged. I am building PCBs at home (single sided) to finish the debug (rememeber, there's essentially no hardware on the shields), as the debug is NOT hardware related.
     
    vasilis likes this.
  3. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    Interesting. So it's basically an enhanced version of an IR cross-the-tracks break-beam (as opposed to reflective under-the-tracks) system, eh?

    The biggest problem from a modeling perspective that I see is scenery visibility and hiding the sensors. I understand the point about taking advantage of IR-transparent materials like styrene, but ... for example... I have a track with a siding... I want to detect both tracks separately, but the tracks are just over an inch apart center/center, so one side or the other of the emitter/detector set must be in between the tracks, where there is little space to have a sensor and disguise it as something else, especially if it must stand up above the rails. What does that look like?
     
  4. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    The emitter is just a plane-jane IR diode....these things put out an amazing amount of IR energy for their size, and the suggesteted current limiting resistor is like 180 ohms.....to tone down the output, I'm using a 4.7k resistor, and it's still outputting like a firehose.

    I've got to do some more experimenting with the output on the setup....I'm probably going to mout the diode vertically as opposed to horizontal, and completely cover it with opaque black paint, except for a small area on the side of the diode, and see how well that works.

    Right now, I'm building some copper so I can manipulate the prototypes easier.....breadboards are too fragile ellctrically with jumpers and all sorts of temporary connection to use them to do this kind of work.

    So, YES, the system is a major expansion of IR detection that detects reliably, AND determines the direction associated with the detection.

    I gave this idea to Dave Bodner about a year and a half ago, but he couldn't get it to work. I started looking at it again about 2 months ago, and have had excellent success......so far. I don't expect any issues with getting the communications between detector & couter working reliably, but with all the other stuff I need to do with this project, I am moving slower than I'd like.
     
  5. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    The detector looks like a tsop4038.....
     
  6. DCESharkman

    DCESharkman TrainBoard Member

    4,403
    3,067
    87
    Unfortunately, no one detection system can handle all applications. An extension of a prior post is my Barstow staging yard. It has 16 parallel staging tracks, a drill track and a through mainline track. Ad it also has a mirror image of the same trackage and mainline. The only was to do true detection here is by track and car mods or below track opticals.

    The layout matches the southwest in that there is no place to setup any across the tracks in the double main lines.

    The only true way is to have something akin to RFID tags inside the cars, then you could put the RFID reader between the rails and you have it. Very expensive proposition.

    Since I run in the transition era, I have a caboose at the end of all my trains. All my caboose's have a lighting decoder and metal wheels with wipers to power the decoder. At least in this manner of detection, I know where the front of the train is and where the back of the train is. I use this to drive my signalling. So I can move whole trains, but not know which cars are in between the locomotives and the caboose. That is still in the Car Cards.
     
  7. JT58

    JT58 TrainBoard Member

    40
    7
    9
    Coming from someone new to the hobby, I was really surprised RFID wasn't being used for this purpose. Seems a natural fit and not very intrusive.
     
  8. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    RFID chips like those used for pet ID are cheap in quantity, but the detectors are relatively expensive, and it's supposedly really difficult to differentiate between multiple chips that are close together, say like if mounted on HO or smaller rolling stock.

    Block detection is more about determining that there's something in a block as opposed to knowing exactly what's in the block. Occupancy is the name of the game, not necessarilly knowing exactly where everything is, IMHO.
     
  9. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    I've always thought that a railroad signal house would be the best place to put the detectors or IR emitters when multiple parrallel tracks need detection.... in the real world, there's a signal house at many block boundaries. Other ways to hide the system components that need to be above the layout can be used.

    The IR emitter is as small as any 5mm LED, and the detector is a pair of tuned detection ICs that are 6mm wide, 7mm high and 5.6mm deep. The actual dimensions assembled is twice as deep (because the 2 detectors of stacked slightly offset to allow the centerlines of the detectors to be closer together) and less than twice as wide as 2 detectors. So, estimated largest dimension for the detector are 10mm wide, 12mm deep and 7mm high. The current state of electronic parts won't allow less.

    The worst case scenarios are if the detector(s) need to be mounted between tracks, and the previously mentioned signal house (or any other small structure could certainly work to hide the electronics). Otherwise, the detector will be easily hidden.

    Once my prototype PCBs are done, I'll take so photos and you can see the actual sizes.....ALSO, remember that the height required for reliable detection is the height of the centerline of the wheels of a freight car......I'm detecting (and counting) the wheels that cross a block boundary AND I can determine the direction of that transition.

    Hopefully, this methodology will become so popular that layouts will be designed around and issues related to hiding the detectors. Once I put the design into the public domain (I have no idea how to do that!), imaginative modelers may come up with other ways to 'package' the detector.....I thought of laying the detector flat, and just using then side of the lens to gather the IR energy. That'd make thing shorter, but wider.
     
  10. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    In N scale, a 5mm LED is nearly 3 scale in diameter... and the detector would be (roughly) 6 feet by 6feet by 4 feet. The detector could be disguised as a signal box, and the emitter, if between the tracks, could be diguised as or incorporated into a dwarf signal or "defect detector"

    Not saying it can't be done at all, but it would require some creativity. And having either device between tracks is going to force a track separation that is significantly wider than normal.

    All solvable problems.

    As for making it public domain, just share it on a website or on Sourceforge or GitHub or something, and put a Creative Commons or GPL license on it. It's that simple.
     
  11. rrjim1

    rrjim1 TrainBoard Member

    821
    12
    15
    Me and my brother designed and built a signal system for my first N-scale layout back in the 1990s. It used photo transistors with a over head light source. Worked great! He made all the printed circuit board and I made all the three color signals. You had to have the P.T. wide enough so only one would be uncovered at a time. I drilled holes in the board then laid the track so the P.T. would just come up and touch the under side of the ties, they didn't need to be between the ties. The only draw back was you needed a light source right over the Photo Transistors.
     
  12. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    This system is a bit more sophisticated....it detects and counts wheelsets as it passes a block boundary, and can tell the direction of the transition....think about that, and how impossible that is to do with just a simple photo detector.
     
  13. rrjim1

    rrjim1 TrainBoard Member

    821
    12
    15
    No problem detecting direction with photo detectors, can't imagine why one would want to count wheel sets, it might just be a little to sophisticated for most people.
     
    Scott Eric Catalano likes this.
  14. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    Really?? Please explain how you can detect direction with a single photo-detector of any kind.......

    AFAIKT, all that can be determined is that the beam was broken by something......

    I'm waiting for your detailed explanation.
     
  15. GSEC

    GSEC TrainBoard Member

    57
    9
    4
    There seems to be a market glut of RFID chip readers under $10.00 on eBay, Amazon, and other online sources. The readers are, basically, coils of wire with controls; when a chip passes near enough the reader detects it, grabs the information, and then passes it on to whatever device(s) use the information. Biggest problem might be interfaces, but this is digital so probably isn't very difficult or intricate.
     
  16. GSEC

    GSEC TrainBoard Member

    57
    9
    4
    Got to thinking (not a promising start, I know) about this block occupation and direction conundrum. Why count wheels or break beams of light or any other mechanical method? Below is a simple diagram of a purely electrical method that uses the current drawn by a locomotive in an isolated block.

    Use two block detector modules similar to NCE’s BD20. Feed the block at both ends and run one leg of each feed through the sensing coil of its detector module. Modules should be same approximate distance for rail. Outputs from each detector module is fed to a comparator circuit that compares the current draw at each end. Current will be measured in micro amps or smaller units (haven’t done the math), but there will always be a difference except when the loco is at the center of the block. By that time direction will be known and reported.

    Output from the comparator circuit can be used to give almost any kind of indication or control signal that might be wanted. Meter movement to indicate direction, a multiplexer that might have 8 outputs to 8 LED’s to show direction or even to control signaling further down the track, etc.

    I’m a DCC neophyte, but NCE’s BD20 detector used in this example because it appears to be a current transformer and a CT’s secondary outputs a much lower current than its primary and can be used for a variety of functions.

    Question: what functions can be automated by indication of direction within a block?
    BLOCK DETECT DIRECTION.jpg
     
  17. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    I think you're missing the point of knowing the direction as related to detection, at least in my design.

    The ONLY reason I need to determine direction is to keep track of things either entering or leaving a block. If anything enters a block, the block is occupied, and when the total number of thing that have entered a block actually leaves the block, it is unoccupied. I don't care what enters or leaves a block, just the number of things.....

    BTW, I've been in shipping hell waiting for parts from China to build prototypes so I can do a video demonstrating how the system operates. The final parts arrived today, and I'm assemling one set of modules to validate the homemade PCBs that I made. Once done, I'll assemble enough parts for a 3 block demonstrator for the video. My test HO layout is just an oval loop on a 2' X 4' piece of board with all components mounted on the top of the layout for clarity. The layout will show simple signaling and obviously the actual block detection. The layout itself won't be powered, and consist of a small oval where I can move a train around by hand.....that'll show that the detection is independant of power from the rails.

    I've also got to learn how to use some video editing SW and figure out how to host the video.....
     
    ObiJay likes this.
  18. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    So... your circuit is using multiple IR detectors and logic to do what a current-based detector would do (detect block occupancy across a length of track), only without being connected to or dependent upon rail current... which would make it work on non-powered rolling stock without adding resistor-equipped wheelsets...

    I must admit I was struggling a bit to see where you were going, but it's starting to make sense...

    BTW hosting the video is easy... you can put it on YouTube and embed the video here if you like.
     
  19. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    Completely correct, and it allows for turnouts. The biggest PLUS for the way it's configured is that it's affordable! And it will work on DCC or DC layouts.

    The daughter cards that the Arduino PRO Mini plugs into contains no active components, except for completely optional indicators. These PCBs are single sided, so they can be made for minimal cost. The external circuitry consists of two 38KHZ detectors and a completely trivial IR LED. The 38KHZ is generated by the Arduino and requires no adjustment. The detectors sell for about $1.25 from DigiKey. Estimated cost for each block is about $10 using $2 Arduino parts from China.

    I also just started upgrading the design to attempt to do both the detection and block occupancy using only one Arduino module, which would reduce the costs probably by 40%. But first I've got to get this design out the door......
     
  20. crusader27529

    crusader27529 TrainBoard Member

    247
    167
    11
    I've got my protypes completely working, using a $2 Chinese Arduino for the detection logic and another for the signal logic. The project to do both functions on one Arduino hasn't gotten past the initial code combination stage. So, you'll need two Arduino PRO Minis for each block for now. If the combination of the two functions is successful, you'll only need one per block.

    NO detection design for MRR is perfect.....current sensing can be done with all modified rolling stock or with just the loco and last car as current sources, but generally the results either are too sensitive or too power hungry, or expensive to implement.

    My design goals were low cost and easy to implement, BUT not without some design drawbacks. Whether you realized it or not, the only way for a piece of rolling stock to be detected was for it to transition a detector module located at a block boundary. Until then, it was sort of invisible. Once detected, all was fine until power was shut down.....the system would again not know where anything was. The tradeoff was sort-of OK, but not really. You'd have to live with that or never shut the power off, at least to the part of the layout that powered the detection system.

    Well, I've resolved the issue related to the system forgetting the state of the blocks of the layout! Each counter module now remembers the state of the block it's connected to by saving it to EEPROM memory. So, once the system detects rolling stock and/or locomotives, it maintains that count value on a per block basis, whether or not power is shut down or the arduino is reset.

    I'll start doing a demo video to show how the system works, but it's only 3 blocks big, and is just a HO oval. You'll get the idea and understand how the system works, and if interconnected.

    BTW, I had a difficult time troubleshooting the system because of very poorly constructed modules (homemade and with the wrong tools), but you'll be glad to know that the system can be installed and troubleshot if necessary with nothing more than a Harbor Freight DVOM. Of the 10 Arduinos I ordered from China (over several months, all from different suppliers) I only found one with a problem.....and that one only had a problem on one pin. Unfortunately, my design uses just about all the pins, the that unit had to be relegated to another project that didn't use that specific pin.

    Please ask any questions that you wish....
     
    Last edited: Apr 28, 2016

Share This Page