Model train turn-out problem

Thread Starter

kbirecki

Joined Oct 22, 2009
20
If I understood your last question correctly, the turnout has a single connector with three contacts, and requires a momentary pulse of voltage to be applied to either A & B (shown in my original schematic) to turn one way or B & C to turn the other way. So absence of voltage has no control.
OK. Too bad. It would help save power, and extend the life of your turnout solenoids, if you can figure out how to interface a SPDT switch with the points, many "false switch" requests could be avoided.
I think I understand your thought here now: the idea is to eliminate the solenoid built into the turnout and use a switch which would last longer. Good thought - I'm going to put this in the "future improvements" category (which I have plans for things like train signal lights that change from red to green and back again when the train is allowed to pass certain sections of track, working crossing arms, maybe a miniature control panel like they have for real trains that shows where a train is on the tracks, and other ideas. The biggest long term idea is integration to a computer where I would have an application that controls the train(s).)


NAND Gate/Schmitt trigger: I have some of those, so I can easily do that. I expected I needed to invert my signal somewhere along the way, but I was going to use a hex inverter. I can use the Schmitt trigger NAND. Thanks for the suggestion.
OK, there are very few CMOS IC's that have Schmitt-trigger inputs.
The 4093 is one of them.
The 4106 inverter is another.
For the purpose of my schematic, consider the two interchangeable.

They are both very useful IC's. However, you'll probably find that the 4093 is less expensive. It is also far more useful than the 4106, as it can be used to construct any other logic gate function, whereas the 4106 cannot.
I meant that I have some 4093's. I do also have 4106's.

Just a thought...

Placing the IR emitter/detector pair at an angle across the track would help reduce multiple activations of the switch solenoid due to the gaps between the cars. Otherwise, you'll get the solenoid activating once (or more) each time a car passes.

I've been idly thinking about adding a flip-flop to the circuit. The idea with the flip-flop is that once the solenoid has been actuated in one direction and the 555 timer has expired, the flip-flop is set or reset, and the output of the flip-flop is connected to the RESET input of the 555 timer. This would prevent the same solenoid from actuating again until the other solenoid was actuated, which would reset or set the flip-flop.

Clear as mud?
Not mud, we're headed the same direction. I have already played with that concept of using flip-flops and had planned to incorporate flip-flops to avoid the multiple triggering problem. I have some 4013's that work well. I was originally trying to keep the thread simple, but you have had so many great ideas and suggestions I didn't want to muddy the water with new aspects. The thought was that one flip-flop will trigger one direction on SET and the other direction on RESET.

But I didn't think of placing the sensors at an angle! The gap occurred to me, which is what triggered the idea of the flip-flop.
--------------
Regarding the new ckt ideas:
New stuff: over on the right, a CD4013 D-type flip-flop has been added.
Note that the Clock and Data inputs are grounded.
It's been a while, but I thought when you pulled inputs D and CLK down, they had to be pulled down through resistors, but I see in your diagram they are not, so that is easier.

When the timer's output goes low, the transistor turns off, and the coil pulls the cap high again, which triggers either the SET or RESET input of the 4013.
I understand the concept of the paring and implementation of the 4013, but why are C9/C10 required? If the coil can pull the SET/RESET high, how does the cap help?


[eta]
Off to the far right, you'll see a couple of transistors with 6.2k base resistors, LEDs, and 680 Ohm current limiting resistors. If you make those red and green LEDs, you'll have switch point indicators for your approaches.
...That's almost exactly what I want to do! I'm planning to add Red/Green pairs at the points where the trains can be stopped waiting for the other train to get to it's stop point.

Which leads to another aspect I'm think I'll need to deal with: The state of everything when stopping and starting the whole system. I haven't worked out the logic yet, but initially I was thinking I'd have a master override switch tied into the two stop point sensors on the exchange tracks that prevents the trains from going any further. That way, when I want them to stop, I flip that master switch and wait for the trains to both stop, then power everything down. Then I'll have a known stop/start state, as opposed to being uncertain where the trains may stop and how the switches will act upon powerup. I figured I'd use the master switch idea for now and and cross the bridge to implement more flexibility later.

Due to the 4013 addition, the installation of the IR detector/emitter pair at an angle across the track is no longer suggested; as a matter of fact, it would be best for them to be just barely above the top of the rails. This will ensure that it's tripped a bunch of times due to the passing of the wheels; in case busy little fingers happen to be switching the points the wrong way, the movement of the train past the IR emitter/detector pair will continually switch the points to the correct position, if they are not there already.
I thought the 4013 prevented multiple triggers of the solenoids until the alternate sensor triggered the turnout the opposite direction. In other words, once the RESET on one timer (say U3) is triggered, that timer (U3) won't fire again until the other timer (U5) gets triggered by a train at another point on the track. Can you clarify?

