Rangachari Anand
November 15 2005 2004
Introduction
Here is a preliminary report on my efforts in controlling my trains with Python. My setup is shown in the diagram below:
The components that I am using are:
- The Uhlenbrock Intellibox: This box sends both power and control
signals to the the locomotives.
- srcpd running on a
Linux server (an old installation of Redhat 9.0). Client communicate
with srcpd using the SRCP (Simple Rail Control Protocol). srcpd
communicates with the Intellibox over a serial cable.
- A modified version of the rcsh Python client software on a Windows XP laptop. Since the version of rcsh that is available on this site is intended to work with an older version of the srcp protocol, I had to modify it to bring it up to date.
Connect( '192.168.0.4')
L = loco( 61)
L.setF( 4, 1)
L.setF( 3, 0)
L.setF( 2, 0)
L.setF( 1, 0)
def From3To1():
L.setDirection( 1)
L.send()
L.setSpeed( 50)
L.send();
while (srcp.getFB( 2) == 0):
time.sleep( 0.5)
L.setSpeed( 25)
L.send();
while (srcp.getFB( 1) == 0):
time.sleep( 0.5)
L.setSpeed( 0)
L.send()
Here is how it works:
- I have a short linear stretch of track on which there are
three sensors (implemented with a Viessmann 5211 feedback
decoder).
- The script assumes that the train is standing at station 1.
- The train moves at speed 50 (127 max) until it reaches station 2
- The train slows down to speed 25 until it reaches station 3 where it comes to a stop.

Text Copyright © 2004 Rangachari Anand, all rights reserved