GT Mills
Does anyone have a "latching circuit" diagram for switching power on/off/on to signal lights? 

Purpose:  Model a Michigan C&O, two-light, block signal system.  Here I am keeping the bottom LED constant red, and switching the top 2-color LED  between red and green.

Idea:  Use a latched circuit to switch top LED color. 

Plan:  The train approaches a green/red  block signal, rolls through photoswitch #1 and switches the top green LED to red.  It stays red until the train rolls through photoswitch #2, which switches it back to green.  LED remains green until train rolls through photoswitch #1 again.  

Materials on hand:  10  new Allen-Bradley photoswitches (normal off), 5 ea. diffuse P/N 42SMP-7601 and 5 ea. retroreflective 42SMU-7601. Size 0.5" x 1.125" x 1.125", with adjustable sensitivity.  Diffuse works up to 12" away, reflective works up to 13 ft. away.  These use no external source, IR etc., and they work the same whether in the dark or in bright ambient lighting.  

OK, I got this far ...
IMG_7292.jpgIMG_7293.jpg




Terry Chamberlain jterryc
OK - the only difference from the full Allen-Bradley specification is in the colour-coding of the cable connections.
In the circuit diagram I posted for you simply swap the colours shown for the XR1 and XR2 optosensors- 
Circuit Red = Your cable Brown
Circuit Green =  Your cable Black
Circuit Black = Your cable Blue
Reply 1
GT Mills


You don't have to build those from discrete parts.  Set-reset binaries  come in 2's,  4's and 8's on cheap (a few cents) ) chips going as far back as the 74xx series.  Common, equally cheap, little prototyping  PCBs save 90 % of the wiring up.

BTW, I interpreted the OP as asking for a set pulse signal in one location and a reset pulse signal further down the track  Now we seem to be talking about just toggling at a single position. Could I have some clarification please.

Andy


This sounds interesting, I'd definitely like to do it both ways and learn more  about electronics.  Would you perhaps direct me to  a suitable part?  There's so much out there its easy to get bogged down wading through all the spec sheets.  Thanks!

You understood correctly, I am looking to set-reset the signal using two, or more, discreet detectors, not toggling at a single detector.

<EDITED +1 hour>  Oh, dear,  I've just gone down the rabbit hole of the garage computer building world of the two Steves' 1977 Apple 1.  Oh, well, I suppose it had to happen eventually... 
Reply 1
GT Mills
Greg,

           BistableMultivibrator-Circuit.png
Using such expensive optical switches is probably not how I (or most other model railroaders) would do it, but if you already have the kit then put it to some use !


I tested this using a pair of push button momentary contact switches and the darned thing worked!  First, one - and only one - LED stayed lit after I plugged it in with a 16V DC wall wart.  I laid it out on the breadboard as close as possible to the drawing to make sure I didn't mess up, then messed up anyway, but after a few tries I got it right.  

IMG_7321.jpg

Pushed the opposite button, let go, and the other LED stayed lit...IMG_7318.jpgIMG_7319.jpg


Then I pushed the other button and the other LED went back on...IMG_7320.jpgIMG_7321.jpg

Just for kicks I pushed both buttons...IMG_7317.jpg But letting go again only one LED stayed lit. 

Some strange things happen occasionally to the LEDs, making the wrong one light up in error - probably from loose/poor connections on the bread board.  After hitting the switches again they always go back to the correct position after one or two clicks.  Which is good to know - if they get out of sequence on the layout it appears they will sort themselves out again just fine after a train makes a complete trip around the mainline. 

Funny, but now after doing the hands-on thing I finally understand how/why this circuit works.  That's just how my brain functions I guess. 
Thanks for the help, Terry!  With the substitution of two transistors for the push buttons I'll be in business with the photoswitches 🙂 

I'm still  interested in the logic chips...
Reply 1
Andy Reichert
Here is a handy list of early logic types in most series. 

