Recent Topics      
YMR logo

You are here:  Your Model Railway Club > Getting You Started. > The Lineside. > Processor Control of Lineside Items To bottom of page
                 

 Moderated by: Spurno  
AuthorPost
Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

This will become an occasional series of items that will concentrate more on the method by which I have - and still intend to automate certain aspects of my John Street layout (http://yourmodelrailway.net/view_topic.php?id=14501&forum_id=21&page=1) so that in a running session I can concentrate on actually driving the trains around the layout and not have to worry about which signal needs to be changed and whether it can even be legitimately changed to a proceed aspect and to automatically open/close the Level Crossing gates. I like to see a lot of animation on the layout other than the trains moving around.
 
To supplement the John Street layout topic, this will be somewhat more technical in nature and it'll leave the main topic as to how the layout itself is being built up and run.
 
Up to press I've automated a Home signal and Theatre Display on the approach to the Terminus and installed a number of Uncoupling Ramps for the tension lock type of couplings within the Terminus, and I'm almost there with a Level Crossing controller as well as progressing the signalling project for the entire layout; the Terminus area has been more-or-less completed (but not yet installed) with the remainder of the layout not far behind.
 
There are numerous methodologies of controlling signals, etc. from shop-bought items from the likes of TrainTech - to mention just one (apologies to other companies for not mentioning you [my mind has gone totally blank on it at the moment!]) but this topic is to concentrate on MY methodology of DIY. Personally, I get far more satisfaction from building something myself rather than going out and buying a ready built unit (which may/may not do what you might want to achieve on your layout).
 
Even on the DIY front there are various ways of automating signalling. My first layout - a rather simplistic layout - simply used a number of 1N4148 diodes and biasing them either "on" or "off" via switches and point voltages to achieve a given signal aspect. It was a bit clunky, but on that rather simplistic layout, it worked fine.
 
From here on in, I'd like to state that I am not an authority on any of the following bits of kit or technologies other than to say I know of their existence and in the case of the PICAXE range of processors how I have got them to do what I want them to do.
 
Moving along, hardware-wise, other than numerous diodes or, maybe, even relays, on the electronics front there is the Arduino Uno (and other types of boards from Arduino - the Nano, the Mega and others - not to mention the cheaper clones of them). Personally, I'm not particularly versed in what this series of boards can and cannot do but essentially they are built onto a ready-made circuit board and can be easily expanded by what is known as "shields" (add-on boards) which plug onto the Arduino pcbs to give some versatility and expansion of functionality. I think they can be made to do pretty much the same as I've managed with the PICAXE series of processors. But you do need a knowledge of the C++ language in order to program the Arduino series.
 
That is not where I'm coming from - I know absolutely nothing about C++. My knowledge only stretches to the BASIC language in one form or another and dates way back to the days of the Sinclair Spectrum (that's showing my age!). Whatever language you might choose to work with, it's only a matter of learning the syntax relative to that language and then using the right hardware for it.
 
The programming software used has the built-in capabilities of converting (or compiling) your code, whether you program in BASIC or C++, into the language that the processor understands - more easily understood as the "machine code". I once tried to directly program the Z80 processor of the Spectrum (in machine code) in order to gain additional memory space - not easy - and I still ran out of memory! 48k of memory is miniscule by today's standards.
 
Getting back to the subject of hardware for my layout. My criteria was to keep costs down and the learning curve short. Hence I decided to continue with the BASIC language together with the relative cheapness of the PICAXE chips. OK, so the whole PICAXE system was designed more as an educational system for schools. But, in my mind and those of many others, it can be so much more. Also needed is (as I build the kits) a piece of stripboard and a few other small/cheap components like resistors, capacitors and +5volt regulators - these PICAXE devices, like most logic chips, only run with a well regulated +4.5 to +5v supply.
 
Hence I have gone for (and I hasten to add, I have no connection to this company other than as a user) the Revolution Education series of PICAXE chips. These are standard PIC chips from Microchip Technology but with a pre-programmed on-board bootstrap interpreter that enables the use of the BASIC programming language.
 
That's a very brief introduction to making a start on automating various aspects of a layout. Incidentally, both the PICAXE and Arduino can be programmed from a PC or Laptop without anything more than a USB port and a cable - all software to do the programming is either supplied or free to download.
 
A couple of links for those that might be interested in looking deeper into this area of possibilities:
https://picaxe.com
https://www.arduino.cc/
 
Coming up next..... My projects, either working or in the planning/build stage.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

A bit of background first. And a bit of techie talk. As mentioned above, I'm using the PICAXE series of processors from Revolution Education which uses a version of the BASIC programming language. I've used BASIC in one form or another since the days of the Sinclair Spectrum but never got to grips with C or C++ or any other form of programming language (of which there are many - and the list is expanding all the time).
 
I first mooted the idea of using the PICAXE microprocessors to automate some aspect of John Street way back in Sept 2016 (see my 2nd post). And following on from this first success, decided to take it a whole lot further rather than simply dream about what might be do-able.
 
If the option of using the basic Revolution Technology PIC processors are used, they can hold around twice the program size of the equivalent PICAXE and the programming itself can be more involved, more complex. Thus is the simplicity of the BASIC language as opposed to the rather more complex C++ command set. The number of input/output ports is the same which ever option is chosen, PIC or PICAXE, it's the same basic chip. I should mention that the PICAXE chips come in a variety of pinouts versions, from 8-pin, 18-pin, 20-pin, 28-pin and 40-pin varieties. Anyway for what we, as model railway enthusiasts require, complexity I don't think really comes into it. Although that just depends on what you might want to achieve.
 
Each port of these processors can only source/sink a maximum of 25mA with an overall capacity of 185mA/200mA or so per chip (chip type dependant). Therefore, if more than one LED needs to be driven per port (such as the signal itself and a mimic board LED) or if the overall chip current capacity is likely to be exceeded then the use of a driver chip such as the ULN2003a or ULN2803a (or even a basic transistor) can be used to increase the current capacity of each output port to approaching 500mA - more than enough for driving any peripheral, even DC motors. Not that the driver chip will be capable of driving all 7 or 8 ports at 500mA each - the datasheet does specify a maximum current at a certain duty cycle. Driving 3 LEDs on each output at 15mA per LED still only comes in at 350mA (for the 8-port ULN2803a) but at a possible 100% duty cycle. So this needs to be bourne in mind.
 
My first project was to make a Theatre-type display on the approach to the Terminus together with the Home Signal controlling the access. As the Terminus has six roads/platforms to arrive into, I also needed to have inputs from each of the numerous points so that I would only get a green aspect when a correct path had been set and when nothing was likely to cross the path of the incoming train, i.e. by a shunt movement.
 
This involved the 10 points of the Terminus, a red/green Home Signal, a couple of sensors and 4 outputs for the display - i.e. 18 input/output ports. This decided the chip version I needed to use - a 28-pin PICAXE 28X2 has a possible 21 input/output ports. The other pins are for programming, supply rails, an external resonator to provide for other than the pre-programmed speed of operation and a reset pin.
 
The programming was created to keep prototypical signalling schemes as far as possible and this involved keeping the Home Signal at danger until a train was on close approach (this is to ensure it slowed down sufficiently prior to access to the Terminus and to allow for the train to stop prior to the signal should access to the Terminus not be available at that time) before turning to a green aspect and only then if there was a valid path for it to arrive at a platform. Along with the green aspect, the 7-segment display would then also show the platform number. At the time of building, designing a fibre-lit theatre display was not realistically possible.
 
The programming was relatively straight forward, mostly IF (this condition)..THEN (do this) command strings: so we wait for the approaching train sensor, then checking a series of points and if a valid path was available, give a green aspect and display the appropriate platform number on the 7-segment display, then wait for the train passing the next sensor and turn off the theatre display and go back to a red aspect, then await the next approaching train. If access was not possible, due to a points conflict, then the danger aspect would remain until the line did become clear to enter the Terminus.
 
The programming editor features a "simulator" mode so that the program can be stepped through command by command before programming the PICAXE itself. Make a mistake and on the layout it doesn't do quite what you thought it would? no worries. Correct the program and re-program. Simple.
 
As probably noted on the John Street pages, the project involves:
the PICAXE 28X2 processor driving a
4511B BCD decoder - 4 control lines in from the processor : 7 lines out to the
7-segment display LuckyLight 1202 KW1-321CWB-JY - a 8mm (0.32") high display.
The processor also drives 2 outputs for the Home Signal via a
ULN2003a (7-port) driver for the
Red and Green LED aspects (copied to the Mimic display),
two RPR-220 in-track sensors and
10 inputs from the various points.
 
One processor port could have been used to combine the Home signal Red and Green outputs. This could have been achieved with the addition of a 7404 inverter chip: the signal output would then be routed direct to one port of the ULN2003a to provide (say) the Red aspect and also via one 7404 port to invert the signal and then be passed to a second ULN2003a port to provide the Green aspect. So that if the Red aspect is set to be a "high/1" output it would switch on the ULN2003a and pull the supply via the LED to ground, thus lighting the Red aspect, while via the 7404 the output here would become a "low/0" signal and the ULN2003a would be inactive and the Green LED remain off. If the signal output on the processor went "low/0" then the direct line to the ULN2003a would also be "low/0" and the Red LED would remain off, whereas the signal via the 7404 would be inverted and become a "high/1" and turn on the Green LED. Easier to work it through on paper than it is to describe in words! If a Yellow aspect is also required, then the processor still only needs to output the Red and the Green signals. This time both would be passed direct to the ULN2003a and again both would be passed via a 7402 NOR gate so that if both Red and Green signals were at a "low/0" level the output would be a "high/1" and would drive another ULN2003a output producing the Yellow aspect. I've not delved into the Double Yellow scenario just yet but should be simple enough with a bit of logic fiddling to make it light correctly - unless your processor has enough ports to drive each LED separately of course.
 
But, in this case of only needing a Red and a Green aspect, and as I had sufficient ports available to me, I left them as separate outputs from the processor. But the above idea of producing a Yellow does come into its own further down the projects.

 


Next up......servos and a working set of Uncoupling Ramps.

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

A bit of a lengthy item this (in 3 sub-sections), but bare with me - hopefully all will get explained regarding servos.

The next working project has been to make and semi-automate a number of Uncoupling Ramps using miniature SG90 servos for the tension type of couplings. The size of these servos: 32.2mm long, 11.8mm wide, 31mm high (including the arm) and only 9gm in weight. The SG90 servo cable has wires coloured Orange for Data, Red for +5v and Brown for 0v/ground. Other colours may be seen depending on the manufacturer of the servo - always wise to check the spec sheet.
 
For those not familiar with servos, they (generally) operate/move an arm (known as "horns") over about 180 degrees, have 3 wires to operate them: a +5v supply, a ground (0v) connection and a Data line. Some servos can be modified to produce a 360 degree rotation of the arm. But we'll be concentrating on the normal (unmodified) servo with the 180 degree movement.
 
One problem with servos is that they have a tendency to generate a lot of electrical "noise", both on to the supply wires and also to a degree in a radiated form. As far as the supply wires are concerned, a decent amount of decoupling capacitance is required - a small 0.1uF ceramic capacitor to reduce any high frequency noise and some large decoupling capacitors to keep the output from the +5v regulator smooth and free of voltage/power "brown-outs" as some of these servos can take quite a hefty amount of current, sometimes in excess of an amp. Just using a normal 7805 regulator on its own might not give sufficient regulation without the addition of the reservoir/decoupling capacitors or if the supply to the regulator doesn't have enough headroom.
 
It should be noted not to use the same +5v supply for both servo and processor due to the electrical noise coming from the servo on the supply cables. Keep the supplies on separate +5v regulators (but keeping the 0v rails tied together). It's also a good idea to keep the cable away from other sources of electrical interference, such as the DCC wires and mains supply cables as the servo's Data cable acts as an aerial and any interference introduced onto this cable might be interpreted as a valid signal to move the arm.
 
Servos seem to be prone to jitter and twitching of the arm and, in this case at least, it was not fixable by the addition of supply line decoupling, etc. when using the 'normal' commands to move the servo arm. Some additions to the normal circuit that feed servos might include, as noted above, one or more 0.1uF ceramic capacitors and up to 6800uF of electrolytic capacitors (rated 15v min) and a 10k resistor in line with the data feed from the processor. Some comments I've seen mention a 330R resistor (which I tried) without much success. Also it has been suggested to lightly twist the cable between the processor and servo to try to eliminate stray noise or to pass the cable though a ferrite ring a couple of turns to introduce a bit of inductance to help stop noise and interference or even to add a 0.1uF capacitor between the Data cable and either the +5v or ground wires. It seems to be a different set of circumstances and fixes required dependant upon all manner of things, such as circuit board layout, positioning of the servo in respect to its surroundings and how the cable runs between the processor board and the servo.
 
As far as the "data" required for the servo is concerned, the servo likes to have a regular series of pulses 20mS apart with a positive pulse of between 0.75mS and 2.25mS - with 1.50mS representing a central position for the arm (some variation of these figures is servo dependent).
 
The PICAXE series of processors can very kindly produce a continuous series of 20mS pulses using the SERVO command and upon this is added the required positioning pulses using the SERVOPOS command. The SERVO command starts the timing of pulses while SERVOPOS inserts the required positioning pulse length. The syntax for the commands are:
SERVO B.4, 75     ; start the 20mS pulses on port B.4 and move the arm to the left-most (-90 deg) position - every 20mS a 0.75mS pulse will be added and this will hold the servo arm steady at that point
SERVOPOS B.4, 150     ; move the arm on port B.4 to the central (0 deg) position and that 1.50mS pulse will be output every 20mS (until the next SERVOPOS command)
 
From my experience, if you try to slow the servo down too much by adding PAUSE commands between each SERVOPOS command, it can lead to some arm jitter which is nigh-on impossible to get rid of no matter how much decoupling, etc. is thrown at the circuit. I may be wrong here, but that's my experience of trying to get a smooth operating speed for my level crossing gates which require moving at a slow speed (more on this in the next article). A servo normally takes less than 0.5 second to swing the arm through 180 degrees, so to slow it down to swing 90 degrees in maybe 5 seconds or so is quite a slowing-down of the servo. Also, I have issues of where the gate suddenly flies off to the servo end-stop (I presume that's where it goes) before flying back to continue its intended movement. I feel that this has something to do with a timing issue between the commands, but I could be wrong. But the level crossing is for another day.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Back to the Uncoupling Ramps. So, to try and eliminate these issues of jitter, I decided to go right back to basics with the code (and with the help of the PICAXE forum members - a very helpful group of people) and try another command that is present within the PICAXE system - the PULSOUT command. Those on the PICAXE forum call this method of servo control "bit banging". This only sends a pulse to the servo as and when you need to send that pulse - so there is no continuous stream of 20mS spaced pulses being sent by the processor and if there is any force normally being applied to the servo arm, then the arm will tend to move and not be held steady by the continuous series of pulses as sent out by the previous two commands. But as long as the minimum period of 20mS is kept between each required pulse (and no external force is being applied) then all should be well with the world. If running the servo at a slow speed then this minimum 20mS timing aspect should not present a problem.
 
