Element Controller

Track side Element

Motors for points and semaphore signals

Points and semaphore signals in the LGB world are operated by a simple two position step motor. When changing the polarity of the supplied power, the motor moves to the opposite position. The original LGB control system operates at 18 V AC, using diodes to provide half-wave rectified current for selecting the moving direction of the motor.

Measurements has shown that the motor operates quite well at 15V DC, providing sufficient throwing force. This is equal to a motor current of 500 mA. At 12V DC, the motor will draw 400 mA and still provide a useable throving force.

When such a high motor current is interrupted, the magnetic energy stored in the motor coil will result in an induced spike of several hundred volt. Normally a diode is mounted in parallel with the coil to limit this spike, but as the polarity is changed for operating the motor, this approach will not work. Instead a resistor of 100 ohm will be mounted in parallel with the motor. When the power is disconnected, the motor current will continue via the resistor, resulting in a spike of 100 ohm * 500 mA = 50 V

The resistor will be mounted directly at the motor in order to reduce electromagnetic noice via the cable.

In order to further reduce the EMC from switching motor power on and off, a capacitor of 680 nF rated at 350V will be mounted in parallel with the motor and resistor.

The P-device escribed below will be used for controlling point machines and semaphore signals.

Light signals

Light signals will be realized with LEDs in various combinations depending on the required signal aspects.

Wiring of Light Signals

Road Signals

Road Signals for level crossings in Denmark consists of one red flashing lantern.

Main Signals

Danish Main Signals comes in several variants. For the Winter Train v3 three variants will be used, two having one red and one green lantern and one having one red and two green lanterns.

Variant 1

  • STOP (red)
  • PROCEDE (green)

Variant 2

  • STOP (red)
  • PROCEDE, expect STOP (green)
  • PROCEDE, expect PROCEDE (flashing green)

Variant 3

  • STOP (red)
  • PROCEDE, expect STOP (green1)
  • PROCEDE, expect PROCEDE (green1 and green2)

The advantage of variant 1 is that it can be controlled directly by one single Arduino output (one bit). This is due to the push-pull nature of Arduino outputs, which can source and sink 40 mA.

Variant 2 requires two outputs capable of sourcing current. As each LED is controlled individual, this allows for flashing aspects.

Variant 3 requires three outputs capable of sourcing current,

The U-device described below can be used for all three variants, while the L-device can only be used for variant 2 and 3.

EC Hardware

The element controller will be based on the Arduino architecture utilizing shift registers to provide more outputs. Further hardware for the Abus network interface and optional a Radio module will be used.

The hardware devices (refer to Devies) used to control track side elements will be realized as follows:

  • P-device: Relays controlled by shift register
  • L-device: Shift register with power output driver
  • U-device: ATmega328 input/output

EC HW structure

The figure to the right provides an overview of the general Element Controller hardware. The radio module is optional, as only one radio is necessary in a complete setup. Details of the device drivers are provided below.


The driver for P-devices will be realized with relays as this approach provides galvanic isolation between the computer circuits and the power circuit for element motors.


  • Overvågning af klæbefejl på udgangsrelæer
  • Overophedning af drev motor pga HW eller SW fejl


The L-device is a simple 1-bit output providing power when the output is set to 1 and no power when set to 0. The power capacity depends on the actual implementation of each module.


The idea behind the U-device is to utilize the push-pull nature of the output pins of the ATMEGA328 processor. This type of output can source and sink 40 mA enabling it to power e.g. two LED.


Module for P-device

Module for P-devices

The figure to the right provides the diagram of a module with four P-devices.

Module for L-device

Diagram of module with L-device FIXME


Interface to RBC/IL

The EC will be connected to the RBC/IL via the Abus network.

The Abus network utilizes a simple polling protocol, where a master (here the RBC/IL) sends addressed packets to each slave (here the EC's). Having received a packet from the master, a slave then (and only then) may send a response packet back to the master.

Packets from the RBC/IL will contain EC configuration data and element orders. Packets from the slaves will contain actual EC and element status.

On a regular basis the RBC/IL will send an packet to each EC in order to request actual status of the elements connected to the EC. The packet may include an element order as described above.

The EC will reply with a packet containing status of all configured devices, unless the EC has not been configured yet. If the EC has not been configured, this will be indicated in the reply.

The RBC/IL will send configuration data to an EC:

  • after RBC/IL startup
  • when EC reports “unconfigured”

The RBC/IL may as well request other type of status from an EC like uptime. In this case, the EC will reply with the requested data instead of element status.

Abus Packet definition

Following Abus packets will be used for communication between the RBC/IL and Element Controlers (including EC/LINK):

Code Description
0 (reserved)
1 Element status request (poll)
2 EC status request (uptime etc.)
3 Mode and movement authorization. Train position request *)
10 Element order and element status request
20 Configuration data

*) Only valid for EC/LINK

In the following “H” designates high order 4bit and “L” low order 4bit

Type 1, Element status request

Request status of all configured elements.

To slave: <empty>

From slave:

Index Type Content Values
3 byte Number of configured elements 0: no elements configured
n+4 H byte Status of element 2n See Status in the design section.
n+4 L Status of element 2n+1

n: 0..15

The element status is provided in the same order as the elements were configured in, ref. packet type 20.

Type 2, Request for EC status