https://www.chip1stop.com/sp/knowledge/047_general-purpose-logic-ic-function-table_en

E.g. the basic (dual) binary with individual Set/Rest inputs is the XX74. That's 7474 for the original TTL version. You can ignore the "D" input for your purposes.  Search  for "7474 IC"  for details. It should do exactly what your discrete breadboard version. Does - But only use a 5V regulated power supply with a 0.1 uF  cap locally across each  chip power pins

If you need to invert the inputs, you can use a 7404 inverter before the 7474 inputs. Although if you are likely to suffer from "switch bounce" from your photo units, then the 7414 instead  has some built in bounce protection.  And if the photo output is more than 5v, use a pair of resistors to ground like as in the discrete circuit to prevent over voltage damaging the IC inputs.

Hope this helps.  And have fun checking out what all the IC types can do.

Andy
Reply 1
Terry Chamberlain jterryc
Greg,

Good to hear that you are making progress.

While I applaud your interest in looking at the use of ICs, in my opinion - as a retired professional engineer - this is not the application for such an approach. Mixing the 12V supply required for your optical switches with 5V logic chips is courting disaster unless you are very careful in what you do. Just adding a dropper resistor or two will not provide sufficient protection for the ICs - my recommendation is to stick with the discrete transistor approach.
Reply 1
GT Mills
Greg,

Good to hear that you are making progress.

While I applaud your interest in looking at the use of ICs, in my opinion - as a retired professional engineer - this is not the application for such an approach. Mixing the 12V supply required for your optical switches with 5V logic chips is courting disaster unless you are very careful in what you do. Just adding a dropper resistor or two will not provide sufficient protection for the ICs - my recommendation is to stick with the discrete transistor approach.


Agreed, for a few reasons - not the least of which is that I already have all the transistors, photoswitches (which got this project started in the first place after finding them in a storage box a while back), and resistors on hand! 

But I'll  still want to learn more about the logic end of electronics.  Kind of like when I was a fiber optic cable construction contractor (built the world's first "last mile" FOC network in WDC, 1986-1990)  and then years later decided to get into the end equipment stuff, managing data centers (the replacement for the old Bell switch centers) and installing/managing/maintaining whole networks, not just the cable.  Its was big leap, lots to learn, and this is just like that - another thing to figure out.  Which makes it fun and fascinating.  Electronics is about as close to magic as I'll ever get.  

Even this simple little circuit you pointed me to is fascinating.  In fact when I woke up this morning, as I walked by the workbench I couldn't help but start tinkering with different disconnects etc. to see how it affects the transistor switching of the whole thing.  This is my first DIY transistor circuit, you see. 

An old dog looking for new tricks. 
Reply 1
Andy Reichert


Voltage divider portion of the updated transistor example.

voltage dividers.jpg

My apologies. I should have been clearer in suggesting the "pair of resistors". I was referring to the same "voltage divider" additions Terry used as above.

I absolutely agree with Terry's being careful comment about too high input voltages to the 74XX TTL range.  But I would add that, like most transistors, the max volts applied to the transistor base above the emitter (Vbe max)  for a 2N 3904 is  also similarly low to TTL. (6 v instead of 5v for TTL) . So the transistor circuit as shown, is not much better protected than a  TTL one.

Once you get much above a handful of transistors for logic design, IC based circuits typically have a much lower component count  as well as few if any special interconnection issues. So often both faster and cheaper to make up.  To learn more, search under "Logic Design" for starters.

Andy

PS. TTL first appeared in the late 60's - so lots of improved and far more complex stuff has happened since. But I think it's good for learning the basics.
Reply 1
Terry Chamberlain jterryc
Just to be clear, the parameter Andy is referring to is actually the maximum reverse voltage across the base-emitter junction - Veb max, not Vbe max. This is only relevant if there is a possibility that the input voltage to the transistor base can be taken negative with respect to ground. With Greg's optosensors, which do not contain any inductive components, this will not occur.

