Track Circuits (Train on Track Indicators.

Post all your model railway electronic problems, solutions and discoverys here.
User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Tue Mar 31, 2020 9:30 pm

fourtytwo wrote:I found the quality issue, it was in color, I have now printed it in monochrome and it seems much better. The original diagram was done over a year ago and either I had run out of color ink or some other reason printed it in monochrome and I eventually figured that was the difference :oops:

Thanks. That makes a world of difference
Anyway if we keep q&a visible anybody else interested can also follow.....I usually look at this site a few times a week but could be more often if things are humming.......

No problem. You're helping me, so it's your rules! :-)
One thing I would recommend is building just one sections worth and trialing/tuning it before constructing more :)

Definitely!
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Wed Apr 01, 2020 9:30 am

Hi Albert

I foresee a potential problem in your application and that is these track circuits are designed to be used in a common return system where the common return is system ground. The first important point is the track circuit bias must always be +24V relative to common return. The OCC signals are also referenced to common return. In my case with floating transformer secondaries and a simple transistor controller there is no issue as each controller has a simple DPCO reversing switch at its output connecting either pole of the controller to common return as required. However in your Arduino based PWM controller if it contains a DPCO reversing switch at it's output the Arduino 0V will not always be at common return potential hence the same Arduino cannot be used to sense or act upon the track circuit OCC signals. Hope this makes sense.
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Wed Apr 01, 2020 11:10 am

fourtytwo wrote:Hi Albert

I foresee a potential problem in your application and that is these track circuits are designed to be used in a common return system where the common return is system ground. The first important point is the track circuit bias must always be +24V relative to common return. The OCC signals are also referenced to common return. In my case with floating transformer secondaries and a simple transistor controller there is no issue as each controller has a simple DPCO reversing switch at its output connecting either pole of the controller to common return as required. However in your Arduino based PWM controller if it contains a DPCO reversing switch at it's output the Arduino 0V will not always be at common return potential hence the same Arduino cannot be used to sense or act upon the track circuit OCC signals. Hope this makes sense.


Hi fourtytwo,

It's been so long since I set up the original version of this project that I forgot to mention that the traction current is not sourced directly from the Arduino. Sorry if this has complicated mattersThe PWM pins drive an L793D which can control a separate power source:
The L293 and L293D are quadruple high-current half-H drivers. The L293 is designed to provide
bidirectional drive currents of up to 1 A at voltages from 4.5 V to 36 V. The L293D is designed to
provide bidirectional drive currents of up to 600-mA at voltages from 4.5 V to 36 V. Both devices are
designed to drive inductive loads such as relays, solenoids, dc and bipolar stepping motors, as well
as other high-current/high-voltage loads in positive-supply applications.


http://www.ti.com/product/L293D

I'm presently using it to provide four uni-directional channels but when I get onto end to end layouts each L293D can provide a pair of bidirectional feeds.

If (big if!) I understand what you have said so far, this should solve the problem because the arduino board power is totally isolated from the final PWM output. I'll need (and have) a total of three wall warts: one (5v) to power the Arduino, one (12v as at present ) for traction power and one (12v again) for the bias voltage.

There are some things on your circuit diagram that I don't think directly concern building the circuit I need:
    The two lines of text starting with 'PULSE'
    The section at bottom left marked 'for Spice test purposes only' (I guess this represents the loco motor)
    the line '.model SW....' at the bottom
    the '.tran... ', '.param...', and 'step param...' lines up at the top'

Practical questions
Does the line marked 'rail' near rhe bottom of the main diagram indicate the layout power rail?
What point on the diagram represents layout the common ground rail?
What point on the diagram goes to an Arduino input pin and what does 'occupied' signal look like?
What point on the diagram goes to Arduino ground?

You may have gathered that I am decades out of practice at reading analogue circuit diagrams. Sorry.

Thanks for all your help so far.
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Wed Apr 01, 2020 3:03 pm

Hi Albert

I have tried to capture your system including the L293's and the power supplies in the diagram below for both the uni & bi directional situations.
If these make sense to you (\/ symbol is 0V) then I will draw just whats inside the Trkckt box.

There are some things on your circuit diagram that I don't think directly concern building the circuit I need:

The two lines of text starting with 'PULSE'
The section at bottom left marked 'for Spice test purposes only' (I guess this represents the loco motor)
the line '.model SW....' at the bottom
the '.tran... ', '.param...', and 'step param...' lines up at the top'

Yes absolutely right, these are things I use to run simulations, next time I will strip them all out just leaving what you need.

