The purpose of this project is to document the development and testing of a Märklin model train turnout (track switch) controller that can serve as a DIY version of what Märklin sells off the self. The goal is for this page to serve as a reference document people can use to better understand the communication protocol Märklin has implemented and provide circuit examples that can be used to build other boards to automate Märklin systems.
A full bridge rectifier is used to rectify the ±15V digital signal used by the Märklin Motorola protocol resulting in a steady DC output. The DF15005S-T was chosen as it is a full bridge rectifier incorporated in an SMD package that simplified board assembly. If the digital input signal is ±15V, the output DC voltage will be less than 15V due to the diode's voltage drop. Additionally, care must be taken when probing this circuit; the GND used on the controller may differ from that found on the Märklin Motorola driver, depending on its implementation. This means incorrect grounding of oscilloscope probes can result in a short between grounds with different potentials. A way around this issue is to use an isolated oscilloscope probe on the Märklin Motorola driver and standard probes on the controller or vis versa.
Power Conditioning Block:
Three voltage levels are used on the control board design, ~15V to drive the solenoid, 10V for LED signaling, and 3.3V to power the MCU. As moderate variation in voltage does not affect the solenoid functionality, the solenoid drive voltage is directly tapped from the rectifier's output requiring no additional power conditioning components. On the other hand, the MCU requires a regulated 3.3V source to operate reliably, so a linear regulator is used to provide that. The LP2951-33DR was the LDO of choice as it came in an easy to solder package, could handle the required power dissipation needs, and could function as either a fix or adjustable output LDO. For the case of the MCU, the LDO was used in its fixed output configuration. A duplicate of the same LDO IC provided the 10V source for the signal LEDs. This was achieved by using the LDO in its adjustable output mode, with the voltage being set by R7 and R8. While LEDs are not as sensitive to voltage variations as MCUs are, I wanted these control boards to be able to handle a ±4V tolerance on the protocol's signal amplitude. Using an LDO to regulate the LEDs source enabled me to meet these criteria.
Signal conditioning Block:
For the MCU to determine if a binary 1 or 0 is being transmitted on the protocol bus, it is necessary to sample the ±15V Märklin Motorola signal. However, the MCU's GPIO can't handle negative voltages or signals above the voltage powering the MCU, so conditioning needs to occur to generate a GPIO-friendly signal. The diode D1 stops any negative voltage from reaching the GPIO, and R8 pulls the line down to GND in those scenarios. The Zener diode D2 is used to clamp the GPIO line to 3.3V when the SIN_PLUS signal is above 10V. This circuit results in a signal (MM_Signal) that is 0V when SIN_PLUS is -15V and 3.3V when SIN_PLUS is +15V thus making it GPIO friendly. R3 was also added to act as a current limiting resistor for D2.
Rectifier Block: Rectifies the ±15V signal to generate a steady +15V source which can be used throughout the design
Power Conditioning Block: Takes the +15V source and generates a 3.3V and 10V linearly regulated source that is used to power other system components.
Signal conditioning Block: Taps directly onto the ±15V signal line and conditions it to produce an output that ranges from 0V to 3.3V, where a -15V results in a 0V and +15V results in 3.3V. This is used to generate a signal suitable for an MCU GPIO.
MCU Block: Contains an MCU that is used to interpret the Märklin Motorola protocol formatted data. The MCU generates digital outputs that are used to control the turnout solenoids as well as signaling LEDs.
LED + Driver Block: Contains bicolor LEDs that are powered by the 10V source, a transistor controlled by the MCU is used to switch the LEDs on and off using a 3.3V digital signal.
Solenoid + Driver: Contains a dual solenoid driver, which is controlled by 3.3V digital signal generated by the MCU. The dual driver setup allows for single, three-way, and crossover turnouts to be controlled by a single board.
The purpose of this post is to give
a quick introduction to the communication protocol that Märklin utilizes to
control all their trains and accessories. Most of this information was obtained
from old web pages that other Märklin DIY enthusiasts created. In the future, I
plan to do a more thorough review and will include some oscilloscope
screenshots of it in action.
Marklin has
utilized different protocols through the years; the one with the most publicly
available information and oldest has been Märklin Digital/New Märklin Digital.
This protocol is what I will be designing my controller to work off of. This
will hopefully help reduce the complexity of the controller, and because new
control units (mfx) are backward compatible also provide the widest usability.
To begin
online, you will often find that Märklin Digital is often referred to as
Märklin-Motorola (MM). This is because the protocol was initially designed to
work with a Motorola decoder (MC145027) which works with trinary data or more specifically
binary-coded ternary. This means that two bits are used to represent three
values, 0b00 -> 1, 0b11 -> 2, and 0b10 -> Open. This results in binary
0b11 being left unused. Märklin updated the protocol a few years after its
inception to also utilize the 0b11 value, this is where the 'New' in New
Märklin Digital comes from.
In Märklin Digital, a bit always
starts and ends at its low voltage level (-15V). The duration of time in the
high voltage level determines the bit value. A pulse that is high for 1/17th
of bit time is considered binary 0 while a pulse that is high for 15/17th of
bit time is considered binary 1. The first 1/17th of bit time has
the signal at its low voltage level for both values. Binary 1 extends the low
voltage dwell time in the beginning resulting in a low voltage state lasting
for 2/17th of bit time. Two bits sent in series results in a trit. Nine
trits make a message and each message is repeated twice in series with a low voltage
dwell time in between.
Each message is composed of 3 components,
address, function, and data. The first 4 trits define the controller's address,
which this message is intended for. The 5th trit establishes the
function of the message and trit 6-9 contains the actual data of the message (train
speed, etc.)
great stuff. I would love to try this at home :) did you publish the schematic and code anywhere? What mcu did you end up using? The board looks really compact.
great stuff. I would love to try this at home :) did you publish the schematic and code anywhere? What mcu did you end up using? The board looks really compact.