The popular and inexpensive Raspberry Pi1) tiny PC offers some interesting I/O like I2C and GPIO. Because the I2C bus is a common and standard one, the idea to use it for Model Railway automation was born in 2013.
Together with Peter Giling, who lives in the Netherlands, we have developed a range of modules for use with Model Railways.
And I am Rob Versluis, living in Germany, the founder and main developer of the Rocrail Project: http://www.rocrail.net
In September 2011, before the Raspberry Pi was released, one forum member mentioned that the Raspberry Pi might make for a Rocrail server that would fit under the layout. Little did anyone realize just how popular, powerful, and flexible the Raspberry Pi would be. In May of 2013 experimentation was done using a variety of communication methods. In May of 2003 the first mention of Rocnet as a way communication between the PC and a Raspberry Pi occurred. In August of 2013 the first version of a Rocnet client on the Raspberry was created. It was a simple port expansion device. Simple, robust, and easy to implement, it was a near perfect solution….and inexpensive too. Next came the servo/LED controller, then the other modules.
Various forum members also tried a variety of TCP/IP protocols like SRCP (1).
While SRCP is certainly one possibility, it lacks plug-and-play capabilities as it is TCP/IP socket (2) based. Rocnet, which is Multicast based, is plug-and-play.
While this was occurring, various other experiments were conducted by Peter and others.
A variety of I2C (3) peripheral devices were tried for various functions.
Some were successful, some less so. One fact became increasingly clear as a result of these experiments. The Raspberry Pi (and its I2C bus) is a stable, robust and very capable platform.
The very best of these prototypes resulted in modules available from GCA (= Giling Computer Applications).
In retrospect the Linux based Raspberry have proven to be more than just a simple controller for model railways.
Coupled with Rocrail/Rocnet it becomes what some call a Super-Controller.
(1) SCRP = Simple Railraod Command Protocol
(2) TCP/IP socket communications requires that the IP address of the remote node be known before communications can start.
To resolve this issue, IP-Multicast is used so that remote node communications can occur without prior knowledge of the destination IP address.
This also means that the Raspberry’s IP address can change without impact. (IP address changes are common when DHCP is used to assign IP addresses.)
(3) I2C = IIC = Inter Integrated Circuit.
This hardware based communication protocoll , originated by Philips, is a 2 wire communication system between chips on the ame board.
Later improvements and speed-up, together with availability of bus transcievers and buffers like used in the RocNet modules, made it possible to extend the communication lines to more than 10 meter.
The whole system is kind of like ‘Plug&Play’ but it needs an Ethernet Local Area Network in which IP-Multicast is not blocked by a firewall.
An Internet gateway is only necessary for updating the Rocnetnode software.
Small or Large
The following diagram shows a small and a large setup example:
The DHCP-Switch ( a small box used to interconnect TC/IP devices) is responsible for assigning IP addresses to the RasPi’s and Rocrail.
The large setup example is especially interesting for modular layout like my own ‘Plan-F’: http://wiki.rocrail.net/doku.php?id=plan-f:plan-f-en.
The Rocrail project has developed a protocol based on IP-Multicast Ethernet communication which was chosen for this RasPi solution.
The Rocnetnode is the software part running on the RasPi and will manage I/O, Servos and throttles. All hardware modules are I2C based and do not need any firmware; Rocnetnode handles it all.
The Rocnet Protocol is Open Source and is documented on the Rocrail Wiki pages: http://wiki.rocrail.net/doku.php?id=rocnet:rocnet-prot-en
This diagram shows the many and flexible possibilities of the Raspberry Pi solution in combination with Rocrail and Rocnetnode:
There are seven hardware modules available:
|Pi01||The main module which connects directly on the RasPi GPIO header.|
|Pi02||32 port I/O module which is compatible with all GCA interface modules: http://wiki.rocrail.net/doku.php?id=english#interfaces.|
|Pi03||16 port PWM module for controlling servos. It’s an adapter for the Adafruit PCA9685 PWM controller.
Also usable for dimming LEDs (4095 steps)
|Pi04||A hand-held throttle with 28 functions.|
|Pi05||Large scale decoder which can report RFID tags scanned between the tracks. (This is still work in progress.)|
|Pi06||3A power supply and I2C hub together|
|Pi07||Zero loss occupancy detection which can handle low and high current for large scale locos.|
All modules have I2C line drivers to make long cables possible.
You can choose between RJ45(CAT) and RJ12(LocoNet) connector types.
I personally prefer RJ12 because this type is easy to assemble yourself with very flexible cable, and it cannot be accidentally swapped with the RJ45 Ethernet cables.
Pi01 Raspberry Pi connection
The Pi01 connects on the RasPi GPIO header and serves also as a power supply when connected to the Pi06.
The board offers two LEDs and one button. The green LED starts to blink if Rocnetnode has been started.
The red LED is used for identification when requested by Rocrail, which is very useful in the case of a large setup.
A short push on the button will identify this Rocnetnode to Rocrail and will popup the configuration utility with this node selected.
A long push of several seconds duration will shutdown this RasPi as indicated by fast blinking of the green LED.
It is not necessary to shutdown the RasPi because the configuration is saved on the SD-Card. But for those who will get a bad conscience when pulling the power supply plug of a Raspberry Pi, the shutdown(all) option is available in some variations.
For more detail: Model Railway Automation with Raspberry Pi.
Current Project / Post can also be found using:
- raspberry pi model train projects
- who is the Railway Raspberry
- ho scale raspberry pi
- model railroad connected to raspberry pi