Controlling Märklin Digital Railroad with Raspberry Pi(Raspi) and Rocrail


(German Version)

(last updated: Dec 12 2016)

After spending a decent amount of time searching the internet to figure how to control a Märklin digital model Railroad without Central Station 2 (CS2) using a PC and Rocrail, I have decided to create this page to save you some time.

Quick Jump:

Hardware:
Circuit diagram
Connecting to the Gleisbox (Digital-Anschlussbox 60113 / 60116)
S88:
S88 feedback module configuration
S88 feedback module configuration of RM-88-N from LDT
S88 feedback module configuration of  RM-88-N-O (Opto) from LDT
tams S88-N Adapter S88-A usage
S88 Y Splitter DSW-88-N Data-Switch from LDT
Software Rocrail:
Rocrail Configuration
Turnout configuration
Turntable configuration
Rasperry PI config:
Setting up Raspberry PI
Setting up CS2.exe with PI

Raspi Wifi-Disconnet Fix

RemoteCS2 (Android) setup

New: Using the free Märklin Software: Central Station v 3.8.1

A ready-to-use mounted board is now available:

Price is currently at 38.- Euro. Please send an email if you are interested.
Out of stock. Again available in Feb 2017. Preorders are welcome.

Now also in red and blue:

These Boards have been created with the courtesy of CadSoft Computer GmbH and a full version of their Software Eagle v7.5: CadSoft Online

In addition I have a few Mini-Din 10 Märklin Plugs available for 12.- Euro.
(Currently out of stock)
Attention with the cable colors: White is GND! (Red = CANL, Black = CANH)

 

Circuit diagram for the CAN - Bus access including S88 Feedback channel:

The key for controlling using a Raspi, is the Märklin Gleisbox, which offers a CAN Interface, which we can use.

Before we can use a CAN Interface with a Raspi, we need an additional circuit diagram using 2 CAN - Bus controller chips, the MCP2515 and MCP2551.
I did build this circuit diagram on a breadboard, so no soldering is required. After it was working perfectly, I have decided to create a circuit board which fits into the Raspberry PI. So here is now my Step by Step instruction for you:

 

Components Parts List:

 
Komponent Value Amount Part Order Nr.
Keramik Capacitor 0,1 uF / 100 nF 2 C3, C4 Bürklin Nr.: 53D3648
Keramik Capacitor 22 pF 2 C1, C2 Bürklin Nr.: 53D3004
Miniatur Quarz 16 Mhz 1 Q1 Bürklin Nr.: 78D154
IC MCP2551 MCP2551 1 MCP2551 Bürklin Nr.: 64S2272
IC MCP2515  MCP2515 1 MCP2515 Bürklin Nr.: 64S2268
Resistor 18 kOhm 2 R2, R6 Bürklin Nr.: 17E325
Resistor 10 kOhm 2 R4, R5 Bürklin Nr.: 17E310
Resistor 4,7 kOhm 2 R3, R7 Bürklin Nr.: 17E280
Resistor 120 Ohm 1 R1 Bürklin Nr.: 17E175
Stiftleiste gebogen 3 polig 3   Bürklin Nr.: 59F2268
LED 5 mm Rot 1 LED Bürklin Nr.: 67S4500
 

You can order these components at this german supplier: https://www.buerklin.com/default.asp?l=e


The proper Din 10 Miniatur Connector for the Märklin Gleisbox can be obtained by Email request from this person: info@can-digital-bahn.com

Useful parts at Conrad.de:

Item Link:
Raspberry Pi® 2 Model B Advanced-Set 1 GB https://www.conrad.de/de/raspberry-pi-2-model-b-advanced-set-1-gb-1317772.html
Raspberry Pi® Connection Cable RB-CB3-25 https://www.conrad.de/de/raspberry-pi-verbindungskabel-rb-cb3-25-1182193.html
Raspberry Pi® Connection Cable RB-CB1-25 https://www.conrad.de/de/raspberry-pi-verbindungskabel-rb-cb1-25-1192229.html
LDT Kabel S88 1m s88-Connection Cable https://www.conrad.de/de/ldt-kabel-s88-1m-verlaengertes-s88-anschlusskabel-248028.html
Konfektionierte Litze Polzahl 3 https://www.conrad.de/de/konfektionierte-litze-polzahl-gesamt-3-rastermass-254-mm-1-st-1244003.html
Buchsenleiste 26 polig https://www.conrad.de/de/buchsenleiste-standard-anzahl-reihen-2-polzahl-je-reihe-13-bkl-electronic-10120231-1-st-741187.html
212628 S88 Feedback module decoder 5217 https://www.conrad.de/de/212628-rueckmeldedecoder-5217-212628.html
Case for Feedback module decoder

Note: Manual action is required to use this case. The S88 ports access must be freed manualy by rasping the case.

https://www.conrad.de/de/viessmann-244906-mittelgrosses-elektronikgehaeuse-244906.html?sc.ref=Product%20Details