I won't be able to test this ckt until I get a few parts I don't have. But I should be able to test the solenoid activation tomorrow. This is looking very promising!

Thanks,
Ken
 

SgtWookie

Joined Jul 17, 2007
22,230
I think I understand your thought here now: the idea is to eliminate the solenoid built into the turnout and use a switch which would last longer.
Oops - nope!
The switch was to provide positive feedback that the points had indeed changed position when the solenoid was actuated.
I have plans for things like train signal lights that change from red to green and back again when the train is allowed to pass certain sections of track, working crossing arms, maybe a miniature control panel like they have for real trains that shows where a train is on the tracks, and other ideas.
Perhaps you should have a look at Rob Paisley's train circuits page:
http://home.cogeco.ca/~rpaisley4/CircuitIndex.html
Lots of stuff on there. ;)
If you're thinking of computerizing this thing anyway, you might consider starting off using microcontrollers at the switches themselves, instead of using all of these discrete timers and stuff. Microcontrollers (uC's) have gotten to be remarkably cheap, many are available for well under a dollar. While at first they may seem intimidating, and the learning curve is a bit steep, you'd be amazed at what you can do with these little things.

The biggest long term idea is integration to a computer where I would have an application that controls the train(s).)
That's why you should consider uC's.

I meant that I have some 4093's. I do also have 4106's.
Either is fine. :)

Re: IR emitter/detector at angles
Not mud, we're headed the same direction. I have already played with that concept of using flip-flops and had planned to incorporate flip-flops to avoid the multiple triggering problem. I have some 4013's that work well. I was originally trying to keep the thread simple, but you have had so many great ideas and suggestions I didn't want to muddy the water with new aspects. The thought was that one flip-flop will trigger one direction on SET and the other direction on RESET.

But I didn't think of placing the sensors at an angle! The gap occurred to me, which is what triggered the idea of the flip-flop.
Well, I was trying to avoid the solenoid getting energized every time a gap between the cars were seen - but with the new revision, you'd WANT a lot of triggers, just in case someone had manually switched it.
--------------
Regarding the new ckt ideas:

It's been a while, but I thought when you pulled inputs D and CLK down, they had to be pulled down through resistors, but I see in your diagram they are not, so that is easier.
You can use 10k pull-down resistors if you'd like. It's also OK to wire them directly to ground or Vcc/Vdd.


I understand the concept of the paring and implementation of the 4013, but why are C9/C10 required? If the coil can pull the SET/RESET high, how does the cap help?
The cap just allows a single 12v spike to pass through to set or reset the 4013. If it were wire instead, the SET and RESET pins would both be high all the time, which would be a problem.

The resistors on the 4013 side of the caps keep the SET/RESET pins near 0v, the diodes prevent excursions below ground when the transistors first start conducting. When the transistors turn off, the solenoid winding pulls the voltage on the collectors high, and the cap couples that fast-rising edge through to the SET/RESET inputs.

...That's almost exactly what I want to do! I'm planning to add Red/Green pairs at the points where the trains can be stopped waiting for the other train to get to it's stop point.
It's almost like I've done this before, eh? ;)
You can actually power two LEDs from each of those transistors. You'll want one red and one green (with their own current limiting resistors). I don't know if you want LEDs just on the frog sides for the mainline and turnout, or also LEDs for the point side - but I don't see a problem with operating three LEDs. You'd have to reduce the 6.2k resistors on the bases of the transistor drivers somewhat - just don't drop them too much, or the 4013 outputs will start sagging.

Which leads to another aspect I'm think I'll need to deal with: The state of everything when stopping and starting the whole system. I haven't worked out the logic yet, but initially I was thinking I'd have a master override switch tied into the two stop point sensors on the exchange tracks that prevents the trains from going any further. That way, when I want them to stop, I flip that master switch and wait for the trains to both stop, then power everything down. Then I'll have a known stop/start state, as opposed to being uncertain where the trains may stop and how the switches will act upon powerup. I figured I'd use the master switch idea for now and and cross the bridge to implement more flexibility later.
Better to plan for it now, than to build a whole bunch of stuff and wind up scrapping it a few months down the road.
That's another really neat thing about uC's - all of the logic is in the chip. If something's not quite right, you can usually just update the program instead of scrapping the whole project.

