Automate your layout using TDL - an overview

So you have built a layout and are ready to automate it. No! No problem - you can use TDL to trial a layout plan you are just considering. In fact doing so might be useful even if you don't actually automate it later.

This automation drives the trains, selects routes, avoids collisions, stops at stations and so on. In fact if you don't add any manual control facilities none are required!

The steps to follow:

  1. Draw out your layout plan on paper and mark on section boundaries and section names.

  2. Read the intro to TDL if you haven't read it already.

  3. Decide on your control strategy. Select DR if you just want to simulate a trial layout.

  4. Decide on your track powering strategy

  5. Describe your layout in a tdl file. Save your tdl file in the same directory as you have tcc.jar. Use this TDL reference guide.

  6. Check your TDL file compiles by running it in Tcc: "java -jar tcc.jar mylayout.tdl" If you have errors (Tcc window doesn't open and errors are in stdout.txt) then fix them and try again.

  7. Open CTC1 (menu->View->CTC1) and the Tracks palette (menu->View->Tracks) and enter your track diagram. It can help to use the text button ("abc") to label your tracks and turnouts.

  8. Print your CTC diagram (when CTC1 is the frontmost window select menu->File->Print). Mark on your section boundaries.

  9. Augment your TDL file with CTC coordinates.

  10. Enter the track blocks into your CTC1 (using the "B" button on the palette).

  11. Enter CTC2 for train class entry.

    Many of the remaining stages only apply if you are using QTU with dead-reckoning as your track powering strategy:

  12. Load your TDL file into Tcc again. Open CTC1, CTC2, and QtuThrottles. Load and run a train.

  13. Augment your TDL file by adding (possibly approximate) lengths to your tracks.

  14. Add class-based routing to your TDL file if you are using any networks. Perhaps add some of your own TCL script to control train routes.

  15. Play with the TDL variables (SetVar command) and perhaps run several trains at once.

  16. Once you are happy with your layout then build it!

  17. Decide upon the interfacing hardware you wish to use.

  18. Use the Network Configuration window to define your interface module configuration.

  19. Use the declaration section of the auto-generated TCL file to wire your inputs and outputs to your interface hardware. You might need to use the Stack commands to control where each signal connects.

  20. Test your inputs and outputs.

  21. Ensure your track lengths are accurate. If they are not then Tcc will tell you at the end of tcc.log (you must exit Tcc before you can see this).

  22. Load lots of trains, fetch your beverage of choice and enjoy.

Section Boundaries

I suggest that as a general rule that wherever track converges or diverges at a turnout that both tracks are isolated at the heel end (the diverging end) and that the turnout itself is fed from the toe end. Whether you switch the frog or rely on switch blade contact is up to you. If you have adjacent turnouts then generally the same rule applies. There are (comparatively rare) times that short track section or points need to be fed individually. This can be achieved by feeding from the adjacent sections and switched through a relay. Any turnout can have such a relay (which switches with the turnout) by adding the "pwr" option for that turnout in the TDl file.

You should end with main power feeds only to each long track section. How you use these are dealt with later.

Control Strategies

Tcc currently handles three control strategies:

  1. Dead-reckoning (DR). This only works when using a Quad Throttle Unit (QTU) throttle per section powering. The train position is monitored in real-time just by monitoring the track signal. Trains can be told to stop at any point in a section without using optical sensors. The only optical sensors required are one or two to allow the train lengths to be measured so the system knows where the front and back of each train is.

  2. Optical sensing. Each track section can have one or two optical sensors. If an entry sensor is fitted then the train will slow down from that location if it needs to stop at a station or if the next section is occupied (if not fitted then the train slows soon after current is detected). If an exit sensor is fitted then the train will stop when it reaches the sensor (if not fitted the train will slow and stop after the entry sensor). This is less reliable than DR because generally the optical sensors are not 100%. Reflective IR is unreliable because rolling stock does not reflect enough IR - a lot is absorbed or transmitted. Across track light beams see gaps in the trains (you can use two for better reliability). LDRs require ambient light at all times, and that light must be incident from above, and long coaches cause problems on curves. If these conditions can be met then differential detection can be very reliable (use a reference sensor away from the track and compare the two resistances using a comparator or bridge circuit such as this.

  3. Current-only sensing. The train will slow and stop when current is detected. This works for long track sections where there is no danger of a train overrunning to the next section (adjust the deceleration momentum to suit) and always keeps two sections in use for each train. This gives problems in passing loops, or wherever diverging turnouts need to be cleared.

You can mix current-only and optical by adding optical sensors to only where you need them. A DR system uses current-only for the first two sections a train passes (until the DR system is calibrated). Optical sensors can be added to DR for train measurement and/or critical positioning.

Power Routing Strategies

Tcc can currently handle two entirely different power routing strategies, and one day I might add a third:

  1. QTU Throttle per section. This is the preferred option because it is the one most used and tested. A QTU output is used for each long track section. No power routing relays are used (except if required for feeding around turnouts). With this strategy you can mount the QTUs under your baseboards (unless you have a garden layout) and keep the track wiring very short. Just run 15VAC power and data cables around the layout. This strategy allows dead-reckoning, and optional optical sensing.

  2. Zone control. Using any type of throttle (CTI SmartCab, QTU, home made RPC throttle) each long section is fed from just two or three throttles using one or two relays. See here for wiring details. Trains sometimes change throttle and sometimes keep the same throttle as they progress around a layout. This uses fewer throttles and more relays than throttle per section, and more throttles and fewer relays than PCC.

  3. Progressive Cab Control (PCC). This is not yet supported but should be easy to add if required. I did not use PCC because the number of relays grows with the square of the size of your layout. Each track section is fed from any throttle by having one relay per throttle per track section. Good for manual driving because you can use commercial throttles. Personally I would use QTUs to allow speed control that is routed in software to the appropriate throttle.

CTC2

CTC2 is used to display the colour code for each train, its class and its speed settings. Enter horizontal track sections in column 3 from row 2 downwards for as many trains as you have declared in your TDL file. You might like to enter dummy text (just a space) in columns 4 onwards so you can control size and position of the text that will be drawn by the script. These labels will otherwise overlap boxes and look messy.

Running trains in the simulator

The simulator only works for layouts using QTUs. You can still use another power routing strategy for your physical layout, but yo need the TDL file to be written for QTU and DR for the simulator to work.

In the QtuThrottles window turn on the checkbox headed 'cur' (the current detect flag) in those sections that your simulated trains are to start in. You can have as many trains as you like, up to the maximum you chose in the TDL file.

After the trains are 'on the track', start the script running (menu->Run). CTC2 will show the colours used by each train, and CTC1 will show where the trains are. The trains WILL NOT MOVE until you have given them a class. In CTC2 for each train (where the track sections have been coloured) click on the cell below the appropriate class heading. The class name will appear against the train.

You should now see power being applied to some of the tracks by looking at the speed column in the QtuThrottles window. The same information is displayed against each train in the Trains window.

The simulated trains should start to move - look at the integral column in the QtuThrottles window. Assuming you are following the sequence listed above then the coloured sections on CTC1 will move in the following manner:

Note that DR cannot become calibrated yet as you have no lengths assigned to each track, so the system is likely to be running permanently in current-only detection mode. This means that we cannot know exactly where each train is, nor where its front and back are. To handle this situation each train uses two sections at all times - it is always departing from one and arriving into the next. This restricts the number of trains you can run to less than half the number of sections in any given loop or length.

If you are using optical sensors then the track section can also enter the 'occupied' state if the train fits fully between two sensors. This assists in marking turnouts clear and allowing more trains to run.

Assigning lengths to tracks and trains

For dead-reckoning to work for real (not in the simulator) it is important that the system knows how long your tracks are. Measuring track lengths is not that easy, especially around corners. I use cord (any string, but as inelastic as possible) laid down the middle of the track, taking care not to stretch it. Then mark the end perhaps with a clothes peg and transfer the cord to a tape measure,

Take care with turnouts because they can make the electrical length of a track dependant upon the route chosen. Give the main track the shortest of the alternate lengths and define the extra lengths in the turnout definitions.

The format for entering track lengths is defined here (for Long track) and here (for turnouts).

If you have some optical sensors then the lengths of the trains can be determined automatically, when a calibrated train passes over a sensor. You can give trains a default length in the TDL file (defaultHead and defaultTail variables), or you can enter headLength and tailLength in the Trains window.

Once you have lengths assigned to your tracks and train the sections can now enter the 'occupied' state if the train fits entirely into the section. When this happens the train is only occupying a single section (which is probably essential on passing loops) and the whole section is coloured in CTC1.

Interfacing hardware

There are several types of interface modules you can use with Tcc, discussed here. If you are using any sensors then you will need input modules such as QTU, RPC SRI4 or CTI TrainBrain. Points, signals and layout lighting will require outputs such as QTU, RPC SRO4 or CTI TrainBrain. Solenoid point motors will require drivers such as RPC PMD or PMR. Tracks will require throttles such as QTU, CTI SmartCab or home made. Zone control (or PCC) will require banks of relays such as RPC DPR or CTI Dash-8.

Consider where you need to mount your interface hardware. If you mount it all together you will need a lot of long wires to run the signals around the layout (just like most conventional layouts). If you distribute your interface modules around the layout then you can reduce wiring considerably (though Track feeds with Zone control are a problem). The minimum wiring solution is to distribute QTU modules around the layout.

Test your inputs and outputs

Start Tcc using your TDL file. Start the interface network (menu->Configure->Start Network). Check that you have some messages per second reported in the bottom right of the screen, or in the network configuration window. If not then check your serial port identification, serial port wiring and stack address (if used).

Open the sensors and controls windows.

Test each sensor one at a time by using your hand to trigger it. Ensure that the correct box in the sensors window gets checked. If not then use a multimeter to check the power to the sensor (if any) and that the output from the sensor changes when you trigger it. Then check the input pin on the interface module. If the polarity is wrong then you can change it by adding (or removing) a leading hyphen ('-') to the 'opt' option for each track.

Once the sensors all work then check them again with a range of rolling stock. Especially important is that all locos are reliably detected when stationary anywhere over a sensor.

Test each output by checking the boxes in the controls window. If an output doesn't work then use the multimeter on the output pin of the interface module. If the output stays low it is possible that you don't have any pull-up - most outputs are open-collector and expect whatever they are driving to provide a load to some supply voltage.

Last updated 25/08/08

© Howard Amos. 2008