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 » Sat Apr 25, 2020 9:41 pm

Thanks, Rog.
Switch debouncing takes me back to my earliest assembler days!
I'll certainly try the software approach. I'm just concerned that it might add too much overhead to the main loop. I'm not too sure about the capacity of an arduino. Still, I can always go over to hardware if the system gets too sluggish.
Cheers
Albert

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

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Mon Apr 27, 2020 10:57 am

Hi Albert
It's a pleasure. I write all my code for micro-controllers in assembler! guess it comes from when they were truly very small and slow!
So I don't know what sort of Arduino you are using nor what language, also there has been much discussion over the terrible boilerplate code offered by chip vendors supposedly to interface with there hardware, if your using that stuff say goodby to any performance (IMOP).
I am what has become called a bare metal programmer of Microchip PICs for many things, the most recent railway project runs on an old 16F877 @ 10Mhz (2.5Mips) plenty fast enough for filtering. I note from the code each section takes 18 instructions and the "slow clock" is 10mS period and it uses a 3 bit count.
If you do your arithmetic you can work out how many section filters you can afford to run, just need to find that Arduino data sheet and do some instruction counting, fun thing all embedded realtime programmers get into :)

I do use high level languages too, but not for performance microcontroller applications with lots of hardware twiddling!

Regards
Rog
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 » Tue Apr 28, 2020 10:36 am

Hi Rog
My assembler days are far behind me now. At that time I found that for my particular needs software couldn't keep up with the data flow, so I switched to hardware for real-time video digitizing. Nowadays, of course software runs rather faster than Z80 assembler could deliver!. Since then, spending time as a database analyst programmer made me lazy using high level languages.

I'm currently just using the Arduino IDE (based on C/C++ I understand) with a pretty bog standard Arduino UNO and I'm expending enough effort getting to grips with analogue electronics that I don't have spare capacity to start playing with low level programming.

I'm hand rolling all my code in the IDE and not using any external hardware that needs boilerplate code. Just directly pin-bashing.

In a forum for another hobby my screen name is 'AlbertTheLazy'. That really means that having defined my goals (quality, performance...) I try to find the least effort way to achieve them. That was always my philosophy across several careers. Having looked looked at some older posts (below) about assembler I might end up writing some small assembler routines (maybe a filter, for example) to call via asm() but nothing more.
https://forum.arduino.cc/index.php?topic=37130.0
https://forum.arduino.cc/index.php?topic=529512.0
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 » Sat May 02, 2020 12:17 pm

Me again, Rog.

So far I have built almost all the 'inside of the box' circuit you provided apart from the last couple of resistors (R4 & R5) that I guess are just there to deliver a voltage around 4 or 5 volts to the OCC line to an Arduino digital in. Originally I planned to bodge together several resistors in series to get the valuse you give, but the prototyping board I'm using is too crowded so I've ordered the right values which should arrive soon.

However...

I've just realised (I must be getting old!) that I can read the TC output using an Arduino analogue read pin instead of a digital one.. In that case can I just take the output from Q3 direct to the analogue pin? I can define the threshold in software rather than relying on TTL logic levels.

Going on from that, would I be able to use the output from the left hand side directly without the stage built around Q3 (the 2N3906)? Cleary I don't gain anything now, but if I can get away with it for future layouts it would greatly simplify matters as I would not need the voltage doubler for the bias feed.

All this must be displaying a lot of ignorance of analogue electronics, but I have plenty of that!

I have a cheap pocket oscilloscope on order which will, I hope, make it easier for me to see and understand what is happening at each stage, but I still value your help and advice.
Albert

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

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Mon May 04, 2020 4:23 pm

Hi Albert, sorry for the slow reply

Albert wrote:So far I have built almost all the 'inside of the box' circuit you provided apart from the last couple of resistors (R4 & R5) that I guess are just there to deliver a voltage around 4 or 5 volts to the OCC line to an Arduino digital in.

Yes they are, please dont forget the diode shown on the other sheet to protect the Arduino input from overvoltage in the event the +24V is a little higher than the minimum 21V or so allowed for here.

Albert wrote:I've just realised (I must be getting old!) that I can read the TC output using an Arduino analogue read pin instead of a digital one.. In that case can I just take the output from Q3 direct to the analogue pin? I can define the threshold in software rather than relying on TTL logic levels.

No, I am afraid the 24V at the collector of Q3 would destroy your Arduino (hence the R4/R5 attinuator). You could use an ADC input but better to find a well defined schmitt TTL/CMOS digital input.

Albert wrote:Going on from that, would I be able to use the output from the left hand side directly without the stage built around Q3 (the 2N3906)? Cleary I don't gain anything now, but if I can get away with it for future layouts it would greatly simplify matters as I would not need the voltage doubler for the bias feed.

Q3 provides a lot of current gain but more importantly it translates from sensing a current in a traction supply that can be at any voltage and indeed polarity with respect to ground to one related to the fixed +24V bias supply. Any attempt to connect Arduino pins directly to a traction voltage will destroy the Arduino.

Albert wrote:I have a cheap pocket oscilloscope on order which will, I hope, make it easier for me to see and understand what is happening at each stage, but I still value your help and advice.