I thought the 4013 prevented multiple triggers of the solenoids until the alternate sensor triggered the turnout the opposite direction. In other words, once the RESET on one timer (say U3) is triggered, that timer (U3) won't fire again until the other timer (U5) gets triggered by a train at another point on the track. Can you clarify?
Yes, that's the point of the new modification. Once a 555 timer has completed it's monostable cycle, the 4013 is toggled, which lowers the 555's RSESET line. When the RESET line is held low, the timer is disabled.

Right now though, there is no "preset" on startup. There is no feedback for the 4013 to know which state it should be in, until the switch is manually set once.

I won't be able to test this ckt until I get a few parts I don't have. But I should be able to test the solenoid activation tomorrow. This is looking very promising!
I think you'll have some fun with it.

In the meantime, do you have any interest in microcontrollers?
 

Thread Starter

kbirecki

Joined Oct 22, 2009
20
I took a quick look at Rob Paisley's page - lots of good stuff there. Thanks for the tip, I'll dig in more later.

As for a microcontroller or a computer, yes, I'm interested. For now I do want to go through the process of making these ckts though. I know also there are components that can be purchased to do all of these tasks, but that's not as much fun. For me right now, it's the process of doing this project that is so interesting. I hate to admit it, but I did actually complete a BSEE, but it was 16+ yrs ago, and I never actually worked in the real world with electronics like this at all. I have a knack for comptuers and latched onto the business IT field while in school (it paid the bills) and have been been here ever since. Now, if there is ever anything I could do to help you with PC's, just name it. I owe you big time for all the help you've been giving me.

Regarding the frogs, I think they are insulated. Let's not worry about that part.

I was planning on just using a DPDT replay to control the polarity on two sections of my track that will need to be reversable. From your posts, I now see that is not ideal since the relay coil would have to stay energized. But I'm going to keep the plan for the DPDT for now and improve on that later.

This weekend should be fun!
 

SgtWookie

Joined Jul 17, 2007
22,230
I took a quick look at Rob Paisley's page - lots of good stuff there. Thanks for the tip, I'll dig in more later.
Caveat Emptor on Rob's page - there's lots of interesting stuff, but it's not completely error-free. A few people have had problems with some of the circuits; I don't remember which ones offhand. However, Rob has tried hard to document what he's done, and it's a valuable resource.

As for a microcontroller or a computer, yes, I'm interested. For now I do want to go through the process of making these ckts though. I know also there are components that can be purchased to do all of these tasks, but that's not as much fun. For me right now, it's the process of doing this project that is so interesting. I hate to admit it, but I did actually complete a BSEE, but it was 16+ yrs ago, and I never actually worked in the real world with electronics like this at all.
It'll come back if you work with it for awhile.
I suggest that you download LTSpice from Linear Technology's website. Google is your friend here. It's a great and free tool to model electronics with.

I have a knack for comptuers and latched onto the business IT field while in school (it paid the bills) and have been been here ever since. Now, if there is ever anything I could do to help you with PC's, just name it. I owe you big time for all the help you've been giving me.
An odd coincidence - my computer died this morning. :rolleyes: I'm on the wife's laptop at the moment. It just shut down (as if I told it to), and won't re-boot.

Regarding the frogs, I think they are insulated. Let's not worry about that part.

I was planning on just using a DPDT replay to control the polarity on two sections of my track that will need to be reversable. From your posts, I now see that is not ideal since the relay coil would have to stay energized. But I'm going to keep the plan for the DPDT for now and improve on that later.

This weekend should be fun!
On the polarity issue; the only thing I can think of offhand is to use a low-power relay. An H-bridge might work, but that'll take more noodling.

Oh, by the way - the TIP120s could be replaced with IRLD014 power MOSFETs - these are nifty little 4-pin DIPs that can sink up to 1.7A current.

For sinking current from the LEDs, you could use 2N7000 or 2N7002 MOSFETs; the 2N7000 MOSFeTs come in a TO92 package, so they're easy to work with, and will sink up to around 100mA.

You'll be amazed at what they've done with MOSFETs over the last few years.
 

Thread Starter

kbirecki

Joined Oct 22, 2009
20
Update: back on my computer.
SpinRite isn't cheap, but it's good stuff.
Glad to hear it. SpinRite has saved/recovered many drives for me over the years. If you're familiar with SpinRite, you're not a novice in that arena either. If your computer decided to fritz up on you when reading my msg, that would be unusual for me, because in my ofc I have a reputation for just being near a computer and it starts behaving again. The offer still stands, if you have need of anything IT, lemeno.

After seeing all your drawing in LTSpice, I did see there is a free version and I do plan on checking it out. Much better for modeling than Visio with it's ability to simulate the ckt operation. In college, we only had the old text version - very cumbersome.