Practical questions
Does the line marked 'rail' near rhe bottom of the main diagram indicate the layout power rail? YES
What point on the diagram represents layout the common ground rail? YES
What point on the diagram goes to an Arduino input pin and what does 'occupied' signal look like? 5V signal like the preceding scope shots
What point on the diagram goes to Arduino ground? The \/ symbol

But as I now know more about your system hopefully the system diagram will help.

Albert2-1.png
system diagram


Of course you would ask questions, so would I :?:
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Wed Apr 01, 2020 5:15 pm

Thank you, fourtytwo, for your patienceand forbearance..

You're a gent (probably, given the demographics of railway modelling; but you know what I mean).
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Wed Apr 01, 2020 7:18 pm

Thank you Albert for your kind comments, it is nice to be able to help someone in the same hobby.

I am afraid the 2K2's in the above diagram don't do quite what I had intended as your L293's are never truly off (tri-stated) unless the EN pin is driven low.
Another alternative to provide a small residual current flow is to never allow the PWM's to reach 0% duty cycle but instead set the minimum to something that will maintain an average current of 10mA or so. I can remember using this solution myself many years ago when combining PWM's and this style of track circuit. Sorry to add more complexity!

And now here is what is inside the Track circuit box, just these components, no more no less :) and just 5 connections

Albert2b-1.png
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Thu Apr 02, 2020 2:43 pm

fourtytwo wrote:I am afraid the 2K2's in the above diagram don't do quite what I had intended as your L293's are never truly off (tri-stated) unless the EN pin is driven low.

I'll have a play anyway. I must admit that my understanding of the operation of the L293 is that it is effectively a 'high frequency' relay, so during the low part of the PWM cycle it merely blocks the power current rather than actively dragging it to zero. I could be wrong, though -- plenty of practice at that!
Another alternative to provide a small residual current flow is to never allow the PWM's to reach 0% duty cycle but instead set the minimum to something that will maintain an average current of 10mA or so. I can remember using this solution myself many years ago when combining PWM's and this style of track circuit. Sorry to add more complexity!

No problem. I can easily do this in software.
Could I get away with using an S8050 instead of the 2N3906? I just want to crack on rather than waiting for the postman, as I understand that parcels are travelling slowly at the moment, and I have all the other components in stock
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Thu Apr 02, 2020 6:44 pm

Hi Albert

Could I get away with using an S8050 instead of the 2N3906? I just want to crack on rather than waiting for the postman, as I understand that parcels are travelling slowly at the moment, and I have all the other components in stock


I am sorry Albert, it has to be PNP, all your transistors are NPN, do you see the direction of the arrow in the emitter in the diagram. I said 2N3906 because they are very common but there are plenty of others that would work like BC327, BC557, BC560, 2N4403, PN2907 etc
Whatever you use don't forget to check the pinout, there is no standard so they may be different to what you think.
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Thu Apr 02, 2020 7:58 pm

Hi, fourtytwo.

Oh, well. Thanks anyway. I'll get on with some other stuff.

Stay safe
Albert

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Mon Apr 20, 2020 10:36 pm

Hi, fourtytwo
I'm back! I had to wait for some components and then other bits of life got in the way.

Still trying to understand what goes on.

Some simple (I hope) questions about your diagram of 'Just the inside of the track circuit box, nothing else'. I am concentrating on a uni-directional setup for now

The A input connects to where?

The B input connects to where?

Does the bias supply have to be exactly +24v? (but see below)

Looking at the more general diagram for the 'Uni-directional 4 sections version it appears that A is the direct PWM output of one of the L293 channels and B feeds on to the live rail of the layout. I still don't understand how it works but that will be for the future because I really need to start learning analogue electronics.

If I understand aright this system needs one sensor circuit for each TC block. There is no obvious way to use a single sensor circuit and linking it to each block in turn to take readings. Am I right?

For the bias supply, in an earlier post you said 'The detector needs a bias supply 5-10V higher than the PWM supply voltage'. To start getting my soldering up to scratch again I've built a voltage doubler, but it is somewhat less than 100% efficient.

Thanks for your help so far.
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Thu Apr 23, 2020 4:01 pm

Albert wrote:The A input connects to where?

The B input connects to where?

Hi Albert, sorry for the slow reply, A & B are simply in series between the PWM and track as shown in the system diagram, as the track circuit is bi-directional it doesnt matter which is which.

Albert wrote:Does the bias supply have to be exactly +24v? (but see below)
For the bias supply, in an earlier post you said 'The detector needs a bias supply 5-10V higher than the PWM supply voltage'. To start getting my soldering up to scratch again I've built a voltage doubler, but it is somewhat less than 100% efficient.

The voltage doubler should work a treat, efficiency doesnt matter as the current is extremely low

