The CAN based binary protocol over Ethernet is easy to understand and very fast to be evaluated.
The UDP solution makes it possible to connect multiple CS2s and PCs in the same network.
Unfortunately the document below does not describe the message format which are generated by sensors or other field events. Märklin reports that this is all the available documentation.
Protcol description: cs2_can-protokoll_1-0.pdf (2008), cs2can-protokoll-2_0.pdf (2012) (both in German)
Tiago Lobo Dias has written a getting started with Rocrail and CS2 manual in Portuguese: rocrail_cs2_pt.pdf
|2.1.7 - 2.2.0||Problem||Delayed sensor reporting.|
- Outputs and signals
- Loc speed, direction and functions f0 - f12 for MM decoders
- mfx decoders
- 28 functions
- S88 polling
From the menu File → Rocrail properties… is selected and in the following dialogue tab Controller is selected. If the CS2 should be the only command station other command stations possibly listed have to be deleted first. Afterwards from the drop down field New the command station mcs2 is selected and subsequently added by pressing Add. The command station
NEW - mcs2 is highlighted and Properties is pressed. The dialogue CS2 opens:
The only parameters to be set are the IP-address of the CS2 (UDP Broadcast address / CAN-UDP-Gateway) in the hostname field - the ports are fixed and predefined by Märklin - and the number of 16 input S88 units in the sensors field:
|send||15730||from CAN to Ethernet||receive|
|receive||15731||from Ethernet to CAN||send|
The name the command station is addressed by. The Interface ID
NEW is overwritten by an appropriate name, e. g. CS2 in the example above.
The number of 16-port feedback modules connected to the CS2.
The version must be set to 2 for activating sensor event handling for firmware version 2.0.
The “Sensors” field will be used once on startup to get the current S88 status.
Has to be Ethernet
On tab setup of the CS2 the wrench symbol is selected in order to be able to change values. In section IP it has to be chosen whether IP-adresses are assigned automatically by a DHCP-server in the network or if they are set-up manually.
If no DHCP-server is available and generally in case of a manual setup all fields have to completed. The IP-address alone is not sufficient for communication!
In section CAN the gateway has to be set to broadcast. The gateway address (broadcast address) is either set to the broadcast address of the particular network (see Network Settings below). Alternatively, if IP-addresses are set up manually it can be set to the IP-address of the computer on which the Rocrail server is running, .
Note: With some firmware versions if IP-addresses are set up manually it was observed that in some cases the addresses had changed by themselves after restarting the CS2. This should be double-checked.
with manual IP configuration. IP addresses are meant as an example only. Of course other valid (see Network Settings below) combinations are possible.
The IP address of the computer on which the Rocrail server is running is 192.168.178.48 in case of this example.
Screen-shots of CS2 with German user interface
| Appropriate settings in Rocrail
Hostname: IP-Address of the CS2 as assigned above
Note: This example is based on CS2 software version 2.0.1
The hardest thing most users experience is getting all the network settings right. Especially the setup of subnetmask and broadcast address require some knowledge of TCP/IP. The subnetmask determines which part of the TCP/IP address range belongs to your local network and which part belongs to the host network. The broadcast address is the highest TCP/IP address in your local network.
When you use an TCP/IP(4) address of 192.168.1.100 with a subnetmask of 255.255.255.000 the TCP/IP address range of your local network ranges from 192.168.1.0 to 192.168.1.255, which means that in this case the broadcast address is 192.168.1.255. If you use the same TCP/IP address with a subnetmask of 255.255.0.0 your local network TCP/IP range starts at 192.168.0.0 and ends at 192.168.255.255 (which is then the broadcast address).
Both the network card in your computer and the network settings in the CS2 must be done keeping these rules in mind. They each must have a TCP/IP address that lies in the range of your local network TCP/IP range, they must have identical subnetmasks and the broadcast address set in the CS2 must be the highest TCP/IP address in your local network, based upon the subnetmask set.
More information on TCP/IP addresses and subnetmasks can be found here: http://en.wikipedia.org/wiki/Broadcast_address. In addition there are many network calculators available on the net, one of them is the IP Subnet Calculator.
All this can be forgotten when you use a DHCP server that is able to assign the same TCP\IP address to the same device everytime the device asks for a TCP/IP address. If you have a DHCP server that does not have this functionality you run the risk that the CS2 gets a different TCP/IP address from the DHCP server every time it is powered on/connected to the pc, meaning that you have to change the settings in Rocrail accordingly.
MFX decoders require special attention when defining them in Rocrail. The address the CS2 assigns to a new mfx decoder is not based upon the decoder address (Motorola address). To find out the address to fill in the address field on the interface tab of the loco the following steps are needed:
- Backing up the CS2 to an USB memory
- Plugging the USB stick to a computer
- Opening the CS2 directory on the stick, searching for the backup file backup.zip and unpacking it.
- Opening the file locomotive.cs2 (plain ASCII) with a text editor.
An mfx fitted loco will have an entry similar to this:
lokomotive .sid=0x6 .name=my new loc .adresse=0x53 .typ=mfx
The address to be entered into the loco properties dialog is the sid address. Attention has to be payed as these are hexadecimal numbers. Hence before entering them as address they have to be converted to decimal.
Example: A loco with the sid of 0×11. As 0×11 corresponds to decimal 17, the value to be entered into the address field of the loco properties is 17.
Tip: Conversion of hexadecimal to decimal numbers is fast using Google: If
0×11 to decimalis entered into the search field the first result is
0×11 = 17.
For Rocrail to distinguish between MM and MFX decoders the protocol on the interface tab of the loco properties has to be set as follows: motorola for a MM decoders, serverdefined for a mfx decoders.
S88 polling has been implemented in revision 342, using the unofficial polling command. It is working with firmware version 1.05 of the CS2, but since the command is not officially published by Märklin it may change or disappear with another firmware version.
To enable S88 polling the number of 16 input S88 units needs to be set in the controller properties dialog. With a value of 0, the S88 polling is disabled.
Starting with firmware version 2.0 feedback event handling has changed: Polling is no longer supported. Instead the CS2 will broadcast such events, provided “2” is selected in the Version field of the command station properties of Rocrail and
|In the CS2-settings under CAN-Gateway “broadcast” is chosen instead of auto.|
The addressing itself is straightforward, the first input on the first unit gets address 1 in Rocrail and from there on counting upwards.
With newer firmware versions the CS2 is able to handle DCC decoders also. To send commands in the proper format, the protocol setting of the object on the interface tab of its properties must be set correctly:
For MM the protcol must be set to motorola, for DCC the protcol must be set to NMRA-DCC, NOT to NMRA-DCC long and for MFX the protcol must be set to Server defined.
For MM1/2 the protocol must be set to default, for DCC the protocol must be set to NMRA-DCC. \
In Rocrail 1.4, revision 1058 (or higher), the CS2 broadcast messages when a switch, a loco function (see advice below), loco speed or loco direction are changed from the CS2 user interface are evaluated and reflected in Rocview. This means that for example when a switch is set from straight to turnout on the CS2, the switch will also change from straight to turnout in Rocrail and Rocview, provided that the switch has been defined in Rocrail.
Note: In order to show changes of loco functions in Rocview option Allow Zero Throttle ID has to be activated.