LocoNet Gateway



Basic Operation

The LocoNet Gateway connects two (or three) adjacent command stations and additionally establishes its own inner network. On the inner net the Gateway acts as LocoNet master like a command station. A throttle that plugs into the inner net is linked to all command stations connected to the gateway and controls the same DCC address on all of them. Therefore it controls the engine independent from the track switch setting.

Also in the adjacent districts permanently assigned to one command station it controls the engine without restrictions. However data rate is needed at all command stations. Therefore the inner net should not be too large. It may be as large that during normal operations the engineers will plug into this net automatically in time.

To allow the inner net to become large enough even in cases where two switched sections are close together like at a branch, the LocoNet Gateway may connect to three command stations. In this case there is only one inner net, stretching over both switched sections. Also with two track switches at a double track line only one LocoNet Gateway is needed.

When the LocoNet Gateway detects a new throttle at the inner net, the command stations controlling the address last is called and all data read and transferred to the other command stations. This insures that no information about the current state of the engine is lost. When the same address is used in the net of one of the adjacent command stations, it will be freed at all other command stations. This compensates the extra data rate needed for the simultaneous control at multiple command stations by a faster purging.

Layout Aspects

The LocoNet from the command stations is routed directly to the LocoNet Gateway and connected to the sockets at the bottom side. The inner net for the switched section is connected on the sides of the LocoNet Gateway. Both sockets are wired in parallel for easy wiring. To keep the drawing simple the usual case with two command stations is shown.

LocoNet-Anschluss (3K)
Figure 1: Connection of the LocoNet at the LocoNet Gateway.

To insure the switch works as intended and the engineer can control his engine at any time, the throttle must be plugged in to the inner net when the switch acts. Otherwise in the simple case he will loose control over his train. But it may also happen that the train spontaneously reverts or the throttle enters emergency stop when it is plugged into the new command station without being connected to the inner net first. On the other hand the throttle may be plugged into the inner net early without problems. Therefore the area of the inner net should be significantly larger then the switched section(s), to make the engineer plug into it automatically.

As the LocoNet-Gateway is unable to detect a missing LocoNet at the opto insulated LocoNet port 3 and therefore a missing LocoNet at this port will lead to faults, a command station should be always connected to this port. It is physically located in the middle of the three sockets at the bottom side as shown in Figure 1.

Photo (41K)
Figure 2: PCB in the opened case.
Photo: Stefan Bormann.


The next drawing shows an overview of the system. There are four processors in the system. The master processor is an ATmeg128, managing the inner net as master and implementing the complex business logic. The three lines to the real command stations are implemented by an ATmega8 each. Master and slave processors are connected via TWI. The master processor implements the TWI master. The slave processors forward transparently LocoNet messages between TWI and LocoNet and inform the master about sending success and the network status.

Figure 3: Overview of the System.

Slave 3 (middle connector) additionally implements an opto insulation. This was added to avoid a ground loop if in a huge net gateways close a ring. In exchange the LocoNet-Gateway is unable to detect a missing LocoNet at this port. To avoid failures one command station should be always connected to this port.

Each of the four processors features the following three status LEDs:
yellow Transmit LEDLit for 50 ms per packet sent.
green Receive LEDLit for 50 ms per packet received.
red Error LEDLit at the slaves, if no net is connected. (not with slave 3)
Lit at the master, if it could not register an address at all
command stations connected.
At the master there are two additional LED:
blue Heartbeat LEDBlinks with 0,5 Hz.
white Re-connect LEDLit while registering at the command stations.


A list of the documents in PDF format follows, the part list is in the Excel format, the image is a GIF.

Circuit Part 1: Main processor and slave 3
Part 2: Slaves 1 and 2
Layout Tracks top side
Tracks bottom side
Tracks bottom and top side on one page
Drill drawing
Image from the layout editor
Placement Placement top side
Placement bottom side
Placement top side full page size
Placement bottom side full page size
Placement bottom and top side on one page
Parts Part list for ordering
Sorted by "Designator"
Integration Drawing of the case
Building the case


The source code of the software resides in the CVS repository of the SourceForge project "embeddedloconet", as that project supplies the entire LocoNet stack. The releases can be found in the File Release System of this SourceForge project (fremodcc).

Links to the servers for
source code and releases:
CVS repository: /apps/LoconetGateway
File release system

Valid HTML 4.0!