Sensors and blocks

ContentAutomatic Mode

  • Sensors and blocks


Sensors are a core component of every computer controlled model railway. By the sensors the positions of the trains on the layout are announced to the software. Sensors can either provide an impulse (e.g., switch rails, Reed contacts, hall sensors) or a permanent signal (e.g., contact rails, other occupancy detectors like current detectors etc.). An overview of the hardware and an introduction to the use of sensors is provided on the page Sensors.

In Rocrail sensors are defined as objects. The page Objects: Sensors and its sub pages inform about the setup of sensors.

Note: To the avoidance of misunderstandings it should be noted that with the word “Sensor” physical (real, hardware-) sensors, as well as the corresponding software objects and events are called.

Rocrail needs two sensor events for every block which define when a train is entering the block and when it has (almost)1) reached the end of the block. These sensors are called as enter and in. When required additional sensors like pre2in, shortin etc. can be added.

The definition of the sensors occurs in the route properties of a block and depends on from which block the train comes. For all possible routes sensors have to be defined. Hence, before the definition of sensors in the block properties all routes must have been set up before.

Sensor Events

All event types may provide extra bi-directional (ident) information.

Event table

Event Explanation
Standard events
enter The train enters the block. Velocity is set to V_mid2), in case no free destination is found or in case the train should wait.
in If the train has to stop the velocity is set to zero. This event also frees up the previous block locked by this train.
Additional, optional events
shortin In combination with the loco property “Use shortin event” this will be used as in. Suitable for short trains which should, e.g., stop in front of a station building.
pre2in Reduce the train velocity to V_min in case no free destination is found or in case the train should wait.
In combination with loco property “Stop at pre2in” this will be used as in; can be used instead of or in addition to shortin
Events for special purposes
occupied No action is taken as long as it is not unexpected. The status will be evaluated if a reserve request is put by a train to make sure the whole block is electrically free.
ident Some sensor systems provide more information like the address of the passing locomotive. (Lissy, BarJut, RailCom, …) This information is compared in auto mode to the identity-code set in the Loco properties, in manual mode this identity-code is shown in the block symbol.
Use this event type only if the sensor has no further functionality.
exit The train exits the block. This event is used for extra safety and detects if a train does not stop with in the distance between in and exit. When this happens the train is stopped immediately and put back in manual mode. An exception message is generated. To use the exit event after the in event, the exit event must be set to the general route “all enter +/-” because after the in event the “from block” is set to the current block.
The use of this event is discouraged: Use BBT instead.
free Free previous block. Use with care! For short trains and automobiles only.
enter2route It is not connected to a physical sensor, but is generated after an in event from the previous block.
This kind of event is not suited for trains but solely for Car systems.
Timer controlled events
Limited support; Long timers can severely disturb automatic control if overlapping subsequent events.
Using timed events is disadvised!
:!: No forum support for event timers longer than 100ms :!:
enter2in A combination of enter and in. The events are generated sequentially; in is simulated. For blocks with one physical sensor only.
enter2shortin A combination of enter and shortin. The events are generated sequentially; shortin is simulated. For blocks with two physical sensor only.
enter2pre A combination of enter and pre2in. The events are generated sequentially; pre2in is simulated. For blocks with two sensors (enter and in).

As explained below in more detail the following general order of events takes place: enter→ (shortin) → (pre2in) → in. Events in brackets are optional.

For the opposite direction of the traffic the allocation is to be repeated from opposite view. Typically a sensor triggers different events depending on the direction of the traffic.

For a correct functioning of the automatic mode at least the events enter and in have to be triggered in each block.


In the following the different sensors are looked closer at. Besides, it is assumed that a train must stop in the respective block, e.g. because the waiting settings of the block are set accordingly, or because the following block is occupied. To the meaning of V_min and V_mid see Locomotives: Interface

Two Sensors

  • Since introduction of the Block Braking Timer (BBT) the two sensors setup with enter and in is the recommended standard. With BBT more than these two sensors are only needed if multiple stopping points are desired in the block. For the breaking behaviour of BBT see description there. The following statements refer to driving without BBT.
Tip: Whether or not using BBT can be defined for each block individually. This decision has not to be made for the whole layout.
  • With two sensors - enter and in - the train drives with V_mid3) from enter on and decelerates to a halt at in. If the combination of brake behaviour and V_mid is set equally for all locomotives (either all locomotives at the same speed with V_mid and the same brake behaviour or V_mid differently, however, with the quicker locomotives also set to a more sharp braking), a stopping accuracy in the range of a few centimetres is achieved easily.

Three Sensors

  • With three sensors, enter, pre2in and in, the train decelerates to V_mid4) at enter and to V_min at pre2in.
    If one sets V_min quite low (practical value: 10 kph), then the brake setting of the locomotive does have a limited influence only. All locomotives will stop quickly after arriving at in. This leads to the very exact stopping point. The divergence lies within clearly less than 1 cm!.
    In addition, the pre2in can be in a way abused to allow shorter trains an earlier stopping point: To achieve this the respective locomotives are set to “stop at pre2in” in the locomotives properties. Now for these locomotives the pre2in has the function of the in-sensor. Accordingly these locomotives decelerate to V_mid5) at enter and stop at pre2in.
  • Another combination of three sensors would be enter, shortin and in. This combination is similar to enter and in and, in addition, locomotives with the setting “use shortin event” use shortin as in-sensor. Other locomotives ignore shortin and use in.