Recommended Feedback Module with galvanic isolation:

Item Link:
RM-88-N-O Littfinski Daten Technik (LDT) Infopage: http://www.ldt-infocenter.com/dokuwiki/doku.php?id=de:rm-88-n-o
Orderpage: http://www.ldt-infocenter.com/shop/Rueckmelden/s88-Rueckmeldebus/16-fach-Rueckmeldemodule/
Apt S88 Cabel 0,5m, 1m, 2m Infopage: http://www.ldt-infocenter.com/dokuwiki/doku.php?id=de:zubehoer#anschlusskabel_fuer_s88-standardverbindungen
Orderpage: http://www.ldt-infocenter.com/shop/Rueckmelden/s88-Rueckmeldebus/s88-Buskabel/
   

For beginners and for your first testing purposes, I suggest to use above S88 feedback module from Littfinski Daten Technik (LDT), because it is using a galvanic isolation between the railroad track and the central station/Pi.
Using regular modules could cause a damage of your central station/Pi if you do incorrect wiring.

Useful parts at company: tams:

Attention:
Using above tams S88-N Adapters can be dangerous, because of reverse voltage connection.
For proper usage please read this part, and if you still have doubts, ask me by email.

 

Mounting the circuits on a Breadboard:

Live picture:

Attention!

In above mounting instruction, the order of the S88 feedback pins is opposite, because I couldn't get a real S88-connector. So a real S88 Module has to be connected to this example upside-down as you can see in below picture:

A complete connection example:

Attention: If the connections CAN High and CAN Low are switched, the Chip MCP2551 gets very hot and can get destroyed. So if you connect this example for the first time, hold your finger on the chip to check its temperature, and if it gets hot, cut the power supply imediatly.

 

Mounting on a circuit board:

Parts side:

 

Soldering site:

The blue connections can only be wired using isolated wires. I have been using a Wiringpen for that.

 

Live picture:

 

Attached to the Raspberry PI:

 

Complete connection example:

 

Software part:

To control using Rocrail you'll need a program which I created out of these following Open-Source programs: can2udp and s88udp

A step by step instruction of installing the software part on a Raspberry PI is now available right here.

Done!

Now you can control your model railroad usinga PC over Raspi with Märklin Gleisbox and S88 Feedback modules, completly with Rocrail.

Settings in RocRail:

To use with Rocrail, you just need to tell Rocrail the IP Address of your PI as CS2. I have both, Rocrail Server and Client on my PC.
So choose following menu: File -> Rocrail Properties:

Switch to the tab "Controller":

In above example, the CS2 is already configured, so click the Button: Properties, and under Hostname enter the IP Address of your Raspberry Pi:

It's important that you pick Version "2" as in above picture.

If you don't have already a controller configured, please choose as new controller type "mcs2", and click the "Add"-Button:

Select the newly created entry: "New - mcs2", and click the Button Properties:

For Interface ID you can choose any name you like. I will use CS2. At Hostname enter the IP address of your Raspberry PI. As Version pick "2", and at Sensors enter the amount of S88 feedback modules, you are going to use. For our first testing purposes, we will use: "1":

The values for the UDP ports can stay at 0, then Rocrail will use the default values 15731 und 15730.

Done!

 Rocrail is now configured to use your Pi as central station. Before your trains can roll, you will need to adjust the right Address for each Loco:

 

Connecting to the Märklin Gleisbox:

   

 

Connecting a S88 Feedback Module:

Here is a picture with the pin-out on my board for the S88 bus.

 

And here is the pin-out of a typical S88 Feedback Module:

Both connected look like this:

or so:

or with Littfinski LDT-Cable:

 

Simply pay attention at the +5V position. On my board it's located close to the LED, and on the S88 module it's located to the outside to the end of the box.

Note: With my Board and the Gleisbox you don't need to connect "GND" of the Module with the track. If you are using a real CS2, then you will need to connect "GND" with the track, which is labeled "0" for C-Tracks, because the CS2 has no connection between the circiut of the track and the S88 modules.

Update: Do not connect the "GND" of the module with the track, because it causes a shortcut and could destroy your Pi.

 

For testing purposes we will now connect a "C-Circuit Track" at the ports 1 und 2 of the feedback module.

U can also use a contact track set:

Connecting module RM-88-N from LDT:

 

Attention: Do not connect the "GND" of the module with the track, because it causes a shortcut and could destroy your Pi.

Connecting module RM-88-N-O (Opto) from LDT:

 

As you can see, with this module you will need another connection with the track, which is using the red cable, connected to the module at the mark: "Ref", and with the track at the mark: "B".

Configuring S88 in Rocrail:

Now lets tell Rocrail that we are using one S88 Module here: Rocrail-Properties -> Controller -> CS2 properties:

Change the number of Sensors to "1":

Click the "OK" Button and then we will add 2 sensors into our track plan with the menu: Track plan -> Edit panel
There you pick "Sensor", and drag and drop any sensor type to your track plan:

Now you will be asked for an ID. I will choose: "TestSensor1":

Now open the properties of this new sensor, and switch to the tab "Interface":

The curciut track is connected with both sonsors in Nr. 1 und Nr. 2 of the module, which is also the address of the sensors. So we enter a "1" at Address -> Address:

Do the same for sensor Nr. 2:

Mine looks now like this:

If you now turn on the power on the track with this button:

And if you now use the switch on the circuit track with your finger, then one of these two signals will turn red:

Now I moved the switch onto the other side:

Usage of tams s88-N Adapter S88-A:

Those who like to use standard network-patch-cables for their S88-Connections, can use those fantastic S88-N Adapters from tams.
(tams have been so kind to spend all four variants of their adaptors for this manual :-) )

But take caution:

There are four different versions of those adaptors, and you have to take caution about the arrangement of the pins of each one!
Sadly the description which comes with those adaptors is very poor, and the adaptors themselves have no print on them to get a clue which pin has which connection.
So I made a picture of each model, and present you the pin-out of each model:


I did place a label on each model as you can see in above picture: "BR", "BL", "SR" und "SL", because it's easier to know which one is which if you have more of them.
I recommend you do the same if you buy more of them. Put a label on each one, right after unpacking it!

Usually you will only need the adapters BL and BR, and the right usage would be like this:

In case you need a S88 connector cable in between, the usage would be like this:

Because you can connect each adapter the wrong way, you should be very careful and read the following usage examples.

To use those, the best is to orientate at the +5V Pin.
Find below some examples with pictures :

Using with a Pi with Adapter BR (Not meant to be used this way, but possible):

Correct usage with a Pi with Adapter BL:

Using with a Pi with Adapter BR and a Littfinski Opto feedback module (Not meant to be used this way, but possible):

Correct usage with a Pi with Adapter BL and a Littfinski Opto feedback module:

Using with a Pi with Adapter SL and a Littfinski Opto feedback module and Littfinski connection-cable:

Using with a Pi with Adapter BR and a Conrad/Märklin feedback moudle and Adapter BL at the feedback module (Not meant to be used this way, but possible).
Actually adaptor BL should be at the Pi and adaptor BR at the module:

Using the Adapter BL with a S88 Module to connect a central station/pi (Not meant to be used this way, but possible):

Correct usage of Adapter BR at a Conrad S88 Module to connect a central station/pi:

Correct usage of Adapters at a Conrad/Märklin S88 Module. Adapter BR goes to the Pi, and Adapter BL goes to the next Module:

Attention:
Never ever turn around any of those adapters. Only connect them as shown in the pictures above, otherwise you could destroy your module or central station or Pi!
You can contact me any time if you have doubts about your doings.

S88 Y Splitter DSW-88-N from LDT:

Here is an interesting product from LDT, to split the S88 Bus.


Picture-Source: LDT-Website

Usually you have to connect all S88 feedback modules one after each other in a row.
But using this devise you can split the usage.
 

Configuring a Turnout Decoder 74460:

Setting the Address:

The little switches are the single bits, which will configure the final address.

All switches off are address: "0"

Switch 1 adds always 1.
Switch 2 adds 2
Switch 3 adds 4
Switch 4 adds 8
Switch 5 adds 16
Switch 6 adds 32
etc...
As you can see, the value always doubles

To setup address 3, we will turn switch 1 und 2 onto 'On' (because 2 + 1 = 3).

If you want address 21 then you would use 16 + 4 + 1, so that would be the switches 1, 3 and 5 onto 'On'.

If you still have trouble, you can also use the configuration for turnouts in the software CS2.exe, which will show a usefull picture of the right switch postions:

Adding to Rocrail:


Now lets add our turnout into our track plan in Rocrail with menu: Track plan -> Edit panel
Choose Switch and drag and drop a turnout into the Track Plan:


When asked for the ID, I use 'sw' for 'Switch' and the nummber of the address: '03':

No open the 'Properties' of your turnout and switch to the tab : 'Interface', und enter the address as Port-Nummber !:

Click the "OK" Button and we're done! If you now click on the turnout in the track plan, the turnout will be moving if the track power is on.

Configuring a Turntable 7286 with 7687

Menu: Track plan -> Edit panel
Choose "Block" and drag and drop a 'Turntable' into the Track Plan:

In the 'Properties' switch to the tab 'Interface' and enter as address "225", and as "Type" choose 'ttdec':

On the tab 'Tracks' we will add the possible entries to our turntable:

The Märklin Turntable 7286 with Digital-Decoder 7687 has a maximum of 48 positions (Tracks).

So the opposite track is therefore always + or - 24

After you click the "OK" button, our turntable did get some entries, onto wich we can draw/connect some tracks:

 

For suggestions or comments send an email to Derrow@yahoo.com


Copyright ©1997 Decision Developments.
All rights reserved. Unauthorized usage of shown material is prohibited.