Yet in my program the PULSOUT command still uses the same PAUSE command (as with the SERVOPOS command)....and the servo seems to work much smoother. The syntax for this command is:
PULSOUT B.4, 150     ; send a pulse on port B.4 to move the arm to the centre (0 deg) position
PAUSE 20     ; wait 20mS before looping back to the next PULSOUT command (as part of a FOR...NEXT loop) - this pause can be any suitable length to make the movement of the arm as slow as you would like it to be.
 

The pulse shown here is for a 1mS to 2mS pulse, whereas it might normally be 0.75mS to 2.25mS as noted above

The difference, as I see it, is the SERVO command sets up a continuous series of timing intervals as required by the servo and the SERVOPOS command sets the length of the pulse that governs where the servo moves to. Whereas the PULSOUT command simply puts out a single pulse to control where the servo moves to one step at a time and so long as the minimum required interval between pulses is maintained there can be no timing errors. The timing of the next pulse by using PULSOUT is controlled by taking into account the length of time any intervening commands take together with any pause command to pad out the timing to get the right speed of movement. That's my theory of it anyway, rightly or wrongly. I stand to be corrected here.
 
Components used for the Uncoupling Ramps:
PICAXE 18M2+ processor,
a rotary switch to select the ramp to be raised
a push button to activate the raising of the selected ramp.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

The 18M2+ processor is capable of driving up to 8 servos, but I only used 6 as each servo needs its own outgoing Data line and its own incoming activating signal. And when you add an indicator LED and take into account the 2 supply rails and the programming ports there is only one spare port to play with.
 