Four Sensors

  • Finally, four sensors can also be combined: enter, shortin, pre2in and in. Then with this variation it is possible to
  1. run long trains as far as in (with V_mid and V_min as described above)
  2. stop short trains already at shortin (e.g., in front of the station building)
  3. use pre2in for trains that would stop to early with shortin and to late with in

One Sensor

Even though using only one sensor per block (enter2in) is possible, this alternative should not be taken into account or only be used exceptionally. See the warning in table Sensor Events above.
  • If only one physical sensor is used - e.g., for cost reasons, or to hold the wiring expenditure low - this sensor is defined as enter2in. The physical sensor generates the enter-event and starts a timer which generates the in-event after its expiration. The train decelerates to V_mid6) at enter and if the timer is elapsed (in-event) it decelerates to a halt.
    The timer (event timer) is found in the Routes Dialogue of the block properties and is valid for all routes of the block equally. Moreover, the timer can be set individually for each locomotive in the Locomotive Details.
    For standard section blocks with low demands for a precisely reproduceable stopping point this is one very well applicable configuration. Even a stopping exactness of few centimetres can be achieved by fine adjusting of the locomotive decoders, in particular the deceleration time (CV4). However, it must be made sure that the train comes to a halt position within the block borders. If a more exact stopping point is desired, however, an own sensor for the in-event should be used.
  • Another possibility to use only one physical sensor is the enter2route-sensor. Nevertheless, this sensor is a special case which should be used for street vehicles in a car system only. A description of how the enter2route-sensor is set up can be found on the page of the Dinamo Car System.

Further timer controlled events

See warning in table Sensor Events above.
  • In blocks equipped with two sensors (enter and in) the pre2in event can be simulated using enter2pre instead of enter. The physical sensor generates the enter-event and starts a timer which generates the pre2in-event after its expiration. The train decelerates to V_mid7) at enter and if the timer is elapsed (pre2in-event) it decelerates to V_min.
    The timer (event timer) is found in the Routes Dialogue of the block properties and is valid for all routes of the block equally. Moreover, the timer can be set individually for each locomotive in the Locomotive Details.
Since the event timers do not only affect enter2in and enter2pre but also in attention should be paid to the following:
If an enter2pre event is defined and this is, e. g., assigned to timer 1 the in event has to be assigned to the other timer (e. g. timer 2, usually with a short or no delay at all) to assure the in event is not delayed by the same time
  • Similar to enter2pre the shortin event can also be simulated using enter2shortin if no physical sensor is available for shortin.

Impulse sensors versus occupancy sensors

Whether occupancy sensors which can supervise a whole rail segment, or impulse sensors which deliver only one short impulse while crossing are to be used, depends on the respective intended purpose, the rail system and the costs: The occupied-sensor according to its function is only useful if designed as an occupancy sensor, however, an exit-sensor can be an impulse sensor without any difficulties. Recommendable for the dual rail DC-System, e.g., could be the following combination: An occupancy sensor to generate the enter-event, for all other events (shortin, pre2in, in) the cheaper impulse sensors will fulfil the requirements.

Velocity Sequence

The following table summarises the speeds as a function of the sensor events. Subsequently the velocity sequence in an example of one block with three sensors is shown graphically.

Event Reaction
enter2route if the actual block is occupied the train will be decelerated to V_mid at this point already
enter, enter2in, enter2shortin if the next block is occupied or the train has to stop in the actual block the velocity is set to V_mid8)
pre2in if the next block is occupied or the train has to stop in the actual block the velocity is set to V_min
in, shortin if the next block is occupied or the train has to stop in the actual block the velocity is set to 0
Note: According BlockDialog Details, Speed other speed indications may be configured.

Graphical Representation

Rocrail does not send every speed step to the decoder and therefore the decoder has to be programmed to get a smooth acceleration and deceleration.

Blocks with only one sensor

Is in a block only one sensor realisable (e.g. the whole block is only one block occupancy section) nevertheless is it possible to get a satisfied stopping inside the block. Then the sensor should be configured as enter2in event and the in event will be generated from an event timer.
The CV configured brake delays or speedlines of all locos, that pass through the block, should not be too different. Otherwise is it possible, a loco achieved too early the Vmin speed and stops too far from the end of the block. For every train, that pass through the block, is neccessary that it is complete inside the block, if the timer controlled in event occurs.


In Rocrail sensor events are configured in the block route properties. For this purpose in the following order

  1. blocks are created (7.1)
  2. sensors are set up (7.2)
  3. routes are generated (7.3) and
  4. sensor events are configured (7.3.2).

In brackets are the relevant sections of the step-by-step tutorial given. In addition, the pages on sensors, routes and blocks should be regarded.

Shared sensors

Using the same sensor in different blocks, for the same or different events, is strictly forbidden. This applies to all above mentioned events without exception. It is thus, as an example, not possible to use one enter sensor for two or more blocks.

Different sensors in specific routes to the same block

If using specific routes for sensor events different sensors can be used to generate the same event (enter in the example) in the same block.

This is not an example for shared sensors; see above chapter!


Example Plan

The screenshot shows a small layout, it contains two routes from the main line block on the left to the main line block on the right, one route passes block local_1 and the other route passes block local_2. The two routes, although coming from the same start block, have different sensor entries for the enter event but use the same in sensor of main right.

Sensor events for route 1:

Sensor events for route 2:

1) in breaking distance to the stopping point
2) , 3) , 4) , 5) , 6) , 7) , 8) or the velocity specified for Stop

Personal Tools