Request status of EC

To slave: <empty>

From slave:

Index Type Content Values
3,4,5,6 unsigned long EC Uptime Index 6 is MSB
7 byte Number of elements configured 0: no elements configured
8 byte Max number of elements N_ELEMENT
9 byte Number of U-devices installed N_UDEVICE
10 byte Number of L-devices installed N_LDEVICE
11 byte Number of P-devices installed N_PDEVICE

Type 3, Mode and movement authorization. Train position request

Provide mode and movement authorization to specific train. Request train status and position report from same train.

To slave:

Index Type Content Values
3 byte Train ID
4 byte Authorized mode
5..9 byte[5] Balise ID
10,11 int Distance from balise to EOA, with sign Valid in FS and ATO only
12 byte Allowed speed

From slave:

Index Type Content Values
3 byte Report status 0: void, 1: valid
4 byte Train ID
5..9 byte Balise ID
10,11 int Distance with sign
12 byte Speed
13 byte Status Ref. WT1

Type 10, Element order and element status request

Order for one specific element and request for status of all elements.

To slave:

Index Type Content Values
3 byte Element index Index is referring to the order in which the elements were configured starting with index 0, ref. packet type 20
4 byte Element order See Orders in the design section.

From slave: (same as for packet type 1)

Type 20, Add configuration data

Add an element configuration or clear existing configuration.

To slave:

Index Type Content Values
3 byte Configuration command 0: delete existing configuration, 1: add configuration
4 byte <element type> See Device configuration in the design section.
5 byte <device number 1>
6 byte <device number 2>

From slave:

Index Type Content Values
3 byte Acknowledge of configuration 0: Configuration accepted, 1: Invalid major device number, 2: Invalid minor device number, 10: Element capacity exceeded, 11: Unknown configuration command, 12: Unknown element type

SW structure

The source code of the EC includes a hardware configuration file called HW_Conf.h This file specifies the amount and type of hardware the actual EC is equipped with:

  • Amount of U-devices, L-devices and P-devices
  • Shift register number for each device
  • Bit number within this shift register for each device
  • Polarity for each bit (where relevant)

This file has to be located in the same folder as the EC source code it self. In order to allow for handling configuration files for different EC hardware, the SW repository has a dedicated folder for these configuration files. When compiling the software for a specific EC hardware, the associated configuration file can either be copied to the EC source code folder or referred to via a symbolic link.

Naming of code and configuration files are following the Arduino tradition, hence all files are located in separate folders having the same name as the file except for the suffix.

Realized Element Controllers

For the WinterTrain 2018 and 2019, following three EC's were realized:


Label EC01
Abus Address 201
# P-devices 4 Device 4 can be wired with separate power supply for barrier drives
# L-devices 16
# U-devices 4
J1 P-device 1-3
Terminal 1 2 3 4 5 6 7 8
Use P1 * P1 P2 * P2 P3 * P3 V+ GND
J2 P-device 4
Terminal 1 2 3 4
Use P4 * P4 V+ GND
J3 Abus
Terminal 1 2 3 4
Use +24V GND D+ D-
J4 Abus
Terminal 1 2 3 4
Use +24V GND D+ D-
J5 U-device 1-4
Terminal 1 2 3 4 5 6
Use 1 2 3 4 +5V GND
J6 L-device -
Terminal 1 2 3 4 5 6
Use GND L9 L10 GND L11 L12
J7 L-device -
Terminal 1 2 3 4 5 6
Use GND L13 L14 GND L15 L16
J8 L-device -
Terminal 1 2 3 4 5 6
Use GND L5 L6 GND L7 L8
J9 L-device -
Terminal 1 2 3 4 5 6
Use GND L1 L2 GND L3 L4


Label EC02
Address 202
# P-devices 4 Device 4 can be wired with separate power supply for barrier drives
# L-devices 0
# U-devices 8

The “EC02lement controller was build on two circuit boards as shown in the photo to the right. The larger board holds the relays for the four P-devices, while the smaller holds the CPU, Abus interface, programming interface (standard FTDI) and power supply. The gray cable connecting the two boards provides power (+5V, GND) and shift register bus (DATA, CLOCK, and STROBE) to the relay board.

Cables to the track side elements are connected via the green pluggable termination blocks at the relay board.

To utilize the otherwise unused I/O of the CPU it self, an additional termination block was later mounted on top of the CPU board.

J1 P-device 1-3
Terminal 1 2 3 4 5 6 7 8
Use P1 * P1 P2 * P2 P3 * P3 V+ GND
J2 P-device 4
Terminal 1 2 3 4
Use P4 * P4 V+ GND
Terminal 1 2 3 4
Use D+ D- +24V GND
J4 U-device 1-8
Terminal 1 2 3 4 5 6 7 8 9 10
Use GND +5V U8 U7 U6 U5 U4 U3 U2 U1


Label EC03
Abus Address 203
# P-devices 0
# L-devices 0
# U-devices 8
J1 Abus
Terminal 1 2 3 4
Use +24V GND D+ D-
J1 (cont.) U-device 1-8
Terminal 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
Use U1 GND +5V U2 U3 U4 U5 GND +5V U6 U7 (nc) U8 GND +5V

it/wintertrainv3/implementation/ec/start.txt · Last modified: 2021/04/24 14:14 by jabe