The program was written such that a servo once selected would slowly raise a short length of plastic, about 35mm in length (taken from an old VHS cassette case - the same thickness of the track sleepers - I said earlier, cheapness and DIY! - laid between cut-away sleepers to disengage the tension hook couplings, wait for around 10 seconds to allow the rake of trucks or coaches to move away and then slowly lower the ramp again back to its resting position.
 
Two thin nails were put through this "ramp" and glued in place and allowed to freely pass through the baseboard - these nails are to keep the ramp aligned and central within the track. The actuator used on this design was a short length of 3.5mm OD pvc tube (to allow for flexibility in movement/alignment) inserted and glued into the ramp and connected at the other end via a short pin through the servo arm itself. The servo being mounted, in this case, on another offcut from the VHS tape cassette (other methods of mounting these servos are available!).
 

  Initially while testing, I found that with the SERVO/SRVOPOS commands being used that the small 7805 +5v regulator got impossibly hot due to each servo being constantly powered with the 20mS pulses. Changing to the PULSOUT command reduced the current consumption to acceptable levels. At the time of building and testing I was not aware of the amount of current these servos can take - something in the order of up to, and sometimes in excess of, 1 amp - not a widely publicised fact, a fact I found to be strange given these servos can be used on battery powered equipment, such as model aircraft. And not all SG90 servos are equal in respect of how much current they take!
 
The end result is that the Uncoupling Ramps raise (and lower) nice and slowly so there is no chance of sending a truck or loco sky high at a rapid rate of knots if the positioning of the coupling between trucks is not correctly aligned before the ramp is raised. Some careful adjustment of SERVOPOS figures is required so not to try to pull the ramp down through the baseboard on lowering the ramp or to raise it too high so as to lift a truck off the rails, just enough to disengage the couplings.
 


That's the Uncoupling Ramps about covered for now. Next time I'll take a look at the Level Crossing Gates - work is still in progress here, so maybe a few days or so before posting this next item. Bare with me.
 
 

BCDR
Moderator


Joined: Sat Oct 19th, 2013
Location: Reston, Virginia USA
Posts: 3565
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave,

I'm bearing with you. Definitely not baring with you though.  :lol:

Nigel

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Nigel.

T'was early this morning I twiped the item up with eyelids wide shut at the time. Shame the auto corrector didn't pick it up (but I guess it was a valid spelling, although not necessarily in this context!). Memories of Morecambe and Wise with Andre Previn...... classic sketch. That's my excuse.


Last edited on Wed Jul 29th, 2020 12:48 pm by Dave C

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

I ought to make a suggestion that if anyone has any comments,
   or suggestions as to how to make any of these projects better or in a different way,
      or suggestions as to other subjects I could cover,
         do please contribute.
It's all about learning. And I'm always keen to learn - keeps the grey cell active!

Other items on my list to complete and then write up over the coming months:

1.   coming up,  end of next week hopefully - automatic train-activated Level Crossing Gates using Wills SS56 kit (across a single track line); followed by....
2.   automatic colour light signalling, using Eckon signals - this is mostly related to linking processors, together with....
3.   automatic semaphore signals using Ratio kit 486, LNER upper quadrant signal (if my fingers are supple enough!).

Most of these have been covered before in one form or another, mostly as standalone items and/or as manually operated, but my idea is to link them together using the PICAXE series of processors so that they all form part of the overall track plan.


Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Automated Level Crossing Gates.

There's been a bit of a delay in getting this next topic sorted due to problems with linking the servo to the level crossing gate itself. So, apologies for that. More on the gates in a moment.

Moving on and yet keeping on the subject of servos, this item is about automating Level Crossing Gates so that they will open with an approaching train (hopefully in plenty of time) and then close again once the train has passed - with the proviso that if a train needs to reverse into the siding, the gates need to remain open until that movement is complete. It also needs to recognise when a second train is approaching and to keep the gates open until the second train has passed. It's all in the software!

This kit is built up using a pair of
Wills SS56 Level Crossing Gates (4mm OO gauge) and again a pair of
SG90 servos across a single track line (and with adjacent access to a siding) together with a
PICAXE 18M2 to control it all and
2 RPR-220 infra red in-track sensors and
LM339 voltage comparator and
1 infra-red separate transmitter and receiver (across-the-track sensing) and
1 point for access to the siding.

First things first - the automation bit. Train detection. For this I have opted for Infra-Red transmitters and receivers/sensors.

The RPR-220 Infra-Red transmitter and receiver pair can be regarded in exactly the same way as normal, individual transmitter and sensor items except that it is packaged as a single item and is suitably sized so as to be buried into the baseboard, which will sit nicely between the tracks and fit between two sleepers (hardly visible). The Tx/Rx pair measures just 4.9mm x 6.4mm x 6.5mm high. Forward current to the transmitter is to a maximum of 50mA with a forward voltage of 1.34v - generally, the current taken should be around 17mA. The receiver collector needs to be fed via a 470k resistor (from a +12v supply) or 10k (from a +5v supply) and this will give a good degree of sensitivity. As the output from the collector of the receiver can vary with the amount of reflected (Ir) light, it is advised to feed that output into an LM339 comparator - this is a 4-port device so is expandable for other sensors on the layout. This will give a clean change (no bounce) in voltage levels to be applied to the input of the processor. The point at which that changeover takes place can be varied by means of a 22k pre-set resistor on the associated port of the LM339 so is relatively independent of the reflected light.

I had emailed/requested Rob Paisley for permission to include the (copyrighted) circuit here, but at the time of posting this, I have received no reply. So below is the web link to the page - the circuit is the last one on the page entitled "4 - INFRARED PHOTO-DETECTORS USING AN LM339". If permission comes through at a later date, the circuit will be included at that time.
http://www.circuitous.ca/ATDetIR.html (the web page has changed from that shown in the actual circuit diagram).
Also see http://www.circuitous.ca/Comparators.html for a complete write-up on voltage comparators. Overall, this is an excellent website for all things electronic, quite a lot railway related or adaptable for it.

Using another port of the LM339, I also used Ir Tx/Rx separates as individual items as an across-the-track sensor pair set at an angle across the track such that there would be no gap sensed between trucks and therefore the gates would not be closed against the train prematurely.

In the circuit noted above, when the sensor (receiver) becomes blocked, i.e. no train passing over, the LED lights. Or to put it another way, the output goes low. This state can then be sensed by the processor and action taken as appropriate. If there is a need for the LED to be off, i.e. the output voltage to be high, when the sensor is blocked, simply swap the two inputs over. Incidentally, to cater for differences in sensor components or positioning, each mid point pre-set voltage level can be individually set rather than using the same voltage level across all ports, as shown in the circuit by using the two fixed 10k resistors.

Now moving on to getting the level crossing gates themselves working.


EDIT: As noted above, permission from Rob Paisley has now been received for me to reproduce the circuit diagram indicated above. For this, see my post #16 further down the page.

Last edited on Mon Oct 5th, 2020 03:26 pm by Dave C

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Something I perhaps should have mentioned in the previous item about servos and the pulse passed to them being between 75mS and 225mS with a mid-way position of 150mS. Shortening to the pulse (towards 75mS) will make the servo arm turn anti-clockwise and, strangely enough, lengthening the pulse (towards 225mS) will make the servo arm turn clockwise. Having got that out of the way.....

The problem here, yet again, like the uncoupling ramps, is getting a smooth operation/swing of the gates. It was thought the ideal time taken to swing one gate would be around 5 or 6 seconds. Any jitter on either servo would be wildly exaggerated due to the length of each gate and the rather flimsy structure of the gates themselves. So getting a 'smooooooth' servo operation is of the utmost importance. So that effectively ruled out using the SERVO/SERVOPOS command pairing and making use of the PULSOUT command. But I did try using the twin commands just in case - no, jittery.

I was able to get the right speed of swing but there was still quite a lot of flapping about of each gate which got worse as the gate swung through its 90 degree swing. As mentioned in the previous post, copious amounts of capacitance was added across the +5v supply rail but this made no real difference. But this wasn't simply just servo jitter - as I later found!



The level crossing gates themselves each have a length of wire inserted and glued into a hole drilled (very carefully!) into the gate post. This provides the gate pivot pin.

One thing I did notice on the original setup, and more by accident than anything, was that the servos were not exactly aligned underneath the gate pivot pin which passes through the baseboard and then connected directly above the centre of the servo arm through a choc-bloc connector - see the photo above. This was most likely due to a misaligned mounting and/or non-alignment of the servo arm wire. Neither wouldn't have helped keep the movement smooth.

Alignment of the servo to the gates seemed to be a huge problem in trying to get it all aligned correctly so that not only did the gates swing through the 90 degrees - that was simple enough once the PULSOUT figures in the program were sorted, but also that they swung horizontally and not either scraped the road surface or rose into the air - namely that the gate (hinge) post needed to be truly vertical.

So the initial arrangement (in the picture above) was eventually scrapped as being too difficult in the space available to me to make the adjustments so I opted for a remote servo with a linkage to the gate pivot pin.

This new arrangement involved having the servo moved away from under the gate pivot pin and using a couple of linkage wires to link between the servo arm and the gate pivot pin. I can't claim any originality for this method, but it would appear to be easier to setup - certainly in places where there is little wriggle room for arms/fingers/screwdrivers/you-name-it!



The above is a test mock-up of the actuator to make sure I could get enough "swing" on the gate with the servo and arm at the top (just held in place with a screw) and the linkage to the level crossing gate at the bottom. With this arrangement I can get around 105+ degree swing - more than enough.

If you're anything like me, I couldn't drill a truly vertical hole if I tried. To overcome this shortcoming in dexterity with a drill I initially drilled a larger hole through the baseboard than was required then glued a small square of relatively thin plastic (part an old credit card would be ideal) with a hole very slightly larger than the gate pivot pin to pass through in the correct place on the top of the baseboard. Then once the glue was fully dry, glue a similar piece of card under the baseboard and, before the glue had set, it was adjusted to obtain the correct alignment of the gate such that it wouldn't scrape the road surface nor would it ride high as it swung. Then once that glue was dried and set solid, the linkage arms were fitted along with the servo sitting between blocks of wood (about 18mm - 25mm high) - or in my case, on a short length of angled wood moulding.

In the mock-up (just the servo arm, linkages and dummy pivot pin - just to test to see if it worked) the linkage arm from the gate pivot pin is about 15mm in length (about the same length as the servo arm). The length of the adjoining link can be any length that suits the space available. Some old Twin&Earth house wiring was used here, but any suitable stiff solid core wire that comes to hand would most likely be usable. Some positioning adjustments can be made using the choc-bloc connector (or within the servo program) and by altering the length of the shorter linkage arm if the full 90degrees (or thereabouts) cannot be obtained. It's very much trial and error to adjust. But this mock-up largely worked and was hugely better than the direct-drive from the original servo version (above).


Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides




Final installation of the servos and linkage arms - the small pieces of plastic card can be seen where the pivot pin emerges from the layout side of the baseboard.

So to recap, as this series is about automation. The whole module is controlled by an 18M2 PICAXE processor as described earlier. The adjacent Halt Home signal is normally showing a red aspect (the gates being held closed to trains). A train is detected some distance away in its movement towards the level crossing as it crosses an in-track "approach" sensor. The gates then swing open and this in turn triggers a signal to the signalling processor to change the Home signal to a green (or a yellow) aspect for the train to pass - provided of course this next "block" is known to be clear. The train gets detected as it passes over the in-track sensor shortly after the Home signal. This is again then passed back to the signalling processor to put the signal back to a red aspect, the preceding signal to a yellow aspect and to flag the next "block" as now being occupied. Once the train has cleared the across-the-track sensor beyond the gates, the gates then close to trains. And we await the next train to cross the "approach" sensor. In the case of a train requiring to reverse into the siding, the across-the-track sensor remains blocked, the gates remain open and once the in-track sensor again detects a train (with the point noted as being set for the siding) and the processor will then wait until that sensor is again cleared as well as the across-the-track sensor before opening the gates.



I should point out that servos are not the only method of activating Level Crossing Gates. There is also the option of Stepper Motors - but these also require processor control to move the motor rotor and to count how far the rotor has moved - and straight DC Motors with low reduction gearing to reduce the speed to an acceptable level. Also needed here would be some form of method of stopping the gates in the correct position, either with microswitches or Hall Effect switches (little solid state devices that react to the effects of a magnetic field) and with a small magnet mounted on the gate or on an arm mounted under the baseboard.

That's about it for the Level Crossing. Next up will be the automatic signalling.

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Ingenious Dave - but I got lost when you mentioned "voltage comparator" ................. :???: :???: :???:

I'll re-read it to see if anything sinks in ..... :roll:


Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Tks Peter

Apologies if I make it sound like you may know very little about electronics - and you may in fact know more than I do in some areas, but I need to pitch the answer at some level where anyone call understand it.

Essentially a voltage comparator is a device that compares one voltage coming from a circuit that has a variable output voltage - such as a light sensor that gives an output voltage dependant upon the amount of light falling on it - and at some pre-determined voltage which has already been set it will switch on a light (for example).
i.e. bright sunlight = no switching on of light - input being, let's say, 4.5v
cloudy daylight = no switching on of light - input being 3.4v
darkness falls = light is switched on - input being 1.2v
The preset voltage level being set at 2.0v.
So once the light dims down, at 2.0v from the sensor, the light will switch on.

The device that does this is a voltage comparator - in the case of the circuitry already described - the LM339.
Input1 = variable voltage from the infra-red sensor
Input2 = a pre-set voltage
Output = either light on or light off


The circuit above is 1/4 of an LM339 and the output (Vout) will either be an inverted input or a non-inverted input - the input (Vin) being applied to either the + or to the - input with the preset voltage set by the two resistors R1/R2 on the other input to that used for the input. Generally used with a +5v or +12v supply to V+ and a ground (0v) connection to V-.

Hope this makes sense and I've not complicated it.


Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Automatic Signalling is (still) coming.......

Just a quick update on the progress on this subject from this end's perspective. But just to whet your appetite......

I've been working on the software for some months - on and off (life has a habit of getting in the way) - with many restarts due to re-thinking the most effective way of achieving it all. The most difficult part (for me) has been the learning curve of getting to grips with the inter-processor communications protocol - I2C - and the rather difficult part of getting the grey cell round the various commands and which part of each command on one processor does exactly what to or from the other processor(s).

To achieve what I'm wanting to do, I'm needing to use four processors - one to handle a few sensor state readings, one to control the Terminus signalling and one to control the rest of the layout. There's also a fourth processor that is already controlling the home signal and its theatre display. This last processor needs its software updating to make it "talk" to the other units.

For those wanting to get into this side of things, as before I'm using the PICAXE series of processors and the I2C commands involved are hi2csetup, hi2cout, hi2cin together with a few others associated with how the data is handled. Regrettably, the write-up on the commands do not make it particularly clear quite what is happening and what and where is being affected. The number of times I've read and re-read the paperwork and I'm still not 100% clear in my mind. Putting a whole load of examples together in combination with the write-ups, I think I've about got it to a level that I can make it work.

And to prove it, a couple of the processors were put onto a breadboard (not overly happy with the thin, poorly connecting linkage pins), a couple of small tester programs were written up and with a couple of flashing LEDs added, it proved to actually work. So that was a surprise if nothing else!

So I'm back to continuing with the software writing - a further update with more detail will appear in due course.

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

I'm with you all the way Dave ............................................................... :shock: :shock: :shock: :shock: :cheers

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Back in August, post #9, I gave a pointer to the circuit I have used for my infra red sensors using the LM339 comparator. In that post I indicated that I would show the circuit diagram as and when and if the author Rob Paisley gave permission to reproduce it on this forum. Today, that permission came through and for which I would like to thank and show appreciation to Rob for that.

So. Going back to post #9, this was all about how I used Rob's circuit to interface between the sensors (receiver) and the PICAXE processors I use. The LM339 was used to give a "clean" switchover between being either ON or OFF, (this is what processors like) - no dithering or varying levels if the light or surroundings change slightly.

The following circuit is the basic setup, and can be found at http://www.circuitous.ca/ATDetIR.html

There's loads of information on this page regarding across the tracks sensors.



The only difference between these circuits shown and that used on my layout is that instead of where the LED and resistor is shown a direct connection to the PICAXE processor input is made. Take no notice of the web address shown on the diagrams themselves - this is no longer applicable - use that web link above shown in the text.

To make better use of the LM339 - a four channel device - the circuit shown below can be found further down the web page indicated earlier.



The sensitivity of the sensor receivers is determined by the values of R1, R2, R3 and R4. I tend to use 470k as indicated in the parts list; this seems to work well for me. The arrangement on these circuits is such that when a train breaks the beam between the emmiter LED and the sensor receiver, the LED turns on. If your preference is for the LED to turn off under these conditions, simply swap the input from the minus (-) to the positive (+) and the "reference voltage" goes to the negative input. A variable resistor in place of R5 and R6 (or one for each input) can be used to set the "reference" to suit conditions, such as the distance between emitter and receiver and, maybe, what ambient light is falling on the receiver; adjust it to suit your conditions.

I hope the wait has been worth it and you can take home some more information on this subject. The entire site is a minefield of useful circuits for all sorts of projects - not just for model railway folk; just go to the home page at http://www.circuitous.ca/CircuitIndex.html

EDIT: just found the first link doesn't work - there's nothing wrong with it, just gives a "Page not found" error and the second link gives a "placeholder" message. Weird, both are correct. I've taken out the full stops at the end of each link/end of sentence. Think the second link (to the home page) should now work, not sure about the first link to the correct page. Checking it out.

EDIT #2: the links still don't seem to work correctly - I know not why! Just copy and paste into another browser tab, it'll work fine then. Sorry about that guys. The links on post #9 work correctly - maybe it's an update/timing thing and perhaps it'll work fine tomorrow.

EDIT #3: How awkward can inserting a link be? Hopefully, got it sorted this time! Seems like an errant 'full stop' was being put at the end of the link address. Apologies for those who found it not working.

Last edited on Mon Nov 16th, 2020 12:00 pm by Dave C

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

That's ermmm, that's errrrr, that really is errrr...........................


Not sure what to say Dave - so I'll just say nice drawings. :cheers

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Peter - good to know these ramblings of mine (and the circuits) are being appreciated :hmm

For me, the arrangement of "across the track sensors" - and the circuits above form an integral part of it - is a good way of train detection for times when the track has been laid and ballasted and, due to the forethough of making a plan (what plan?! was I supposed to make a plan? oh, come on, get real!), train detection by current sensing, i.e. the need to break the track into sections so that current taken by a loco can be sensed is not a real possibility. So this arrangement has been very useful as it easily detects the entire train, not just the loco.

There are times and locations where an across the track sensor is not possible without it being very visible and obvious. It's times like this that the small "in track" sensors have been used that sit nicely between the track sleepers - far less noticable and just as effective. The only downside being that they tend to sense the inter truck/coach spacing (the couplings). But even this can be worked around.

Anyway, it's all part of this DIY automation and this electonic wizardry is part and parcel of it. Give me a soldering iron, a circuit diagram and a few components and I'm happy!

More to come of the signalling side of things (as promised earlier) as and when I get the time to finish the project off - it's a bit bigger and more complex than I thought it might have been. I'm getting close, so it shouldn't be too long before the next installment appears. Hopefully not quite a techy as the circuity shown above.
  :doublethumb

Cheers for now - and where'd I put that reel of solder......

BCDR
Moderator


Joined: Sat Oct 19th, 2013
Location: Reston, Virginia USA
Posts: 3565
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave,

That looked familiar. Basically an updated version of the reed magnet detection system described by Roger Amos back in 1990 using the 555 timer.

Nigel

TeaselBay
Novice
 

Joined: Fri Aug 4th, 2017
Location: United Kingdom
Posts: 1089
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hey Dave,
I’ve only just found your thread, it was a good interesting read. Automation is on my list of activities at some point!

I went down the Arduino route, at the moment it simply takes commands from USB and turns lights on and off.. so it’s basically a glorified light switch! I have some of the infra-red sensors you mentioned above but have not experimented with them yet. 

Your signals and crossings looked amazing.  It would be great to see some videos of them working!

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Nigel.

On my last layout I did play around with reed magnets and the 555 timer chip but found the reeds to be a little unreliable (maybe it was me and my fumble fingers in mounting them correctly!). Not only that but they only detected where the magnet was, presumably under the belly of the loco (or wherever the magnet got fitted). I'm looking at detecting the entire train. The reeds were also a bit obtrusive and noticeable in that they lay along the track and were somewhat difficult to "hide". But for those that use them, great, as long as it does the job for you.

And to you Chris, again, thanks for the comments.

I did have a look at the Arduino, mostly the Uno, but found that it had a limited number of ports to which you can connect things - am I right in thinking only 20 digital and 8 analog? Maybe there are add-on boards to increase this number of ports but that then adds to the complexity of it. Having said that, I guess my idea of using the PICAXE processors is just as complex in that I only have the bare, naked processor to start with, and it along with everything else has to be mounted onto a piece of board. Swings and roundabouts, I guess. But the PICAXE 40X2 has up to 32 ports for connectivity and even for my needs I have found it limiting when trying to sort the signalling out.

For instance to save ports, I have to generate a three-aspect signal from two outputs and a two-aspect signal from just one output - plus a couple of logic chips to make up for the deficiency and the missing aspects - more on this when I get round to the next instalment, coming (I hope) shortly. Presumably the Arduino is as capable of only driving a limited amount of current from each port (and overall) as the PICAXE. Therefore, if you want to run the layout signals as well as duplicating them on a mimic board then other add-on chips to increase the current capability would also be required.

Don't get me wrong, I'm not trying to put you off the Arduino. In some respects I'm trying to make a comparison about the Arduino of which I know very little about. Like the reed switches/magnets mentioned above, it's horses for courses. You run with whatever you feel is right for yourself.

I'm not sure about making videos.....I only recently found out I have a YouTube channel by way of the GMail account, I think that's how come I got it. Never even thought about videos. Maybe one day. At the moment there's not enough hours in the day to do much on the layout (same old story, I know). Can't recall the last time I actually ran some trains.

Anyway, glad you're enjoying the series, Chris

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thought I ought to give an update on the automation of the signalling as it's been a long time a-coming.

Well, life over the past few months has certainly been getting in the way of all things railway. But there is progress, slight though it might appear. The circuit board has finally been completed and the inter-connections checked and double and triple checked - it's not been supplied with power yet so there is still a chance I may have missed something along the way. Once I start checking the board it will be very slowly, slowly, bit by bit.

Then I can start to connect up the sensors and signals and the associated layout mimic/track diagram. But even some of the signals and sensors are not yet in place - so there's still a lot to be doing before it all gets up and working.

But to give an indication of where we are, the following is a preliminary shot of the circuit board - on standard stripboard.



Note the two large processor sockets and small add-on board for the "master" processor - not enough room to squeeze it onto the main board - and the use of two 7805 regulators (just to make life easier on having just one of them). It's still a bit cramped though.

So, as you can see, there IS life at the end of the tunnel - if only someone would turn the light back on! .... more to come in the next few weeks as and when I can get the time together to spend in "The Train Room".

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Another quick update - not that much has been happening.

The signals are now installed and connected up to the (new) main patch-panel - there are over 120 individual wires to connect through. The sensors are also getting there. The original sensors in the hidden track area were all initially run from +12v - which is of no use what-so-ever for feeding into a processor that only likes +5v. So they are in the process of being updated and modified for +5v. They all need updating as there will be an overall layout track diagram complete with (pseudo) signals in the hidden section (only visible on the track diagram) and the sensors are needed for controlling them. The signals also need to be wired essentially back-to-front with a permanent +12v to the anode of the LEDs - it's the negative side (the cathode) that gets switched to ground (via the limiting resistors) which lights the light, so to speak.

When I started this layout I didn't really have a long term plan of what I wanted to finally achieve. And processor control of the signalling was far from being in my mind at that time.

If only I had made a plan! How many times has that been said amongst us all? And signalling didn't come into it.

Ah well, that's life I guess. At least I'm trying to keep everything written up and making notes of wire colours and where they start and finish and their purpose in the grand scheme of things. Which is helpful - until you look at the masses of wires strung all over the place under the boards and at the few circuit boards fitted wherever there was space to fix them. Plan? Nah!

I can certainly appreciate looking at other layouts and can only assume there is neat and tidy wiring under the layout. Or am I kidding myself? Mine started out relatively tidy, but then more and more wires were added and it become more of a jumble.

More to follow in due course.

Sol
A modelling Moderator.


Joined: Mon Nov 28th, 2011
Location: Evanston Gardens, South Aust, Australia
Posts: 4384
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Dave, Plans are like Rules - for the guidance of wise people & for fools to follow ( so one of my Engineer masters told me but heaven help me if I stuffed things up by not following plans/rules).
Of course with DCC you only need two wires.......

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

When you say the sensors need updating Dave, does this mean replacing or can you just re-programme a change in voltage ?

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Sol
But, as you say "Of course with DCC you only need two wires.......",  even then, two wires can still get mixed up and get you into a pretty pickle. Beats the two wire system of DC though, every day!

And PeterMac, yes thanks for the query. When I said the sensors needed modifying, I have taken it to mean all the sensor circuitry - i.e. the sensor parts (emitter and receiver) and the voltage comparator, all taken as a whole unit.

Fortunately it's just a change in the voltage to the LED that gets fed to the comparator output (see the diagram in my post #16). It's this connection between the LED (and it's current limiting resistor) and the comparator output (LM339 in this case) that gets fed into the processor's input. So while the comparator itself (and the actual sensors) are still working from a +12v supply, it's the switched-off state of the comparator that matters at its output - the output being open-collector and needs a supply voltage to make the LED work - and this switched-off state can be no more than +5v.

Hope that clarifies the situation for you.

Cheers all.....

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hmmm .........

I'm sure you know how to do it Dave - I'll just continue watching from the sidelines if you don't mind.... :???: :shock:

As I said to Bill (Longchap), electrics are for those with 17 eyes and antennae sticking out of their heads .............. :roll:  Do you have 360 deg. vision and a couple of antennae ?

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

I couldn't possibly comment Peter :lol:

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

And the automatic signalling saga goes on.... and on and...... One day it'll be done. It'll not beat me. Nothing much to add to that from 12 & 22 November, post #22, #23. So this is just an update of how progress is progressing (or maybe not quite so much progress and going round in circles of ever diminishing circumference!).
 
I had thought that this particular item was going to get a bit large for an "overview"/basics of "signals automation" and perhaps more suited to the "Signals" part of the forum. Hence, to read more about the signals, in more detail, head over to http://yourmodelrailway.net/view_forum.php?id=74 for various aspects of signals and signalling. This is more on the automation side of things.
 
Yet I kept thinking, was this project ever going to work; was it doomed from day one; am I wasting my time on such a complex project when a few simple LEDs and a couple of diodes here and there coupled with point switch settings would suffice? (it worked on my previous, but very much smaller and simpler, layout). Little did I know what was in front of me. A target was, however, set to get it completed.
 
And we all know what 'targets' are..... They're there to be missed, modified and re-scheduled (many times in this case!). Not helped by having an intermittent and very annoying fault on the laptop - that took time to find and sort out. And of course the "virus", while not (thankfully, yet) catching it myself, has had a marked slowing down effect of my works in the "train room".
 
This has been one of those projects that nothing works until it all works. And even by the end of December, still nothing worked! But I like a challenge and I enjoy electronics. So we battled on.
 
At least I now have it all - more or less - completed. The circuit board is all done and fully wired to the patch panel. The patch panel is wired to the signals and to some of the sensors. The software is about done and ready to load onto the microprocessors - but before that I need to complete the last few bits of wiring and checking each part and then running a test program on the microprocessors to check, if nothing else, that the signals at least light up correctly. And then there is the overall Track Diagram that will show "signals" and "occupancy"  in the hidden areas of the layout; part of it has been built but it's not necessary to the project overall so may be missed for the time being. And finally, the Home signal & Theatre Display board needs a few wires moving from one port to another and an update to its software.
 
In the meantime, this is a list of the components used:
two PICAXE 40X2 microprocessors - one for the Terminus signals, one for the Layout signals
one PICAXE 18M2 microprocessors - a "master" device monitoring sensors and controlling points and sensor data being passed between the processors
five ULN2803a - 8-port current driver for the signals
three ULN2003a - ditto above , but 7-port - these are for driving "up to" 61 individual signals/aspects (59 ports used)
two 7402 NOR gate - for generating a "yellow" aspect from red and green outputs
two 7404 Inverter gate - for generating a green aspect from a red output
many, many 1k current limiting resistors for the LEDs (all running from +12v)
signals are all Eckon, 2 or 3 aspect, either complete or just the signal heads
sensors are either RPR-220 combined Infrared Emitter/Receiver pairs buried into the track or Infrared separates used as across-the-track sensors
a few LM339 voltage comparators - to give a "clean" switch-over point for the sensors.
two 7805 +5v regulators

So once this overall project is complete, we will have this part of the project (signals) plus the Home Signal/Display module and the Level Crossing module all working together to achieve the goal of fully automatic signalling across the layout all (hopefully) working together.

All in all, at the rate I've been building this part of the project, probably about another two years should see it up and fully working. That's my new (and final) target and one I hope will be smashed by finishing it all in the next month or so.
 
I'll be back with the next, hopefully, completed project update - but don't hold your breath, it may be a few weeks yet!
 

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

If I understood any of it, it would be an amazing project Dave.

I got lost as soon as you started on your list of componennts although I do have a pick-axe .............. :shock:

I really am in awe of people who understand all this dark art stuff - for me, I'm chuffed to bits when I manage to fit a decoder (in a DCC Ready loco ! :lol:)  The minute someone mentions "relay", my mind wanders back to junior school and passing a rolled up newspaper on the the next team member without either stopping or dropping it ..............

Hopefully, you'll post a video showing the results of all this effort at some stage - I'd love to see what it's all about. :thumbs


Headmaster
Full Member


Joined: Sun Jun 2nd, 2013
Location: Faversham, United Kingdom
Posts: 1918
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

You are my kindred spirit, Peter!
Michael

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hmm. I'm not sure if I'm getting the impression this line of technicality is going down well with some of you.
 
Once I have it all up and running I'm not sure a video of it would really do justice to it all - seeing a set of signals change with the movement of a train is not exactly "exciting" stuff to watch. A change of signal aspects is just that, i.e. a change of colour LED being displayed and that could be activated from just a simple discrete switch, a change made via a sensor and a few diodes or something more complex by way of microprocessors, such as I'm working on.
 
I've always felt that working signals are as much part of a model railway as they are on the real thing - and that's what I'm trying to achieve; something that is fully autonomous to what is happening on the tracks and not something that has to be manually switched by the operator, maybe working the layout on his/her own. Running a layout on your own may not be the most relaxing pastime when everything has to be operated manually, hence the idea of automating some of it.
 
Therefore, this series of articles is to (hopefully) encourage the use of microprocessors in tasks such as these being developed here which, in turn, may make the operator's life simpler. OK, so it maybe a bit OTT, but if it gives someone else an idea that they can adapt it to, so much the better. That's been my idea all along. Each to our own.
 

Barchester
Administrator


Joined: Wed Oct 18th, 2017
Location: Linlithgow, United Kingdom
Posts: 1068
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave I'm actually in awe of what you are doing. I don't think its OTT at all. I know personally I struggle to hold information in my brain when it comes to electronics, and coding etc. I'm one of these 'Monkey see Monkey do' people !

I can follow instructions and these days try and make notes on anything even mildly complicated as the old brain cells seam to go awall more often :roll:

I for one am enjoying following your progress and the trials and tribulations as you work on it and although as you say the end result when shown, wont be THAT exciting, having followed along I am looking forward to sharing your sense of achievement !!

My impression is that both Petermac and Headmaster share my Awe and Im sure there are many other watchers with the same thoughts who only wish they had half your knowledge ? But it WILL encourage myself and others to 'Dip a toe in'  although maybe something not quite as complicated !

At the very least its persuading me to pull out the ' pocket Money' kits I got years ago from Merg that have been hidden at the bottom of the 'To Do' drawer and have a go :thumbs

Cheers
Matt

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Matt's right Dave - the fact that it's all a cloud to us doesn't stop us enjoying reading what you're doing and yes - we are in awe of your knowledge and skills.

I'm slow on the uptake with electronics (slower even than a GWR locomotive) but that doesn't mean I'm not interested - far from it !

Obviously I can't discuss matters like "why did you use this chip rather than that one" but my ghast will be well and truly flabbered when I see what these little black boxes can do ................ :shock: :shock:

The fact that you don't seem to get a deal of feedback is probably, as Matt suggests, most are just watching and wondering how in heavens name you manage to a) remember all this stuff and b) manage to work out what happens to your signals when you pass a current through them .................

I tend to agree with you that working signals are a big part of railway modelling but, for me at least, I still have my hands full just getting the track down.  Once that's done, I can have a look at other refinements although my signalling will be semaphore. ;-)

Longchap
Full Member


Joined: Wed Mar 25th, 2015
Location:  Saumur, France
Posts: 2206
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks for this in depth article on processor control Dave and also for Matt and Peter’s last responses which will mirror many member’s thoughts on this clever application. Well done and many thanks for your insights.
 
It’s also good to know that Peter is interested in slow GWR locomotives and frankly, who wouldn’t? The fast ones are pretty awesome too!
 
Keep safe all,
 
Bill

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

It's funny how this covid is getting to us all and how we react to things. But thanks to one and all for your comments.

Time at this end has been very limited for railway-related stuff, especially when sitting on a project that takes time to get back into after a break away from it of even a day or so even before something fresh can be achieved to continue from where it was left. Like many of us, my grey cell seems to take more holidays than I've had hot dinners. So apologies if I jumped off the wrong end of the plank and misinterpreted comments recently made.
 
This project is bugging me to get it finished but it's just taking so long even I'm getting fed up with it. But I will continue it to completion. There's been too much time and money thrown at it to bin it. I'm determined not to let it beat me.
 
In a few days or so I'll post another (possibly the final) "constructional" update on it and then just finish it off as and when time, mood and a fair wind takes me. Maybe a video will get made, probably of the track diagram board that covers the entire layout rather than of any specific signal or two. That way the entire set of signals and occupancy markers will be seen to change with a train running round. I wonder if I can do a split screen or picture-in-picture video with the editor I have [Lightworks] - that way I could show the train and the individual signals as well as the track diagram.  Even I'll look forward to seeing that!
 
OK. Back to the drawing board and see if I can fit in some more work on it without getting side-tracked on other "fill-in" projects - but maybe not until tomorrow - or the day after. Keeping focussed was never my best point!
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Back to the project at hand......
 
At this stage of proceedings, this project is still not yet up and running - I'm finding it somewhat difficult in these strange times to devote the time to getting it completed - doing one or two other small fill-in jobs for the layout, such as building a footbridge and a few cottages, etc. just so I can just dip in and out of them without worrying about where I left off whenever I get a few minutes to do something. But, having said that, this project is not that far from completion and I have every faith it WILL get completed and that it WILL work (more or less) as planned. With a project such as this, there will always be tweaks needed. So, as this particular item has been dragging on for quite some while, I'll give a write-up on it all at this point. If I wait until it's finished, it may take months before another update.
 
Essentially this unit brings together the Terminus (exit and sidings) and the Layout signalling (this part of the project) together with other modules (from previous posts here) all together as one larger module - the Terminus approach Home Signal/Theatre Display (post #1 and http://yourmodelrailway.net/view_topic.php?id=14501&forum_id=21&page=4#p281915) and the Level Crossing (post #9).
 
From my post #29, 8 Jan, I included a list of the components used. Below is a block diagram of how it all hangs together.
 

 
This shows how the microprocessors are connected together and what components are connected to each. Due to the lack of sufficient input/outputs ports on each processor certain inputs are shared across two or more processors using a data bus and the i2c data protocol. The protocol itself doesn't need to be understood - just the commands of how to send or receive data to or from the "master" processor (PIC3) and even the understanding of the commands can be challenging! It took me quite a while to understand where on each processor the bits of data is either being read from or written to - there can be three memory areas that can be accessed by the protocol and some are also normal variable locations that could easily be overwritten by the running program. Even the write-up for the commands can seem a bit complex in this respect and not overly clear. Or maybe it's just me.
 
To aid my understanding of the i2c comms, a small, simple program was cobbled together to allow some practice with programming the comms/i2c between a pair of processors (and a couple of switches) on a breadboard. This way I could get myself some understanding of writing and reading the data (settings of the switches connected to one processor or the other) and displaying the result on a couple of LEDs on the other processor depending on those switch settings. Anyway, I digress.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

The pcb layout (unpopulated) has previously been shown in my post #22, 12 Nov. This houses, from left to bottom right, PIC1, PIC2 and PIC3 for the Terminus signals, the Layout signals and the "master" processor respectively. The "master" reads some track sensors onto the small piggy-back/addon-on board and which also controls the inter-processor i2c communications. Other chips are, as noted in post #29, a pair of 7402 NOR gates that will generate a yellow aspect if both the red and green aspects are not on and two 7402 INVerter gates that allow a green aspect from a not on red aspect and the ULN2003a or ULN2803a current driver chips to feed power to the LEDs and so allow the processors not to become overloaded when driving above the current specification of the chip and/or of each output port. Plus the LED current limiting 1k resistors and a pair of +5v regulators for ALL the chips. Each LED, whether it be on the Track Diagram or on a signal head is powered from the more normal  +12v.
 
Incidentally, the current needed for an LED is usually taken as around 10-15mA, whereas to drive the same LED via the ULN drivers is around 1.4mA from the processor port - quite a saving on power that would need to be provided from the processor - and any number (within reason) of LEDs can be connected to any one output port of the ULN chip. The voltage drop across the ULN devices is around 0.9-1.0v so, in theory, to obtain the same LED current (and resultant LED brightness), the current limiting resistor would need to be around 900ohms rather than the more normal 1k (from a +12v supply). Personally, I hardly think the difference is that noticeable.
 
In fact, and to correct the statement above about the ULN driver chips feeding power to the LEDs, it's actually the other way around. The LEDs are all fed with a permanent +12v and the LEDs are turned on by the ULN driver ports being driven ON by a positive output from the processor, which then causes the cathode of the LEDs effectively being connected to ground (0v) via the internal Darlington output transistor pair on each port of the ULN device. Up to 500mA can be sunk through each of these ports - that's quite a few LEDs that could effectively be connected from one processor port (unrealistic as only two or three would be normally needed - the signal head itself plus any mimic/monitor LEDs).
 
As noted way back in my post #2, the programming is all in the BASIC language and which simply comprises a series of "IF this condition....THEN take this action" commands. I say "simply" a series of commands, but in reality there can be quite a lot of possibilities as to what action to take dependant upon the state of the next signal as well as the one after that and whether a train is already in the next section and also which way any points have been set beyond that signal. Simple enough where there is a long stretch of uninterrupted track with just a couple of signals to contend with, but add in a few points, maybe both diverging and converging, and it can be not quite so simple. At least the programming application has a simulation mode so the program can be tested either in slo-mo or step-by-step (everything except for the i2c comms). And this programming has taken me months to get it sorted, with many restarts as fresh ideas on how to do it came to mind. No doubt there's an even more compact or efficient way of doing it, but this appears to work (in simulation). And the processor itself is said to be capable of around 2000 individual commands per second - not that I've counted them! So it should be fast enough to cope with whatever might be going on.
 
As I've mentioned previously, overall there will now be complete control of the Terminus outgoing signalling (points still need to be manually set - maybe another day even this could be automated), the Layout signalling taking into account a working level crossing operated by servos activated by signals taken from in-track sensors together with the protecting signal that remains at danger until the gates are fully open for train traffic, right round to the Terminus Home signal and Theatre Display which shows the active (arrival) platform number and which remains at danger until a train approaches it - this to force the train driver to slow the train before entering the Terminus itself.
 
The past day or so I've been checking all the inputs (sensors, switches) and making sure they work as expected. And also the outputs (using a multimeter) before plugging the processor in. One issue I found has been a couple of signals (4 aspects) that are effectively wired wrongly (with a common 0v connection and not the common/permanent +12v as used elsewhere on here) and they are in a position I just cannot get to with a soldering iron and change. So a revised output has had to be made whereby I now take their red outputs direct from the processor and the yellow aspects direct from the 7404INVerter rather than going through the ULN drivers - although the track diagram will still work as originally planned - so maximum current capabilities of the processor are still within spec.
 
So, although it's not fully up and working as yet, that is the final plan that is coming close to completion. Hopefully it won't be too long before I can call it done and I can get back to operating the trains again and maybe adding a bit more scenic stuff.
 
So that's about it for automating signals (and the Level Crossing). Unless I can find the time to add a semaphore signal (or two) somewhere on the layout in place of a colour light signal. Something to think about, probably making use of more servos and another processor. And then maybe a project to update the Turntable as it doesn't line up 100% to the exit roads - it's close, but can at times be far enough out to cause a derailment.
 
As mentioned before and for clarity, I have no connection to the makers/distributors of the (Revolution Education's) PICAXE or the Microchip series of microprocessors, upon which the PICAXE processors are based, other than as a user.
 
So to recap this part of the project. Two processors, one for the Terminus controlling exit 6 roads/platforms, each with a two-aspect red/green signal on a gantry plus ground calling-on/positioning signals for entry into the sidings and turntable area. The second processor controls the flow through nine signals, three of which are hidden but visible on the Track Diagram of the layout. The signals are seven three-aspects and two two-aspect red/yellow signals. Each signal having its own sensor. Tied into this module is the Home Signal/Theatre Display processor controlling access to the Terminus. Also tied into this is the Level Crossing processor.
 
So quite a lot going on making automatic signalling across a layout a real possibility with a few processors, miles of wires, quite a few hours of programming time and a fair bit of patience.
 
That's it for now. I need a lie down in a dark and quiet corner with some soft, gentle rock music playing before I start on the next project.

Marty
Enjoying the Journey


Joined: Sun Oct 14th, 2007
Location: Perth, Western Australia, Australia
Posts: 6207
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

...and for a long time they used to control signals and points with a couple of blokes in raised boxes pulling levers.
The fact that these “blokes” were highly skilled humans with years of experience and logic capacity and that accidents were so very rare is a fair indicator of what you are trying to achieve electronically Dave.

Please keep it coming. I would like to do some microprocessor programming and automation one day and will look to your work for guidance.

You can do it, finish it off. It took me six months to rebuild the Llandyfriog Junction on NE with electronically actuated points. There is room in the Llandyfriog signal box lever frame for signal actuating levers... just need a roundtuit!

All the best

Marty

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

"Good grief" , I said to my mate, "that Dave bloke, he knows some stuff"  !!

I have absolutely no idea how you remember all this Dave, let alone how you learnt it all in the first place !   Did you already know what did what or did you come up with a function requirement and then find out which "black box" would do it ?

Is this the sort of electronic installation they would use on the real thing - albeit somewhat beefed up ?

Considerably less physical than Marty's muscle bound signalman pulling his levers. .......

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thank you guys for your continued interest in this section on automatic signalling. Perhaps a little background might be appropriate; a little insight into it all.
 
I have every admiration for those that pulled the levers in the signal boxes up and down the country that kept our railways running safely. But I also have admiration for those who developed the interlocking systems that go on under the floorboards. This system must surely be at the heart of safety and helped prevent errors by said signalmen pulling the levers.
 
The idea behind this project kinda follows along the lines from the Hot Chocolate song "it started with a kiss, never thought it would come to this" whereby it developed from a simple idea and it just went on and developed into what it is today. So yes, it started as an idea, then I started to look around as to the "how to", hardware-wise. Arduino boards or the PICAXE processors. Then the software. Programming.... The C+ language or BASIC. I've been playing with programming on and off since the days of the first Sinclair Spectrum (that shows my age! - but only with the BASIC language and dabbled with VB6) and I've always been involved with electronics repair - from the early radio sets (with valves - you know, the very old glass devices that glowed and got very hot) through TVs and into computers. The magic and thrill of repairing stuff has all gone these days as about the only thing you can do is board swap. That's not me; I like to get down to the faulty component.
 
And the joy of software programming is that it's possible to replicate the hardware inter-locking systems of the old manual signal boxes, only in software. And, I guess, in many ways it's very similar to the new, modern signal boxes that control huge areas of the rail network - only these are much, much bigger and more complex.
 
I started with the Home (approach) signal controlling entry to the Terminus. In the case of my John Street layout there is a double slip at the entry pinch point so that depending on the setting of that first point a train would only have access to or from either the UP or the DOWN line (no reverse running allowed here). So it was a simple check to see the setting of that single point. If it was set for the UP (incoming) line, then go and check other points settings to see which platform is accessible, set a green aspect and display the platform number on the display.
 

 
At this point I've not incorporated a platform occupancy test (no sensors in place).  But maybe there is a power-fail memory location I might be able to access and write to that area which could hold such data (without having to use sensors). Something to think about in the future.
 
That first part of the project worked well so I thought about trains departing the Terminus. Check the points settings and if a correct exit path to the Down line is set that corresponds to a particular platform starter button being pressed then set a corresponding green aspect.
 
There's a sensor buried in the track under the double slip such that a green aspect from either signal will reset that signal back to red following a train passing over it. For incoming trains particularly it also resets the occupancy of the incoming section. It's all in what can be done with the programming.
 
And so it went on - adding bits as it progressed; that's why it's taken so bloomin' long! The main problem was controlling the access to the sidings from the same processor. Just not enough i/o ports when each of the points needed monitoring as well as having all the signals coming from it. So I needed to find a way around this.
 
The built-in inter-chip communication system (i2c) was found. By using this I could share the points settings monitored by the Home signal and have them copied over to the Terminus processor. And then there was the methodology of having logic to provide a green aspect from just a red output, as noted above; anything to save on the number of i/o ports needed.
 
Then it was just another development to adding a third processor to control the layout signals. This also had a need to monitor the level crossing gates as to whether they were open or closed to train traffic. And again using logic to provide yellow aspects from just red and green outputs. Anything to save more processor ports.
 
So it's just like a building block game, adding sections and improvements as the situation demanded. Work still to do will be to add the positioning signals on each platform exit and to build up the rest of the Track Diagram (1 board out of 4 done) as well as finishing off a couple of sensors around the layout. So it's still work in progress with only time being the limiting factor to finally completing it.
 
Hopefully this has given a bit more of an idea of how it started and progressed to where it is today. But I'm sure more will be added to this project as time goes by - such as the platform occupancy idea.
 
Next up, I think, will be the turntable if I can find a way to retro-fit to what is already in place and given the awkward location of it. Looking at ideas already! Watch this space (but don't hold your breath).

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave C.  I am wading through your thread, it’s not your fault I am just a lazy reader. But I did spot the word “Horn” is that the same as in radio control model aeroplanes? My idea was to operate two points at the same time, but I couldn’t get the points to throw together. As for the Uncoupler I have been changing enough wagons for my Inglenook Junction , and using Kadee’s. Best wishes Kevin 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Kevin

I think these servos are used in model aircraft - the SG90 servo (below) - the horns being the plastic arms that screw onto the servo spindle. Why they're called "horns" beats me, I thought it was only bulls and various other animals that had "horns". :hmm It's a whole new vocabulary some of this stuff!



I'm sure you could use some form of wire linkage from opposite ends of one of the double-ended horn arms to simultaneously throw a pair of points, similar to the method I used for the level crossing gates as in my post #1 on 7 Aug 2020 - not the first attempt to direct drive the gates, as in post #10. Substitute the single arm for the double arm, and a couple of lengths of stiff wire to drive the point mechanisms. Personally, I've not used servos to switch points, but I've known it done.

Good luck with it.

Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

I've used servos to control points in the past on Maxmill Mk 1 - via the Megapoints system.

They worked very well, were virtually silent but I did find them a bit fiddly to set up.  I will be using them again on parts of Maxmill Mk 2.

Your latest posts are starting to make a little more sense to me Dave. :thumbs  As with most things, when one breaks it down into manageable chunks, the clouds usually thin a little.  Trying to look at the whole project was certainly overloading my few remaining brain cells .....................

I'm still totally in the dark about what goes on inside those little black boxes but, as long as they dod what they're supposed to do, it is of little importance how they actually do it...............  Half the skill is surely in knowing which black box does what !!

I also think maybe, just maybe, by reading your posts and trying to get my head around what's going on, instead of simply shutting down, pennines are starting to drop - very small pennines maybe but at least they're dropping !!!

A year or so ago I would never have believed I'd ever have any interest whatsoever in electronics, beyond knowing what the end result is.  Now there's a spark so headway is being made and I thank you for that ....................... I think .........................!! :mutley

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave.  The “Horns “ that I have aren’t straight they are like elbows, and I think that is how they got their name.I am using wire in tube for my point control but it is limited. As for signals, I have two Triang semaphores which I am considering controlling, without the hand 🖐 from the sky.  Best wishes kevin

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Good luck Kevin with the semaphores. Hope it works out for you.

As for the couplings, I've looked at the Kadee devices and it seems an awful lot of messing about, especially if a lot of the rolling stock is not "modern", shall we say. I've a right mix of couplings, some NEM, most not. Some link up easily, some don't (different heights, etc.).

One day.....

And Peter

Like you, I don't quite understand these little black boxes as you call them. All I know is if you prod them in the right manner, they'll (hopefully) do something constructive, otherwise they'll do nothing and they give you no clue as to why.

It's all about learning - and I've been doing quite a lot of that lately with this project - and I'm still doing some more learning even now (see the next post).

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

An update on part of the circuitry used to drive the signal LEDs - I found a flaw in the design - or rather the wiring! (that's life). The circuit design worked ok (it did on the breadboard!). The fact is I didn't appreciate at the time of wiring two signals that they were being wired differently to every other signal that would later be connected! And that has caused some confusion in how they get wired to be compatible with the rest of the signals. They were installed very early on in the building and signals installations - long before this automatic signalling had been really thought about. That's my excuse! Plan? What plan?

I'm specifically talking here about the logic 7404 INVertor chip that I need to use to effectively change the polarity of the supply for the LEDs on two 2-aspect signals that were wired up conventionally, and not like the remainder of the LEDs which are fed from a permanent +12v with the LED cathodes being switched to ground via the ULN2003a drivers to turn them on.

Looking at the specification sheet for the 7404 it shows a sink current of 16mA - that is power that the chip will accept at its output pin to pass to ground, sufficient to light an LED, i.e. +12v > LED > limiting resistor > 7404 plus PIC output > ground. And this is fully acceptable for my needs for these two signals. It works.

The way I have currently wired the circuit board is PIC output > 7404 > 2303a > LED > limiting resistor > +12v. And it won't work! Well, it does but the two aspects are on at the same time - NOT ideal (or wanted). Connect the LED to ground rather than +12v and it fails to light.

The answer? Remove the 2003a (which re-inverts the logic signal - already inverted by the 7404) and connect the PIC output > 7404 > LED, remembering to change the limiting resistors from the standard 1k (for the +12v) to something like 300R (for a +5v from the 7404) > ground. Now it works again.

These breadboard devices are very useful for prototyping and trying things out and is something I should have played with before committing the pcb. Their only problem, I find, is that the components don't always connect 100% to the holes in the board and things can be a little intermittent if any of the jumper wires/components are touched.

And there has always been a bit of confusion in my mind with a lack of complete understanding of the links between the terms IOL, IOH, sink current and source current, high state and low state.

For the sake of clarity for those who may be as confused as I was (maybe still am):
IOL is the Low state, i.e. logic "0" (or 0v), and it's the amount of current the pin can accept (sink) to pass to ground (or another chip). In logic chips terms, IOL is around 16mA.
IOH is the High state, i.e. a logic "1" (or +5v), and it's the amount of current the pin can pass (source) FROM the chip. In logic chip terms, IOH is around -0.4mA. And the minus figure confuses me even further. It seems it's because the current is effectively flowing the wrong way. Positive figure = into the chip, negative figure = out of the chip, i.e. it doesn't/shouldn't. Not if you want or need to keep the logic value of "1" at that pin. Any figure above 0.4mA being sourced here and the voltage at that pin will drop from it's logic "1" value. But it is quite possible to drive the base of a transistor or FET by this pin or to drive an LED with a small amount of current; to much current and the LED fails to light due to the drop in the voltage from the pin.

I think I've got that right even if it still might not make a lot of sense! If you weren't confused before, I'm sure you will be now - so apologies for that! I've not really used much in the way of "logic" devices until now; mostly I messed with "analogue" signals, not digital. That's my excuse!

But if anything, I think I do understand it more now I've given it a bit of a write-up. Give it a minute or two and I'll not be quite so certain once the grey cell has had a lie down!

If I have any more thoughts - or it there are any questions - I'll come back to it.

I'll add a photo of the breadboard and the circuits used for parts of the signalling in  the next post.

Last edited on Fri Jan 22nd, 2021 12:00 pm by Dave C

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Signals LED circuitry:



In the breadboard photo, the chips are,left to right, ULN2003a, 7404 INVertor, 7402 NOR gate with pin numbering on each chip from bottom left being pin #1. The output from the PICAXE is simulated by jumpering a couple of wires to either +5v or 0v.

On the ULN2003a the inputs (being simulated from the PICAXE) are applied to pins 1 (green) and 5 (red). The outputs are taken from pins 16 and 12 respectively. These then go via their 330R resistors and the LEDs to the permanent +5v supply (+12v and 1k resistors when on the board proper). The ULN2003a ground point is the blue wire on pin 8. The 2 logic chips have +5v on pin 14 and ground on pin 7.

For a (missing) yellow aspect: The yellow signal is derived from the two simulated PICAXE outputs (R&G wires) and taken to the input pins of the 7402 (pins 2 & 3). The output from pin 1 (yellow wire) then goes to the ULN2003a pin 7 with the output on 10 which then goes via its 330R resistor and LED to the +5v supply. In this manner, there is a yellow aspect lit if and only if both the red and green aspects are off. That is using the less-than-conventional wiring with each LED connected permanently to the positive supply line and the ground being effectively switched by the ULN2003a. Two output pins, three signal aspects. See the diagram below.



To power the two "conventionally wired" signals the output from the PICAXE red output is sent also to the 7404 INVertor chip on its pin 1. The inverted output is taken from pin 2 to the 330R resistor and the green LED (far right) to ground. The red aspect is taken direct from the same PICAXE output via the 330R and LED to ground (now on the breadboard). One output pin, two signal aspects: Red on, Green off, and vice versa.

Total current from the PICAXE across all signals is around 100mA and well within its specification when driving most signals via the ULN2003a driver chip(s).

That might help explain how this lot is actually wired when it gets to the layout. So a minor change to the pcb is required and then it'll be power-up time.

Hopefully, this might give a little background into wiring signals from logic or microprocessor circuits, always being aware of the current capability of each output port and of the device's overall total current capability.


TeaselBay
Novice
 

Joined: Fri Aug 4th, 2017
Location: United Kingdom
Posts: 1089
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Looks great. I like the use of not R and not G turns on Y. You can also duplicate this for signals with just red/green easily. Look forward to a video of it running. 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

This project has been moving along nicely - even if very slowly these days. Completion is getting frighteningly close to when the processors get plugged in and testing the software can start.
 
The various sensors have been mostly installed (and modified where required so that the in-track sensors do not "see" inter-truck coupling gaps). I'm in the process of having to re-do one sensor board due to a wiring mishap. The sensors still missing (different sensor board) are in the shunting areas - these can always be added later - I'm wanting to get the main layout completed, that has been the primary concern up to press.
 
The signals have all been checked, and after a short panic due the wrong LEDs lighting up caused by one plug being shifted left by one pin, all now looks to be good. The reverse wiring requirement of a couple of signals has been sorted - most signals use a common +5v (switched return connection) while these two use a common ground (switched +5v as normal). There's nothing like standardisation - or forward planning! And the points have also been wired in to the main circuit board and checked. Likewise the platform starter buttons have also been checked.
 
The track diagram boards are still work in progress; board one has been done; 3 to finish.
 
Also still to be done: the Home signal module needs a couple of wires moved about due to the communications ports now being needed that currently hold other functions connected to them - and an updated program to be installed. And there's more...
 
The level crossing needs to be checked to ensure that the gates open/close to the correct positions and the open/closed signals are being set correctly for the next processor in line.
 
Soon it will be time to insert the processors and then we'll see how it performs for real. And then.... If only I could keep focussed on one job at a time.
 
Thoughts have been had regarding the next project - modifying the turntable - it currently doesn't always align correctly to the exit tracks. And it's too far away from the operating position to tweak manually. At this point I'm looking at using a small stepper motor and (you might have guessed) a PICAXE to control it.
 
There is quite a lot of experimentation to be gone through before I commit to anything. Thoughts are to use the 28BYJ-48 stepper motor - very small with a reasonable strength behind it, more so once it has been modified from its unipolar style to bipolar. These motors are very cheap from the far east (delivered in unipolar mode) but to use bipolar mode it needs a different board/driver chip to operate it from the ULN2003a driver usually supplied - it will require a L295D H-bridge chip. I do still need to find a method of setting an index position from which everything else will be calculated.
 
My problem is the turntable is installed into the baseboard and everything fixed up to it - but then after a while it was noted that it didn't really align too well. So whatever needs to be done needs to be carried out in situ - and with very little room between the well underneath and the tracks that run under it, it ain't gonna be easy. I can foretell the air is likely to become a little blue!
 

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave.  Have you ever thought of “ Manual Control “? Are you a member of DOGA? Colin a committee member has got a layout and the turntable is worked by a bit of Meccano Kit out of sight under the baseboard. Best wishes Kevin

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Kevin - hadn't heard of DOGA, but will check them out later.

As far as manual control is concerned, the turntable is way over the other side of the layout and some of the exit roads I can't see clearly enough (totally wrong angle of viewpoint) to align the TT to the tracks. So whatever I do, it's got to be some form of automatic indexation.

But thanks for the thought.

Edit:
Back after a few jobs done - and a quick look at the DOGA turntable idea. Talk about simple! Effective though. Shame there's no photos visible, no doubt lost in the sands of time given that it goes back to 2003. But good line of sight is needed for anything manual such as this. And that is, as I mentioned above, is my big problem. Side-on sight of an exit road and, given my ageing eyesight, even the mostly straight-on track alignment would be a problem. So I have no option but to go with some form of automatic alignment - and I always like (prefer) the DIY approach. I always get so much satisfaction from designing/building something myself. So back to the drawing board.

But appreciate the pointer - that idea "could" possibly come in handy for some other project yet to be thought about.

Last edited on Fri Jan 29th, 2021 07:37 am by Dave C

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave.  Sorry but I couldn’t think of the name in full, but I put on my thinking cap, and it is Double O Gauge Association.    Best wishes Kevin 

TeaselBay
Novice
 

Joined: Fri Aug 4th, 2017
Location: United Kingdom
Posts: 1089
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Passed Driver wrote: Are you a member of DOGA?
Sounds like a completely separate forum...  :mutley

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Chris.  DOGA may have a forum, but, I haven’t heard of one. They do have a small stand at model Railway shows, i can vouch for that as I had a fainting session? At the Birmingham show the other year, black Mark for Kevin, when I fell into their stand, and a News Letter, even a get together .in London. Best wishes Kevin

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

As an aside to the automatic the signals and to give me a break from it (I just can't focus on one thing at a time!) and more thoughts following on from my last post on the subject .... And as I have had an enforced lull in proceedings due to a very slow delivery of solder - it might be coming first class post, but if it takes the guy over a week to put it in the post, what's the point? I need the solder to renew a couple of sensor circuits.
 
My recently bought solder reel, which I had bought in good time, appears to be pretty useless when it comes to using it. It seems to heat when trying to solder into something like paste and not flow like it should, not like my old reel of solder. Both were 60/40 fluxed solders. Maybe some additional, separate flux might help. Anyway, so while I'm waiting for the new stuff to arrive - hoping this stuff is going to be better - I thought I'd add a bit of a write-up on adding/renewing indexation to my turntable.
 
So the following is more regarding methods of getting indexation to a turntable rather than how to implement it being automatically controlled by DCC. I have no knowledge of how to implement DCC to operate such a unit, but no doubt there are ready made kits out there that will do the job.
 
Indexation. A bit of background on the indexing options, each has it's own for's and against's:
Mechanical - using microswitches;
Electromagnetic - using Hall effect switches - oh, and a magnet (what else?);
Optical - using infra-red LEDs.
 
Mechanical: probably not the easiest to install or setup and switches can (are) "noisy" devices, i.e. (a) they don't always switch at the same point, and (b) at the point of changeover the contact can "bounce" giving unpredictable results. A "clean, repeatable " changeover is absolutely desirable. Hence, the following options.
 
Electromagnetic: easy to install with no power requirements (on the turntable deck). Although I've yet to have a try with this, I can foresee a problem or two - mostly the activation point of the Hall effect sensor and this can depend of how strong the magnet is and how far away the Hall effect sensor is from the magnet.
 
One problem here is that the sensor is likely to trigger at differing points depending on the direction of deck rotation, giving rise to an alignment error. But having said that, this is/might be my option of choice.
 
Optical: easy enough to set up despite the need to find a source of power for the Infra-red emitter.
The source of power could be taken from the supply to the rails but only if running DCC - with DC running, this doesn't work. But with the turntable in situ and not easily removable, this might not  be quite so easy.
 
Again, I have yet to have a good look at this but I think that a small diameter hole could be drilled into the well or the side of the turntable and the sensor receiver made to align with what should be a very narrow beam coming from the emitter.
 
Another optical option is to use a slotted disk through which to shine an Infra-red beam using an optical interrupter as used by Locomotech and currently fitted on my turntable but which, unfortunately, tends to lack accurate alignment depending on whether the deck is rotating clockwise or anti-clockwise. I'm not rubbishing the kit - it just didn't work for me. Other than the indexation disk, it worked perfectly and quietly - but I'm not in an operating position to physically see the alignment to some tracks for which it needs a tweak of adjustment to prevent derailments.
 
Hence I'm now looking at a retro-fit of another method of alignment and the change from the current DC motor to a stepper motor.
 
If you choose to use the Hall effect switches (with a magnet), beware there are two types of switch available: analogue and digital.
 
The analogue type produces an output that is dependent upon the strength of the magnetic field, i.e. the output varies. It's then up to the designer of the electronics to decide, with the aid of a voltage comparator, at what value of magnetic field strength to make the switching point. The digital type, on the other hand, has a fixed switching point using the internal Schmitt trigger. A commonly used type being the A3144E. Once the Hall effect switch makes the switch between states, it's a simple matter to count the number of steps to make the turntable align with one of the tracks - all other turntable stopping points (tracks) can be counted from that one initial point.
 
At this point I am tending to try the Hall effect switch&magnet with the optical Ir method (using a small hole in the turntable well) as a backup option. I've no idea how either will work and I need to try things out using something other than the installed (non removable without a lot of hassle!) turntable. With either method, it's all about counting the steps between each exit road and the initial power-up point. Work on this may move along somewhat slowly (as does most things in the Train Room).
 
Essentially, for the motor using any of these indexing methods, you would need to make use of a stepper motor. A bit of technical info next, but info that is needed for the correct operation of the turntable.
 
Looking at the 28-BYJ48 (sometimes known as BYJ48-28) small stepper motor it takes 4075.77 steps to make the 360 degree deck rotation using the internal 64:1 gear train. That is, using half-step mode; with a quoted 5.625 degrees per step of the motor and with 64 steps per one revolution of the motor shaft (gear ratio being 64:1 - or 63.683951:1 to be more accurate). Even these figures vary slightly depending of whose information is read. I get the impression there have been different gear trains used in these motors, one that gives near 4076 steps and another that gives 4096. So either figure would indicates a step size of about 0.088 degrees per step of the motor - I think that's accurate enough for most alignment purposes.
 
Most of this write-up is a bit of future thinking and is certainly becoming work in progress (when I find the time). I've written a small program to test the number of steps per 360 degrees and I've been building a jig to run it before I dismantle the turntable. In the meantime, it's back to the signals (again) once the solder arrives.

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

The new reel of solder finally arrived! But unfortunately time to use it has been almost non-existent - or rather the availability to get into the Train Room to use it. Time has not, however, been entirely wasted. Computers are a wonderful thing. I've stepped back from the signalling for now but I'm continuing to progress the likelihood of upgrading the turntable - and this has now taken over my thoughts.
 
I've been working on a program to operate a stepper motor. All track locations are setup the first time the program is run - the magnet is first located by moving the deck anti-clockwise; it then waits for a move clockwise to the "home" (main track) position and then to each of the other exit roads and each stop position is "saved" to the processor eeprom. The turntable then moves under its own power to the first exit road and waits for a manual move anti-clockwise back to the "home" position, this is again saved to eeprom. From the two "home" positions the amount of backlash of the motor/gearbox is calculated and this is also saved to eeprom. That's it for the setup. In normal runtime mode the number of steps is calculated from the current initial "home" position with an allowance for the backlash to the next desired position depending on whether this move is clockwise or not and whatever direction the last move was (CW or CCW).
 
That's the theory - the program seems to work in simulation mode. All I need now is some time in the Train Room to see if it works out on a jig - i.e. the motor with a spindle rammed into a piece of wood (turntable sized) and a fixed piece of card to mark where each track could be - and then to see if it does actually align correctly each time, whether it be turned clock- or anti-clockwise.
 
To minimize any backlash in the gears, a planetary type of gearbox can be used instead of the more normal - and far cheaper - ordinary type of gear wheels on shafts. But that puts the price of the entire motor at a premium (they seem to come as a pair). Whether the slack of an ordinary gearbox is something that can be worked around will be dependant upon the motor/gearbox combination. I may be about to find what the slack is in the cheapo BYJ motor. I hear it's not brilliant. What can you expect from a motor that is less than the price of a pint?
 
If the BYJ stepper isn't up to the job, the next stage would probably be to source a motor of more suitable strength - there appears to be very little made or stocked within the UK that gives the resolution of the small BYJ stepper. But the price! By the time the import duties, etc. are added, anyone would think I was wanting to buy the company! Maybe that's a failing on my part of living with the prices of the past.
 
Be interesting to see how it works - with the BYJ stepper firstly. I've checked the operation of the Hall effect switch and with the small 4mm dia. round magnet I have, the switch senses it from about 6mm away from the magnet's south pole (the north pole does nothing!). So that gives me something to look at when mounting the magnet on the deck (the switch will need to be hard up against the turntable well).
 
Once this jig is complete and tested, things should move along quite quickly to finding a method of mounting it under the turntable deck.  More reports to follow when I progress things further. And maybe I'll get a video put onto YouTube of it in action.
 
One day I'll finish the signalling! I must get back to it sooner or later. It's been dragging on and on but I've re-constructed one sensor board. I had tried to modify what I had so that I could implement a sensor release delay so that inter-truck couplings would not be seen. Not a success, so a fresh start was made. It simply involves an additional resistor, a capacitor and a diode per input. The delay (hopefully) being about half a second.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

It's been a while since the last update. I've not been totally idle - pretty much so, but things have been happening in the background. Further work has been happening on the turntable. This needs to be fully working before I get back to the automatic signalling project. On my layout, trains will run without the signals, but the turntable is pretty much an essential part, being still in the steam era.

The latest is that the turntable is in and working with a new stepper motor (NEMA17) plus a Sparkfun Easy Driver board and the PICAXE processor as the controlling unit. The final stages of programming the processor are in process - a tweak here, a tweak there then see what other parts of the routines have been upset as a result of these tweaks - then start tweaking again!

Not far off now. Full details will be forthcoming on this on my John Street layout page, the turntable saga starting at (http://yourmodelrailway.net/view_topic.php?id=14501&forum_id=21&page=7) from my first attempt using the small 28BYJ-48 stepper motor and ULN2003a driver right through to where I am now - currently on page 9 (and soon beyond).

More updates as and when - but we're starting to get into the caravanning season (once the weather improves) and that means more away time and less train time. Such is life!




Last edited on Sat May 22nd, 2021 06:19 am by Dave C

TeaselBay
Novice
 

Joined: Fri Aug 4th, 2017
Location: United Kingdom
Posts: 1089
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Still keeping up.. as best I can anyway! Haha

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Finally I got back into the Train Room and squeezed my way in and under the layout and fitted the new stepper motor in place of the DC motor and its brass indexation disk. It was quite a squeeze and numerous bouts of cramp were felt due to the strange shape my legs had to get positioned into so I could get into the space and fit the new motor, etc.
 
The 28BYJ-48 stepper motor was scrapped due to the gearing and the amount of unreliable backlash found - I couldn't program the backlash into the software; it was too variable. Therefore a stepper motor was used instead - a NEMA 17 12v 400mA per winding. In order to use this motor without the need for a lot of fiddly programming, I made use of the Sparkfun Easy Driver board - this uses the Allegro A3967 chip and allows the motor to be run simply by having two signals from the processor board (PICAXE 18M2+), the DIRection signal and the STEP signal which will move the motor one step for each positive-going pulse. The ED board allows the stepper motor to work at a maximum stepping rate of 1/8 stepping, thus giving 1600 steps per revolution. The motor tends to be a little bit noisy in use; whether this is the motor style itself or the method of fixing it on a relatively thin piece of board that might be amplifying the noise. To make things a bit quieter I may purchase the Big Easy Driver board - this uses 1/16 stepping with 3200 steps per revolution.


Method of mounting the stepper motor - the Hall effect sensor can be seen against the turntable wall (with the blue output wire).
 

PICAXE board with the 18M2+ microprocessor and the small motor speed adjustment preset resistor.

All movements are based on an initial power-up search for a Hall effect sensor which is placed against the turntable well outside wall about 10deg. counter-clockwise from the main track; it's also used for any re-alignment during run-time in case some drift occurs during running. The switch has a maximum of about 6mm separation using this magnet before it fails to be "seen" and fails to change state. The magnet was fitted under the turntable deck as far forward as possible without it catching on the well brick paper cover. This is fitted in a very similar method as seen on the Nov 2013 RMWeb page: https://www.rmweb.co.uk/community/index.php?/topic/78578-dcc-controlled-peco-turntable-project-using-a-arduino-uno/ except my magnet is glued onto a small piece of high density foam rammed into the same space under the deck, between the two main beams. Other than the magnet mounting location, nothing is the same between the RMWeb article and my construction. But it's never-the-less a useful article to read through.
 

Method and placing the small magnet under the deck - this is viewed from the underside.

Then came the testing of the program in simulation mode, and after a few tweaks here and there with the aid of some debugging commands, it all worked perfectly. Also written into the software is a short routine for acceleration and deceleration of the deck at the start and end of each move.
 
My turntable simply has one in/out track plus one exit into a small engine shed. The program can, with a few adjustments, be written/updated to allow for any movement from one track to another, depending on the specific layout, but it would add another layer of complexity regarding selecting the specific track required to turn to. But, as it stands, the turntable works for me and seems it will work acceptably well.
 

Turntable in situ.

All in all, the components are:
Peco LK-55 turntable;
PICAXE 18M2+ microprocessor;
Sparkfun's Easy Driver board;
A3144E Hall effect switch and a small magnet (5mm dia. x 5mm);
Two 5v regulators (7805) - one for the processor, the other is currently spare/surplus to requirements at the moment;
Decoupling capacitors, 0.1uF and 100uF to keep the supplies steady without spikes or ripples on the voltages;
A few resistors to hold the processor input ports at 0v and one resistor to hold the Hall effect switch to a "high" (+5v) level - the magnet pulls the switch output to a "low" state;
A small pre-set resistor to adjust the rotation speed;
The 4 small push switches on the (setting-up) control box, salvaged from an old printer (CW, CCW, Reset, Save position). And the control box was also re-purposed;
Two push buttons on the mimic panel and a direction changeover switch;
and a 5mm-to-4mm rod coupling;
And that's it - apart from many hours of (BASIC) programming (and simulation tests) to make it work.
 

The difference between the no-longer-used 28BYJ-48 and the NEMA 17 series of motors is that the former is a unipolar motor (5-wires) while the latter is bipolar (these can have 4, 6 or 8 wires) and each motor style needs a different method of driving them. The unipolar motors are ok with the ULN2003a chip while the bipolar needs an H-bridge arrangement, either directly operated by the processor or via an add-on board as I've used (this takes all the overhead processing from the processor and its program of how far the motor needs to move each time).
 
For those who like to see a moving turntable, a video has been posted on my YouTube page at: https://youtu.be/RAqhEKJtn5A
 
Next stop - back to the signalling - after maybe giving the trains a run.
 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

It's been a while since I last posted any updates. So I thought I'd give an update on where we're at at this point in time.

Following on from the (eventual) success of the long running turntable saga that seemed to be never ending, life finally returned to the subject of the automatic signalling project; this is after some decent weather and a number of trips out and away in the caravan (together with numerous other interruptions - otherwise known as illnesses and "life"!). But not before I got round to installing a long forgotten Ground Positioning Signal (for Shunting back into the siding at the small Halt station). It took ages (many days in fact) to find where it had been put for "safe keeping"; and while I was on with thoughts of the GPS, I decided I would also spend a further few days trying to find where I had put the Positioning Signals (two white lights) that will allow a loco to move forward against an otherwise red aspect into a siding area; the Train Room is such an untidy place! After much tearing out what little hair I have left, I finally got them all found - not that I'm going to do anything with the Positioning Signals just yet a-while - but I needed to find them for peace of mind if nothing else; they'll soon be needed in the Terminus as part of this overall signalling project.
A few problems with the Ground Positioning Signal came along (mostly light bleed into an unlit aspect), but finally it was reconfigured and is now in position and wired into the signalling boards - see my post under John Street for more on this signal itself (https://yourmodelrailway.net/view_topic.php?id=14501&forum_id=21&jump_to=304264#p304260).

Returning (at long last) to the Automatic Signalling Project:

First job was to check the signal aspects and this proved simple and easily and quickly checked. Next on the list was to ensure all sensors were wired up and working correctly before I progressed further. One block of four sensors did not fill that criteria; two were fitted but needed adjustment - the other two were just not there at all!

One snag I found was that, now that I am automating the signals somewhat more than I had previously thought, which also included occupancy detection (of sorts), and a need to detect the entire length of a train and not just the loco (which already has a small piece of silver foil stuck under each belly, this being easily detected by the in-track sensors), the underbelly of coaches and trucks were not reflective enough to be detected by these sensors and I didn't want to have each and every coach and truck with silver strips of foil stuck underneath. This has meant having to replace each in-track sensor with an across-the-track sensor and to effectively hide them from view, blending into the scenery, etc. Not so easy when two of the sensors are on a double-track part of the layout. Hence a few low lying bushes have suddenly sprung up between the two running tracks to hide the infra red emitters; the sensors are hidden elsewhere not too far removed from the track side either in more bushes or inside buildings. The line of detection needed to be at an angle to be high enough to be blocked by the coach/truck body (not the through wheels) and at such an angle along the track so as not to see the inter-coach coupling gaps.

For those with figures and more detail on your minds:
with the RPR-220 emitter-sensor pair buried into the tracks, the voltage swing between sensing a coach/truck or nothing was around 0.5v with a +5v supply and a 470k resistor in the receiver collector circuit (refer back to https://yourmodelrailway.net/view_topic.php?id=16438&forum_id=7&page=1#p296757 which gives the circuit details). And a 0.5v voltage swing was certainly not enough to be considered stable enough for detection by the LM339. Back to the drawing board then.

The idea of using across-the-track sensors was again looked at but with a gap between the emitter and receiver (on one particular sensor position) of around 10inches (255mm) the sensitivity of the circuit was a little lacking. I tried pushing up the emitter power, perhaps beyond its undisclosed rated value, to 70mA. This made a slight difference in the sensed voltages, but not enough to be overly comfortable. So the emitter current was dropped back to 35mA (I think a normal maximum value would be 50mA) and the sensitivity of the receiver checked with differing collector resistor values. At 100k (more normal for a +5v supply) there was little difference between states; at 470k things started to look a little better and with careful alignment I could get a difference of 1.25v between train and no train on the test bench. I then tried increasing the resistor to 1M and at this point I started to get the inevitable 'leakage' current through the sensor and possibly also the LM339, but the train-in-position voltage dropped to 2.9v - giving a nice and acceptable 1.5v difference - all this on a +5v supply. I eventually settled for a 680k resistor which gave me, when emitter and sensor were fitted and glued into place, 4.52v blocked and 3.37v clear path giving a difference of 1.15v over a distance of 9.75inches (250mm). On the test bench I was able to get a usable voltage difference over a 15inch (380mm) gap, but the difference was starting to become minimal.

So that's been fun! This is what this hobby is all about for me - experimentation to get an end result that suit the situation.

So now I have to go back to the software side of the project and make a few changes in the program to reflect the change from in-track sensors - where I had need to add additional code to compensate for the gaps between coaches (the couplings). The only in-track sensor is now only going to be "looked at" when a train is reversing into the Halt siding. Overall, it should make the program a little faster.

That's it for today - hopefully I may get out for a breath of fresh air and stretch the legs this afternoon and then (just maybe) I can get back into the train room and get the new sensors fitted onto the layout.

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave C. Reading your thread reminds me of one of my ideas, after years of lighting up the night sky, when “ Motoring over the end of the third rail while working on London Underground , followed by the Arc. The modus operandi that I chose involved a magnet under the motor bogie, but now I cannot see that there is enough space between the track and underside of the bogie for a neodymium magnet, as 2mm is the thinnest one I have seen advertised. Best wishes Kevin

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Thanks Kevin

I recall the arc of the LU trains many moons ago when I lived/worked down that way. And also on the Southern 2-BIL,2 -HAL, 4-LAV, etc. units when I lived not 25 yards from the main south coast line (not that I knew the nomenclature at that time - they were just trains that rattled the windows to me at age 5 or so). I'm sure the drivers did the arcing on purpose!

You mention the small magnets under your locos. On my first layout I used that sort of thing riding over a reed relay across a couple of sleepers just beyond a signal. It worked quite well. Everything then was done using nothing much more than diodes and suitable voltages applied. But that was only used to trigger a signal from green to red - I can't recall how it went back to green again - probably using more diodes further down the track when the next signal went from green to red.

And as the track on this layout was already laid and cutting the rails to allow for current detection was not feasible there had to be another way of achieving the same result - detecting the presence of a train or part of a train on a given section of track and to light up an LED on a track diagram to give a visible indication should the train be in a section of track hidden from view.

But these days I'm wanting to use microprocessors which will not just change signal aspects but also simulate track occupancy. Namely, so long as a loco, coach or truck is present in a section then the section before that signal will not become "clear" and the previous signal will remain at red. A sensor is placed across the track so that once blocked by a loco it immediately trips the signal (signal B) just passed to red and puts that section as occupied. So long as that sensor remains blocked by the remainder of the train the section just being left remains "occupied" and the previous signal (signal A) remains at red. Once the final coach has cleared the sensor, that is when that previous signal (signal A) is allowed to go to a yellow aspect (in the case of a 3-aspect signal). It is, I guess, a software version of (in the real world of full sized trains) the more modern track circuit where a wheel-set/bogie makes a "circuit" across the two rails and a small current is drawn between one rail and the other and it's this loss of the voltage on one rail which is in turn used to indicate something is on the track in that section of track, i.e. section blocked.

This was never thought about when I first started this layout. The initial idea being to simply change signal aspects. Then the problem came about of the in-track sensors not being able to properly detect the presence of a coach or truck for the track occupancy. New sensors, update the software.

This is how the layout has developed over time. Start with the basic and then think about what might come next - and then solve the problems caused. If I had a plan....... how many times have I heard that?



Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave C.  Thank you for your reply. My idea is to mount the “Reed switch “ under the baseboard with the LED on the surface. The idea works well with a non motorised bogie or a wagon etc. But it has to be on the lead/tail end,As for signal control, I like your idea but it isn’t for my Plank. The so-called professional dealer seen at the long missed model Railway shows, where I had seen various ideas that didn’t appeal to me, but two rail models cannot follow the true system, meaning the two running rails only carry the track circuits which isn’t possible with modern models. As usual I am running out of steam.  Best wishes Kevin 

Passed Driver
Full Member


Joined: Thu Feb 19th, 2015
Location: Peckham, United Kingdom
Posts: 4271
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

Hi Dave C.     More info? I wasn’t  old enough to have a Tin Plate three rail system, but, I did see a circle of “ O “ gauge track with tin plate trains running around, arcing as well, I don’t know if that third rail could allow track occupancy or track circuitry. Best wishes Kevin 

Dave C
Full Member


Joined: Sun Oct 26th, 2014
Location: Doncaster, United Kingdom
Posts: 272
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

This automatic signalling project just seems to be never ending - there's always something getting in the way of getting it completed.

Only the other week I bought a new loco (as a treat to myself as it fitted in very nicely with the timescale of the layout). Only problem was that it didn't like one set of trailing points and kept derailing. The main issue was this set of points is buried under the main terminus throat and far from easy to get at. There's more to read on this at https://yourmodelrailway.net/view_topic.php?id=14501&forum_id=21&jump_to=305347#p305335

So that took a couple of weeks to sort out.

Then there was an errant couple of sensors I thought had been installed - but no. And that turned out to be a can of worms, so-to-speak. And it turned out more difficult than I had expected. The sensor, a 2-leg device, looking like an ordinary LED but darker, you would expect to connect it the same as an ordinary LED - long lead to positive/supply and short lead to ground. No! Whoever thought it would be a good idea to swap it round - long lead to ground, short to positive.......

No wonder it wouldn't work!

And then I thought that I would like to be able to switch off at the end of a running session (or in the case of a power fail) without the need to store everything back in sidings or in the terminus and to be able to pick up exactly from where I left it, occupied sections and all. Such is the problem with software-derived signalling and occupancy detection as opposed to "current detection". Everything normally gets lost at power off.

So that's meant another look at the programming - hoping in the process I'm not slowing things down too much by adding in these extra (write to eeprom) commands.

Surely this project can't be far off completion now, or maybe.....



Petermac
Admin


Joined: Sat Oct 13th, 2007
Location: Nr Bergerac, France
Posts: 18736
Status: 
Offline

My photos:
view photos in Gallery
view photos as slides

The more I read about your journey Dave, the more I realise how much fun one could have from the old Hornby "O" Gauge clockwork trainset .................... :roll:

I'm assuming you know what you're doing because I got lost when you mentioned "breadboard" and didn't follow up with the type of flour you'd used ................... :cheers

It does however, seem that you're making steady progress so onwards and upwards Sir !! :thumbs


                 

Recent Topics Back to top of page

Powered by UltraBB 1.15 Copyright © 2007-2011 by Jim Hale and Data 1 Systems. Page design copyright © 2008-2013 Martin Wynne. Photo gallery copyright © 2009 David Williams.