In normal operation, with positive voltages applied to the transistor base via the resistor dividers (R7-R8 and R9-R10), the transistor itself will limit the maximum voltage at the base to around 0.7V (the base-emitter junction being forward biassed). There is no danger of destructive voltages being applied to any of the transistors.

If I was designing for an absolute worst-case scenario, where negative voltages might be applied to the circuit inputs, I would add a pair of "catching diodes" to each input as shown below -
          Bistable+LEDs+Sensors+Diodes-Cct.png

In normal operation, none of the diodes will conduct since the input transistors Q3 and Q4 hold their base voltages to around 0.7V when switched on (or 0V when not) . If, in the unlikely scenario that the input voltage to either R7 or R9 was taken negative, the diodes will conduct and limit the maximum voltage at the junctions of R7-R8 and R9-R10 to around -1.4V - which is well within the reverse voltage rating of the transistors.

I don't believe Greg needs to add this extra complication to his signalling development.
Reply 2
Andy Reichert

2n3904.jpg

Apologies. My mistake. I misread the spec  on quoting the Veb max value as a positive Vbe max value.  And Terry is definitely correct. Please ignore that part of my earlier post. 

Andy
Reply 1
GT Mills
Hadn't considered reverse currents will occur (Veb) in other circuit designs...anyway, while laying out where the signal lights will go in relation to where the photosensors go, came to realize an important aspect here:  This circuit Terry provided prevents error tripping - getting the signals changing color in the wrong sequence - when a train crosses an interlocking from one mainline to the other, since this design does not change each light like a single on-off-on momentary contact would, but rather switch #1 only lights a set of signals one distinct color, it doesn't change the sequence of switched LED colors. 

I can also include dual manual push button switches at each signal as well to override whatever color is lit.  I'm so 101 here...lol
Reply 1
GT Mills
I found these photoswitches on Ebay for $2.50/ 5 pcs. from China so I bought a set.  They are called out for an Arduino, but I'm sure I can use them as stand-alone 5V units with the transistor circuit Terry provided 🙂  These look like they will be very easy to clip the IR detectors from and put them in really tight spots, and the board is still only 1.25" x 0.5" with potentiometer to adjust sensitivity 1-12", perfect for a block signal system!   I'm thinking about putting my industrial ruggedized, super expensive photoswitches up for sale on Ebay and just going with these little buggers.  Heck, I could undercut all the other new-in-the-bag Bradley sensors currently for sale by half and still buy a brass collector loco or several sound cards for every one I might sell! 

https://www.ebay.com/itm/394220696560

IR Sensors.jpg
Reply 1
Andy Reichert
I've seen some of these with molded black sleeves around the diodes.  Wondering if that may be a necessary addition to prevent cross talk.

Andy
Reply 1
GT Mills
I think the clear LED is a green switching indicator which lights when the circuit is closed.  You're saying you've seen the black IR signal IO sensor device sleeved?  These have a wide 35° field, so putting a sleeve on it might be done to narrow that down...?
Reply 1
Terry Chamberlain jterryc
The clear LED is an infra-red emitter and the black LED is an infra-red receiver.

Before you get rid of your high-cost (and very high quality) Allen-Bradley optosensors I would try these cheap devices on your layout. From my own experience they are not particularly sensitive, have a short detection range, and are greatly influenced by the ambient light level around the layout area - as with everything, you get what you pay for.

If you are looking for a cheap and reliable optical detector then I would highly recommend Geoff Bunza's  Differential Absolute Position Detector (DAPD) details of which you can find here -
https://forum.mrhmag.com/post/sma23-%E2%80%93-a-new-dcc-dc-car-loco-detector-%E2%80%93-differential-absolute-position-detector-dapd-12203476?highlight=bunza%20dapd&pid=1331190049

I use several of these on my own layout in conjunction with a set of conventional block detectors.