Great, be careful where or what you attach the ground clips too, you dont want to smoke your scope :)
Last edited by fourtytwo on Mon May 04, 2020 4:30 pm, edited 1 time in total.
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 » Tue May 05, 2020 2:08 pm

Thank you Rog.
I had a nasty feeling that would be the answer. I've bought Roger Amos's Electronics book and treating that as a basis for learning enough analogue electronics to make sense of this and future projects.
I actually had a few zener diodes in my bits box, so I'll be sure to add them . I love the 'highland fling' circuit symbol.
At my present rate of progress I can't see myself having this little layout finished for a week or two at least. I'll try to remember to post some news when it's up and running,
Thanks again
Albert

User avatar
Bufferstop
Posts: 12468
Joined: Thu Mar 11, 2010 12:06 pm
Location: Bottom end of N. Warks line

Re: Track Circuits (Train on Track Indicators.

Postby Bufferstop » Thu May 07, 2020 10:47 am

This was a comment that I thought I'd made about the description of a latching relay as being a point motor with contacts but no points, but I found it in the drafts folder so perhaps it didn't go. If it did, I apologise for the repetition.
Describing them as a point motor with just contacts attached is not only a good analogy it's has also been done, in a big way.
Back in the 50s Alton Towers installed a huge multi tracked layout. Whoever did the electrics was very familiar with model railway products, but not commercial equipment, so when it came to the electrics, where someone from the electronics industry would have used latching relays they used H&M solenoid motors coupled to a row of microswitches. It didn't stop there where there was a need to switch multiple circuits to a number of positions, someone with a knowledge of telephone exchanges would have used a uniselector, their solution was a multiway rotary switch driven by a Triang X03 loco motor and what looked suspiciously some Meccano gears. The whole lot was mounted in a large glass fronted case on the wall behind the viewing space. By the time they came to it's large expansion they had found someone who knew about these things and a second large glass fronted case was added to take the extension using GPO 3000 series relays and 50 position uniselectors.
Although nerds were not then generally known about, the proto-nerds in the audience were easily detected, as when they passed around that end of the layout they turned around and stared at the cabinets on the wall. Also in the first couple of years Alton(Staffs) station was still open and the drivers and guards must have got free entry when they arrived in the afternoon for the return trains as they would appear in there around 4pm. Not a busman's rather a train driver's holiday.
Growing old, can't avoid it. Growing up, forget it!
My Layout, My Workbench Blog and My Opinions

User avatar
roganty
Posts: 170
Joined: Wed Feb 17, 2016 11:53 am
Location: Bristol, UK
Contact:

Re: Track Circuits (Train on Track Indicators.

Postby roganty » Fri May 08, 2020 10:56 am

Bufferstop wrote:This was a comment that I thought I'd made about the description of a latching relay as being a point motor with contacts but no points, but I found it in the drafts folder so perhaps it didn't go. If it did, I apologise for the repetition.


Maybe you were thinking of a different topic :?:

@Suzie mentioned the comparison of latching relays to point motors in the Using latching relays in in a control panel ?? thread
Main Layout: Planning | The Build

Erikslund - a small shunting layout

User avatar
Bufferstop
Posts: 12468
Joined: Thu Mar 11, 2010 12:06 pm
Location: Bottom end of N. Warks line

Re: Track Circuits (Train on Track Indicators.

Postby Bufferstop » Fri May 08, 2020 1:57 pm

Thanks I went looking for it but kept missing it. So Yes sorry for any repetition. Lockdown cabin fever is starting to kick in.
Growing old, can't avoid it. Growing up, forget it!
My Layout, My Workbench Blog and My Opinions

User avatar
Ironduke
Posts: 1019
Joined: Mon Sep 26, 2005 12:04 am
Location: Ballarat Victoria Australia
Contact:

Re: Track Circuits (Train on Track Indicators.

Postby Ironduke » Fri May 08, 2020 11:39 pm

sorry to intrude but would this thing be of any use? https://www.auselectronicsdirect.com.au ... o-projects
Regards
Rob

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 May 09, 2020 10:28 pm

Thanks, Rob.

I'll see about getting one to test. Did a little research and apparently they can be a bit erratic but definitely worth trying.

Cheers
Albert

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

Re: Track Circuits (Train on Track Indicators.

Postby fourtytwo » Mon May 11, 2020 8:11 pm

Ironduke wrote:sorry to intrude but would this thing be of any use? https://www.auselectronicsdirect.com.au ... o-projects

No intrusion and its a perfectly valid solution........
I designed my circuit long before such things were available and........
My circuit is far more sensitive, at a typical 12V supply it can sense 10K resistors across the track, useful for vehicle axles not just loco's
I calculate the ACS712 in conjunction with an Arduino (10 bit ADC?) will sense at best anything less than ~300Ohms across the track, ok for loco's but no use for wagons.
Also the bleed current required to maintain detection when the controller is off will mean something like a 1/2 watt dissipation in the stalled motor.

However within those limits perfectly usable :)
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 » Mon May 11, 2020 10:56 pm

Thanks for the comments. :-)

I've got my prototype of your circuit built and my 'scope has arrived. Now I need to start debugging my build.

Wish me luck!
Albert


Return to “Electronics”

Who is online

Users browsing this forum: No registered users and 6 guests