The H-bridge idea is cool. I just did a little Googling and found some nice examples of component versions and integrated IC versions. I'm going to put that in the "future improvements" category.

Thanks for the suggestions.
 

SgtWookie

Joined Jul 17, 2007
22,230
Glad to hear it. SpinRite has saved/recovered many drives for me over the years. If you're familiar with SpinRite, you're not a novice in that arena either. If your computer decided to fritz up on you when reading my msg, that would be unusual for me, because in my ofc I have a reputation for just being near a computer and it starts behaving again. The offer still stands, if you have need of anything IT, lemeno.
I'm not a novice with computers, but I'm a tad rusty. Haven't really been keeping up with the technology. I bought my first computer in 1977; a TRS-80 Model I. 1.77MHz of blazing 8-bit powered Z80 might. ;)

I bought SpinRite several years ago when we were going through a rash of HDD failures. Decided to swear off WD drives; went to Seagate, and have been much happier.

After seeing all your drawing in LTSpice, I did see there is a free version and I do plan on checking it out. Much better for modeling than Visio with it's ability to simulate the ckt operation. In college, we only had the old text version - very cumbersome.
SPICE modeling has come a long way, too. In the late 80's at a former employer, we had to log on to a remote mainframe computer that was running the Darmouth time sharing system (DTSS) using a 300 baud modem, and enter the models using a Decwriter LA-120; basically a wide-body hardcopy-only terminal. It was brutal.

Nowadays, you can find SPICE models for just about anything you'd care to model, just slap it in and go.

I've attached the LTSpice source for Train-part3 and an updated Train-part4; simply replaced the two LED driver transistors with 2N7002 MOSFETs. They'll result in less drain on the 12v supply, as once the gates are charged/discharged, there is no more power usage. I left the gate resistor at 6.2k, so just in case the gates of the MOSFETs short to the drain or source terminals, the flip-flop logic will still work - just the LEDs won't function properly.
Download them to your SwitcherCad directory.
Note that you will need the cd4000.lib to display and simulate the 4093 and 4013 devices. It is available on the Yahoo! LTSpice group:
http://tech.groups.yahoo.com/group/LTspice/
Join the group. Lots of help on there.

The H-bridge idea is cool. I just did a little Googling and found some nice examples of component versions and integrated IC versions. I'm going to put that in the "future improvements" category.
The H-bridge suggestion was just one of those half-baked ideas.

A single-pole double-throw relay is the easiest solution. You could use 5v versions, and power them from the ATX 5v supply - for that matter, you could use the 5v or 3.3v supply for the LEDs as well.

Figure each relay will take about 30mA current for the coil, unless you can find something more stingy with current.
 

Attachments

Thread Starter

kbirecki

Joined Oct 22, 2009
20
"Blazing" is right. My first hands on a computer was in a KMart at the Vic 20 display - I was hooked. That was when I had my epiphany that computers were my future. The first I owned was a TI 99/4A.....ahh, the good ol' days.

Thanks for sharing the Spice models. That will give me a good leg up on this project.

Even though I have DPDT relays available, the H-bridge is cool because it's new to me, and maybe a little challenging to get it to work. I'm coming back to that idea!

By the way, I was able to just now test the TIP120 in actuating the turnout and it worked perfectly. I'm on my way! Now I need to put together a parts list of what I don't have to place an order. I wish I still had a local place I could go to get the stuff I need. Everything in the area is either very limited on what they carry, or bad customer service. I don't even have an expensive place to go if I wanted to. There is one electronics store nearby that I stopped going to many years ago, before the Internet really existed, let alone any of the opinion/review sites, because of the grouchy service. I saw an online review recently of that same store having the exact same complaints, maybe about the same woman I dealt with years ago.

I'll let you know how it goes over the next few days as I start prototyping on my breadboard as much as I can until I get the rest of the parts. Thanks!
 

SgtWookie

Joined Jul 17, 2007
22,230
"Blazing" is right. My first hands on a computer was in a KMart at the Vic 20 display - I was hooked. That was when I had my epiphany that computers were my future. The first I owned was a TI 99/4A.....ahh, the good ol' days.
Those were fun times. I spent many hours typing in BASIC programs out of a book, and saving them to cassette tape.

Thanks for sharing the Spice models. That will give me a good leg up on this project.
My pleasure. It's not hard making them thanks to the GUI interface, but there is a learning curve associated with it.

Note that the 555 timer models I used are "idealized" - they're not real-world timers. However, the real thing should work just about like the simulation does, due to how I've used them.