Reply 2
Andy Reichert
FWIW, As cheap photo detectors go, I quite liked the Old Radio Shack units.  Not around any more, but IIRC, they had a 10KHz filter so that they would only react to a 10KHz  optical signal and ignore any ambient light below the saturation level.

The other way of reflective detecting is use parallax mounting of the source and receptor in small slightly tubes slightly  angled inward to each other. So the target has to be at the intersection of  of the source beam tube  and the receptor  view tube center lines for the source light to hit the detector .

Andy.
Reply 1
GT Mills
After playing around with the Arduino robotics proximity sensors I see the sage advice regarding the high quality and reliability of the Allen-Bradley industrial photo switches I am lucky to have in the parts drawer.  Big difference.  HUGE.   I can probably make use of the cheaper ones in some spots, but I don't think I'll sell off those expensive A-B units on Ebay after all...
Reply 1
Mark R.
While I thoroughly enjoy circuitry and its capabilities, I'm not very adept at creating.  What I did for my signalling system was rather archaic and what I call pinball logic (reminiscent of the internal workings of old pinball machines) !
 
I used miniature DPDT latching relays to control the signal logic and for activation, I installed reed switches between the rails at locations where activation was required.  To activate the reed switches, every engine has a rare earth magnet attached to the bottom.  In case of an errant activation, I've installed "phone boxes" along the line where the engineer just needs to press down on the pole which presses a switch wired in parallel to the reed switch as a back up.
 
Crude indeed, but it works flawlessly to indicate block occupancy, turnout alignment and in cases heading into hidden staging, if the track is occupied and power is turned on.
 
Mark.
Reply 0
GT Mills
 
Mark R. wrote:
While I thoroughly enjoy circuitry and its capabilities, I'm not very adept at creating.  What I did for my signalling system was rather archaic and what I call pinball logic (reminiscent of the internal workings of old pinball machines) !
 
I used miniature DPDT latching relays to control the signal logic and for activation, I installed reed switches between the rails at locations where activation was required.  To activate the reed switches, every engine has a rare earth magnet attached to the bottom.  In case of an errant activation, I've installed "phone boxes" along the line where the engineer just needs to press down on the pole which presses a switch wired in parallel to the reed switch as a back up.
 
Crude indeed, but it works flawlessly to indicate block occupancy, turnout alignment and in cases heading into hidden staging, if the track is occupied and power is turned on.
 
Mark.
 
Good to hear from someone who likes using this method, I've looked into reed switches for a couple of different projects but haven't tried any yet. 
Reply 0
Ted Becker rail.bird
Did anyone mention the 555 timer chip?  It is a bistable MV at its core and can be used as one.  The outputs will drive way more LEDs than your signals will use.
 
The issue with simple logic circuits like these is not the parts count and cost but the "infrastructure", the mechanical stuff needed to hold all the parts together and connect them electrically.  It could be simpler to put an Arduino NANO on a NANO shield and connect the wires.  It could contain multiple latch functions with the flexibility to have them trigger on rising or falling or any combination of signals.
 
 
Reply 0
GT Mills
Ted:  Yes, thank you, the 555 did come up earlier and I looked at a few different examples of circuits using them.  I think for now the straightforward simplicity of the transistor circuit shown above is the winner for this signaling system so far, and I already all the stuff on hand.  I'll probably buy some 555 chips to play around with anyway, they have a lot of uses.  I do have a  bunch of Arduino Nanos on hand, planning on using them for turnout control with mini servos. 
 
Reply 0
GT Mills
I love MRH Froum!!
 
 Here it is 3 years gone by and I still easily found this thread to refresh the info needed as I get ready to install the photoswitches on the layout finally.  
Reply 1
Andy Reichert
And the 555's have a double version, 556, which makes having a 150 mA output binary a (very inexpensve) doddle.
 
