Home

Latest Post

Traincontroller 42 – Loading Wagons Using a Sensor

In the previous video we simulated wagon loading by advancing the train one wagon at a time, based on a fixed speed during a certain amount of ms. This works well if the engine runs stable at low speeds and if the number of wagons in a train does not change throughout a driving session.

If one of these conditions is not met, we can use a sensor to detect the wagons. This could be a light beam that detects the gap between the wagons, or a reed switch on the track combined with a magnet under every wagon. The end of the train is assumed if no new wagion is detected after a given number of seconds.

The macro that advances the engine has the following code:

1. Switch the ‘Loading’ switch on.
2. Label ‘Next’. This is the point where the below Goto in line 7 jumps to.
3. Increase the wagon counter.
4. Engine speed 6.
5. Delay 00:00:15:000. Total time for advancing plus loading.
6. Prerequisite on/off switch ‘Loading’. If not end of train, execute the goto statement.
7. Goto label ‘Next’. Jump back to the top and repeat the sequence.

The sensor is given an Operation that stops the train. Furthermore we use 2 flagmen to detect the end of the train. The first Flagman is the ‘Timer’. It triggers when the detector sees the gap between wagons and in its Memory tab it is put on ‘Timer reset’ after a given number of seconds. Be sure to set the tick mark at ‘Forced Reset’. The second Flagman is the ‘End of Train’ flag, it is triggered by the Timer Flagman’s reset, with the conition that the sensor still sees no new wagon. In its Operations we turn off the ‘Loading’ switch, which means the prerequisite in the macro is no longer true and the goto statement is skipped … this ends the macro.

 

..

Welcome at this website / blog

This website / blog contains all kinds of info on the model railway hobby project I'm working on.

The homepage is where new posts appear every time a step has been made, or when I came across something noteworthy.

The other pages, reachable via the topmenu or via the sidebar, store some information I thought worthwhile to remember. Having it all here in one place makes it easy to find it back.

The railway hobby to me is more about electronics and (micro) computer control than about being protypical or to have the nicest scenery. A lot can be found here on the use of Arduino as a DCC decoder and on Traincontroller PC layout control. Who knows these pages may be helpful not only to myself, but also to other model train hobbyists..

Ruud.