Even though I have DPDT relays available, the H-bridge is cool because it's new to me, and maybe a little challenging to get it to work. I'm coming back to that idea!
I think that an eventual solution lies in the direction of a power opamp, like an L272 or L2722. Those little jewels can be used more or less as a linear H-bridge, and are very cheap. You do lose some voltage across them, but it's not too bad.

By the way, I was able to just now test the TIP120 in actuating the turnout and it worked perfectly. I'm on my way!
Good deal! :D
Now I need to put together a parts list of what I don't have to place an order.
Oddly enough, I don't know offhand how to export a BOM (bill of materials) list from LTSpice. However, you can export a .NET list in various formats for import into various PCB layout tools.

Have to warn you though; some of the parts that are shown on the schematic aren't defined in the library as I've described them; I just chose the closest part or a suitable part and re-labeled it. For example, what I've shown as TIP120s are actually a pair of 2N2222 transistors. The 1N4002 diodes are actually MURS120 diodes.
I wish I still had a local place I could go to get the stuff I need. Everything in the area is either very limited on what they carry, or bad customer service. I don't even have an expensive place to go if I wanted to. There is one electronics store nearby that I stopped going to many years ago, before the Internet really existed, let alone any of the opinion/review sites, because of the grouchy service. I saw an online review recently of that same store having the exact same complaints, maybe about the same woman I dealt with years ago.
Mom & pop type electronic stores are unfortunately fading. Radio Shack used to have a decent selection many years ago, and their employees used to be reasonably knowledgeable about electronics. Nowadays, they have very little in stock, and the only thing the employees know is cell phone payment options. :rolleyes:

Digikey.com is a hobbyist-friendly place to order stuff. No minimum, and you can actually get SMALL orders shipped USPS 1st Class, which can save money.

Mouser.com is another authorized distributor for many manufacturer's products.

Avnet is another, Newark is another.

Jameco.com frequently has deals on stuff.

Electronic Goldmine isn't an authorized distributor, but they have tons of interesting stuff. Easy to go overboard there.
I'll let you know how it goes over the next few days as I start prototyping on my breadboard as much as I can until I get the rest of the parts. Thanks!
Have fun :)
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Well, that was easy enough to figure out - it's in the View menu under Bill of Materials. Just select Clipboard, then run Notepad and paste it in there.

Here's what the BOM list looks like for Train-part4:
Rich (BB code):
--- Bill of Materials ---

Ref.	Mfg.	Part No.	Description
C1	--	--	capacitor, 100nF
C2	--	--	capacitor, 220µF
C3	--	--	capacitor, 10nF
C4	--	--	capacitor, 10nF
C5	--	--	capacitor, 10nF
C6	--	--	capacitor, 10nF
C7	--	--	capacitor, 100nF
C8	--	--	capacitor, 220µF
C9	--	--	capacitor, 10nF
C10	--	--	capacitor, 10nF
D1	--	1N4148	diode
D2	--	MURS120	diode
D3	--	MURS120	diode
D4	--	1N4148	diode
D5	--	1N4148	diode
D6	--	1N4148	diode
D7	--	NSCW100	diode
D8	--	NSCW100	diode
D9	--	1N4148	diode
D10	--	1N4148	diode
L1	--	--	inductor, 1mH, 500mA pk
L2	--	--	inductor, 1mH, 500mA pk
Q1	--	2N2222	bipolar transistor
Q1b	--	2N3904	bipolar transistor
Q2	--	2N2222	bipolar transistor
Q5	--	2N3904	bipolar transistor
R1	--	--	resistor, 1M
R2	--	--	resistor, 10K
R3	--	--	resistor, 10K
R4	--	--	resistor, 330
R5	--	--	resistor, 2.2K
R6	--	--	resistor, 1M
R7	--	--	resistor, 10K
R8	--	--	resistor, 10K
R9	--	--	resistor, 330
R10	--	--	resistor, 2.2K
R11	--	--	resistor, 10K
R12	--	--	resistor, 10K
R13	--	--	resistor, 6.2K
R14	--	--	resistor, 6.2K
R15	--	--	resistor, 680
R16	--	--	resistor, 680
U1	Linear Technology	CD4013B	integrated circuit
U2	Linear Technology	PC817A	integrated circuit
U3	Linear Technology	NE555	integrated circuit
U4	Linear Technology	CD4093B	integrated circuit
U5	Linear Technology	NE555	integrated circuit
U6	Linear Technology	PC817A	integrated circuit
U7	Linear Technology	CD4093B	integrated circuit
U8	Linear Technology	2N7002	integrated circuit
U9	Linear Technology	2N7002	integrated circuit
Note that Q1b and Q5 are actually the input transistors for the 2N2222's with reference designators Q1 and Q2, respectively.
 
Last edited:
Top