Jump to content

Stopping trains under program control


Recommended Posts

Resulting from a comment made in another unrelated thread, I have decided to document methods which I use in Railmaster programs to bring trains to a halt. First of all, a realistic, controlled halt at a station platform. Secondly, stopping in a hidden storage siding.


1. Station Stop


There is a Railmaster Programming command which is available, but doesn't appear anywhere in the RM User Guide. In the program editor it appears in the dropdown list of instructions thus:-

 

/media/tinymce_upload/fde0aa686dc8deda905243b1606066ea.png

When the "Pause message" command is executed in a program, execution of further program commands is "paused" until the user either presses the Enter key or clicks the green tick button when this mini-window appears:-

/media/tinymce_upload/f6e4948fba8b0ee223182cc144a156a5.png


Here is an example of the last few lines of one of my programs which uses this technique.....

 

68 LOCOMOTIVE 0011 4-6-2 'William Whitelaw' Class A4 BR grn F3: Chime short 1

82 LOCOMOTIVE 0011 4-6-2 'William Whitelaw' Class A4 BR grn Decelerate Forward [20] to [5],0.4

91 COMMAND Program command Play sound: C:Program Files (x86)RailMasterSoundsL_2_Chimes.wav

92 COMMAND Program command Pause message

93 LOCOMOTIVE 0011 4-6-2 'William Whitelaw' Class A4 BR grn F12: Brake

93 LOCOMOTIVE 0011 4-6-2 'William Whitelaw' Class A4 BR grn Stop

101 LOCOMOTIVE 0011 4-6-2 'William Whitelaw' Class A4 BR grn F17: Chuffing on/off

103 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsL_DoorsSlam.wav

105 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsL_3_Chimes2.wav

108 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsEnglishM_L_TrainNow.wav

110 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsEnglishM_L_Four.wav

111 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsEnglishM_L_Midlothian.wav

114 COMMAND Program command Play sound: C:Program FilesRailMasterSoundsR_DoorsSlam.wav


At time 68, the loco has already been decelerated to speed 20 and is approaching the start of the platform.
At time 82, the train is about 3/4 of the way along the platform, ready for its final deceleration to a crawl at speed 5. The time taken to obey the deceleratuion command should be 15 (speed steps) x 0.4 = 6 seconds, so when the Pause command is executed the train should be doing speed 5 but still short of its stopping position. The user should keep his finger hovering over the Enter key and press it when the train has reached its stopping position. At this point, the program restarts and obeys the commands which follow, in this case the sound of the brakes (F12) and a Stop command.

At this point, I need to point out a deficiency in the way that the Pause command works, and this is that, the program run clock keeps on going in the background while the Pause message is being displayed. This means that, for example, if the Pause was on display for 5 seconds before the user presses Enter, then RM will try to execute any of the following commands which are within 5 seconds of the Pause command. In this example, the next two commands, F12 and Stop, are to be obeyed immediately so these are OK. However, these commands are followed by station sounds such as Doors slamming, an announcement about the train etc. so a gap of 8 seconds (93-101) in this case has been left to account for the time used up by the Pause command.

One more "deficiency" with this command which needs to be mentioned is that pressing Enter when the Pause message appears often doesn't work. Worse still, pressing Enter can cause something else to happen, such as the program either being stopped or restarted. The reason for this is to do with the way MS Windows works. Buttons on display in a Window can have what is known as the "Focus", and by default, pressing the Enter key on the keyboard can cause any button on the current window to act as if it has been clicked if that button currently has the "Focus". Unfortunately, when RM displays the small Pause window, it doesn't give the green tick button in that window the focus. Instead, the last button pressed still has the "Focus". If the program is being run on the main screen from the dropdown list of programs, then the button which has the Focus is the program Start/Stop button. So pressing Enter will effectively press this button causing the program to terminate without obeying any more commands after the Pause command. The effect is even worse if the program is being run from the Editor window. Pressing Enter causes the program to restart from the beginning !!!

There are two ways of getting around the problem with the Enter button. The simplest way is not to use the Enter button but to use the mouse to click the green tick button instead. The other way is to remove the Focus from the last button pressed so that the Enter command will have the desired effect when the time comes. To do this, the mouse needs to be clicked on an area of the screen which is non-reactive to a mouse click. So on the main window, the best place is on the track diagram in the middle of an empty space. In the editor window, it is a little more difficult to find an area which doesn't normally respond to a mouse click. I find the best is the border around the outside of the Editor window.


2. Hidden Siding Stop

On my own layout, I have nine "hidden" sidings, which fan out using sets of Peco Electrofrog points. Because of the electrofrogs, the running rails already have isolating rail joiners (IRJs) on each rail coming from the frog, so I made use of this by placing another IRJ on the same rail at a distance of about 18" from the frog IRJs into the siding. Then I fed power to these isolated sections using two of the three terminals used for switching of frog polarity on ADS2 accessory decoders. This means that these sections of track can be switched on and off by using Points switching commands in a program. Most of the time, these isolated sections are kept in the off position, which has the added advantage that any locos standing in the isolated sections are not using up any of the Controllers ampage unnecessarily.