Albert wrote:If I understand aright this system needs one sensor circuit for each TC block. There is no obvious way to use a single sensor circuit and linking it to each block in turn to take readings. Am I right?


Well it would mean multiplexing all the track sections to a single detector, I guess possible but I think maybe the expense of the relays required would exceed that of the detectors saved, there is also the problem of the detector imposing a small voltage drop (~700mV) that would be noticeable if removed.

I hope all your work is fun, here I am mostly gardening that I enjoy as much as railways but suddenly I find my neighbors also growing veg, one has even dug up a patio and planted potatoes!! Amazing what people turn to when forced to stay at home although sadly none of them have started railway modelling!
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Fri Apr 24, 2020 11:23 pm

Thanks for all the help.

The aim of a multiplexed system is partly to reduce the number of input pins required on the Arduino. I'm currently planning on using 6 blocks on my development track. Using an 8 channel mux needs four pins, rather than six, so not a big saving but my next planned project would have about a dozen blocks, which would still only need five pins with a multiplexed design.

I've just finished rebuilding the bits I'm confident of from my old layout. Next stage will be to start with your design to make sure I understand it. Then I think I can see how to multiplex your circuit by 'splitting' it so that I will only need to build the part on the right, including the 24v bias feed, once and only replicating the left hand part for each PWM power feed. The output of that part going through the multiplexer (a 16 pin DIP, not discrete relays).

Unfortunately, I freely admit to being too ignorant of analogue circuitry to be sure of success. Still, it keeps me busy.

We had put our house up for sale just before the present crisis, so our garden is really just in maintenance mode at present. Still, I have things to keep me busy.

Look after yourself.

Albert
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Sat Apr 25, 2020 9:40 am

Hi Albert

Sorry I thought you meant to multiplex the circuits carrying motor currents, as you say if you are only multiplexing the digital signals then a simple TTL/CMOS chip would do the job.

One problem you might encounter with multiplexing however is the need for a filter in software (see scope shots earlier this thread) the dwell time on a single section would have to be long enough for the filter time-constant, alternatively if you have plenty of memory maintain a filter per section and update each section filter synchronously with the multiplexer.

OMG poor you being caught up in a house sale at this time, that's one thing I should imagine is very hard to progress, I hope the need is not urgent.
Does the pain of N gauge steam ever end!

User avatar
Albert
Posts: 67
Joined: Fri Dec 26, 2014 5:33 pm
Location: Scotland

Re: Track Circuits (Train on Track Indicators.

Postby Albert » Sat Apr 25, 2020 3:15 pm

One problem you might encounter with multiplexing however is the need for a filter in software (see scope shots earlier this thread) the dwell time on a single section would have to be long enough for the filter time-constant, alternatively if you have plenty of memory maintain a filter per section and update each section filter synchronously with the multiplexer.

That went past me without slowing down! Any chance of pointing me at a web page that explains it? Pretty please?

Just to clarify, my aim would be to cycle through reading the TC outputs each at each iteration of the main loop and set a variable in an array for each one

House sales in Scotland are at a standstill because the central registry is shut. Fortunately we are not under pressure to move, but you can imagine it's all a bit unsettling.
Albert

fourtytwo
Posts: 114
Joined: Mon Oct 31, 2016 7:41 pm
Location: Norfolk (Bodecia's country) UK

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Sat Apr 25, 2020 8:54 pm

Albert wrote:
That went past me without slowing down! Any chance of pointing me at a web page that explains it? Pretty please?

Hi Albert very sorry for that, here is a link https://www.cc.gatech.edu/~hadi/teaching/cs3220/doc/debounce.pdf
Just the same as debouncing a switch, in software I usually generate a suitably slow clock (say 25hZ). A common method is to use a short counter, say 4 bit and a status bit holding the last filtered input state, and another holding the last sampled state.
At each sample if input = last input then reset counter, if input not= last input then increment counter, ONLY if counter overflows then update last filtered state = input.
The object is to remove impulse noise, time constant is clock period * max counter counts. Your other control software only ever inspects the last filtered state for information, not the input directly (hope that makes sense, if not please tell me).

Tune for desired result, tradeoff is between worst case impulse noise width and delay from physical change in section state to filtered logical section state change, if it's to long unfortunate things may happen.......SPADS :o or even rear ends :shock:

You could as mentioned in the article burn your fingers :roll: fiddling with capacitors to do it in hardware but I prefer tuning with a keyboard :)

Best regards
Rog
Does the pain of N gauge steam ever end!


Return to “Electronics”

Who is online

Users browsing this forum: No registered users and 9 guests