Andy
Reply 1
GT Mills
Fair point, Andy - I hadn't gone as far as to consider the actual connection of Greg's optical sensors. You are quite right in pointing out that they have PNP outputs and they require a power supply of at least 11 volts to operate. The Allen-Bradley data sheet is attached below for your and Greg's information (if he hasn't already got a copy) .

The PNP outputs mean that the output signal is referenced to the positive supply rail rather than to ground so, to connect it to the bistable circuit given previously, requires the addition of a couple of transistors to invert the outputs from the optical sensors. These transistors (Q3 and Q4 in the circuit below) take the place of the two pushbuttons -

Bistable+LEDs+OptoSensors-Cct.png

The circuit now runs from a 12 volt supply, with values of the LED resistors (R5 and R6) adjusted to suit.

When, say, optical sensor XR1 is triggered, its Normally Open output (NO) changes from 0V to +12V, switching transistor Q3 on and bringing its collector and the base of transistor Q1 close to ground. This, as the pushbutton did previously, switches Q1 off - and Q2 is then switched on via the cross-coupling, illuminating LED 2. Similarly, actuating optical sensor XR2 switches Q4 on, Q2 off and Q1 back on - flipping the state of the bistable, extinguishing LED2 and lighting up LED 1.

Hopefully, Greg can try some of this out on his breadboard and see if the circuit works as described.
 
 
Earlier I'd arranged the photo switches and parts onto a breadboard according to Terry Chamberlain's schematic and got everything working as expected. Soldered everything onto a PCB last week and one LED lit up, remained lit, and refused to shut off, while the other LED never came up. Started thinking transistors failure. Looked into 2N3904 transistors info again and it seems that the Vbe is only safe to the reverse voltage max Veb of 6V, and that 0.8V is what is needed to be applied to the base. In this layout, above, tested line Vbe is 12V for Q1 and Q2, whereas base V on Q3 and Q4 it is properly stepped down with resistors to 2.2V.
 
Question: as drawn here, doesn't this fry Q1 and Q2 by applying too much base voltage? So I need to add a series of step-down resistors upstream of base Q1 & Q2, as already done for Q3 & Q4, right?  
Reply 0
Terry Chamberlain jterryc
Question: as drawn here, doesn't this fry Q1 and Q2 by applying too much base voltage? So I need to add a series of step-down resistors upstream of base Q1 & Q2, as already done for Q3 & Q4, right?
Wrong ! - sorry Greg, but your view of how transistors work is incorrect. Transistors are current-driven devices and the current into the base of either Q1 or Q2 is set by the voltage across either R3 or R2, respectively. The current into the base simply forward-biases the base-emitter junction which, just like any diode , will then drop around 0.8 volts across it - almost irrespective of the current flowing into the base of the transistor. When this happens, the transistor conducts and pulls a larger current through its collector via either resistor R1 or R4, and the collector voltage falls to near GND (0V).
 
Transistors Q1 and Q2 are connected as a bistable device - only one of them is conducting at any given time. If Q1 is conducting ("on") then the voltage at its collector will be close to GND (0V) - as will the end of resistor R2 connected to it. Since there is then no voltage across R2, no current flows into the base of Q2, so that Q2 is non-conducting ("off"). Since Q2 is not pulling any current through resistor R4, the voltage at the collector of Q2 rises towards +12V and this voltage across resistor R3 results in a base current into transistor Q1, reinforcing its state as "on".
 
If you then short the base of Q1 to GND, by turning Q3 on (via a current through resistors R7 and R8), Q1 will be turned off, stopping the current drawn through R1 by its collector, so that the voltage at its collector rises and will then turn on Q2 by creating a current into its base through R2. Transistors Q1 and Q2 therefore "flip" states - one on and one off - which is why a bistable device is often called a "flip-flop".
 
If your PCB verion is not working like your breadboard then I suggest that there is an error in its layout - you need to check all of the connections very carefully against the circuit diagram.
 
Let me know if you need anything else explained in more detail.
Reply 0
Reply