So, if I have a program which moves a train from this hidden siding either to another location on the layout, or in a complete circuit back to this starting point, then as well as any "normal" points needed for the journey, the program will switch on the isolated section to allow the loco to receive power and the DCC commands to move it. As soon as the loco has moved and cleared the isolated section, the program uses a point command to switch off the power to the isolated section. Whenever, a train returns to its "hidden" siding, the isolated section is left switched off, the program slows the train to "shunt" speed, allowing the train to be stopped by the loco entering the isolated section. After a delay long enough to ensure that the loco has arrived, a Stop command is sent by the program, even though the loco won't receive it immediately because it is isolated. But at least the Controller knows its speed is now zero, so next time the isolated section is switched on, the loco will (almost) instantly receive the speed = 0 command from the Controller.

There are probably less expensive devices available on the market which will allow on/off switches to be switched on and off using accessory DCC commands. If anyone knows of any which can handle eight such on/off switches, I would be very interested to know.


I hope this provides food for thought, and I would welcome any other methods which RM users have found to control train stopping via programs.

 

Ray

Link to comment
Share on other sites

it would actually be quite easy to knock up a circuit based around an arduino that can operate 8 relays - assigning a seperate DCC address to each relay. 

Arduinos can be had for under £5, a block of 8 relays costs £9.99, a DCC interface for the Arduino is £8. Those are all the parts you need - if you have any programming experience you should be able to knock this up over a weekend. If not, contact me through the Shedend website...

Link to comment
Share on other sites

Andy

I see in your link which leads me to the Arduino parts supplier that there are two DCC interfaces, one at £8 and the other at £20. Apart from the size and shape they both appear to do the same thing at a great difference in price. Is it simply the expensive one sits on an Arduino Uno and the cheap one sits separate linked by wires.

 

I have a Uno already loaded with the DCC library being used as a DCC sniffer, a load of discrete IR sensors and some ready built IR sensor boards along with several varieties of relay modules. The relay modules were bought to replace my existing car relays used for interfacing DCC points control with my manual points control switching circuits, but the IR sensors were bought purely for track use initially to control tail chasing signals, but with an eye towards loco detection and control, given as you say the Hornby LD system appears to be vapourware. I follow your progress with great interest along with that of Ray who has also made great strides to overcome the lack of the commercial LD system.

Link to comment
Share on other sites

there are two more expensive ones - one for the nano & one for the Uno. I did buy the nano one, which actually uses a voltage regulator taking power from the DCC bus to drive the Arduino. I found that once you start driving relays the regulator overheats & everything goes a bit pear-shaped. Not sure about the one for the Uno, but the simple £8 is 'good enough' in fact if you're handy with a soldering iron & hunt around you can find the circuit he is using - it uses one opto isolator chip, three resistors & a diode. 

 

regarding the IR sensors - they're very sensitive to daylight, I'm thinking of using block occupation circuits now.

 

I've started writing up everything on the shedend website, but work keeps getting in the way

 

Link to comment
Share on other sites

All internet searches for "Shedend Website" lead me to 'Chelsea FC', can you post the actual URL link to your web article. Such a link doesn't impact on any forum rule.

.

...if you're handy with a soldering iron & hunt around you can find the circuit he is using - it uses one opto isolator chip, three resistors & a diode

.

It is probably this one. I use this circuit from the Internet with my Arduino DCC Monitor.

/media/tinymce_upload/0aa3c19c5f0ab4bb7810e0043b394c76.jpg

 

Link to comment
Share on other sites

that is indeed the circuit, although at £8 their basic board is quite nice, and from a manual inspection I'm sure it's the same.

I can't apologise enough for sending you to that football club - I shall have to sublimally add a link to the red and white team the other side of the capital. here is the first in what I intend to be a series of articles tracking my progress with the Arduino

https://shedendrly.wordpress.com/arduino-based-signal-decoders-part-one/

 

Link to comment
Share on other sites

I have just spotted that the web link home page is actually mentioned in your signature. Obviously, that passed by me unnoticed before. I have bookmarked the article and look forward the reading the future parts.

Link to comment
Share on other sites

Rob, asked Adam, the forum administrator to make it clickable for him. Adam left Hornby for pastures new last Christmas Eve. Adam had a close working relationship with the ComMods, thus when Adam was at the helm, things were a lot easier to get progressed.

Link to comment
Share on other sites

Everytime I amend my signature or avatar Andy I have to get Admin to reconnect the link for me as I cannot do it myself. Bit of a pest but protecting the site against someone slipping malicous code into their signature.

Just email forum@horny,etc and ask.

Link to comment
Share on other sites

Everytime I amend my signature or avatar I have to get Admin to reconnect the link for me.

I just replied but the profanity filter kicked in for some reson, so you will see my full answer later. Meantime write to forum admin on the posted email address and ask for the signature link to be made live.

 

As Chris says I already have the opto-isolator circuit as well as the DCC library for use with the Arduino DCC monitor project.

Link to comment
Share on other sites

Everytime I amend my signature or avatar Andy I have to get Admin to reconnect the link for me as I cannot do it myself. Bit of a pest but protecting the site against someone slipping malicous code into their signature.

Just email forum@hornby, etc and ask.

 Spotted the profanity - compare my amended text with the previous post as approved - I missed the ‘b’ out of Forum@Hornby. Corrected now and allowed to continue.

 

Suggestion to Admin - if the profanity filter kicks in please redisplay the post and highlight the word, phrase or saying that is at fault, to allow the poster to correct a typo or other misdemeanour and allow the post to continue.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
  • Create New...