TDM Emulator

On and off for the last two years I have been wondering what I could use the Pi for and then last month, Aug '14, a few things came together which made me decide to see if I could use it for a serial protocol Simulator. In my line of work there are several protocols that are commonly used, BR1810, BR1921A 'Message Handling and Data Transmission Requirement Between a Solid State Interlocking and a Panel Multiplex System' and BR1922 'Message Handling and Data Transmission Requirement Between a Solid State Interlocking and a Train Describer System'.

I decided to try and write a program that would emulate BR1922 with a simple interface, click a checkbutton on the screen and it would send the appropriate bit to the receiving computer system wrapped up in the message format. To start I had to expand the RPi with a serial port, download the current Raspian image and begin to learn the basics of Python and Tkinter.

After a couple of weeks and with a great deal of help from reading the Python forums I managed to complete the program. With a small number of tweaks I also had a program that would emulate BR1921A.

Since I had learned a great deal from the forums and various web sites I thought I should make my program available for anyone to pick over, please bear in mind it has been over 20 years since I have done any kind of programming so it is probably not the most compact or efficient.

It would not be correct to publish these protocols so I thought I would modify it to one that has no consequence now but would still show the processes used. In 1981-2 I was a junior member of a team that designed a small TDM (Time Division Multiplexing) System which was to be installed between Cathcart and Neilston, later to be expanded to Kirkhill.

The concept of the TDM would veer away from the conventional office/field synchronised (time slotted) system to an asynchronous address/data type with an added feature which we called 'change of state' to provide almost instantaneous transmission of bits. The system would have a background scan similar to the conventional TDM but if any input changed it would not need to wait for the scan to reach it, it would detect that change and send it immediately then return to continue the scan. We finally ended up naming the TDM 'ScR DAM System' (Direct Address Multiplexing). The maximum capacity was 448 bits in each direction and the largest built was 84 x 266 for Craigendoran.

These systems were installed throughout the 80's and early 90's in Cathcart (2 off), Craigendoran, Motherwell and Glasgow Central (2 off) and through time have been decommissioned with the last one being Cathcart in December 2012 after 30 years of service.

The protocol followed the same philosophy as the hardware, that of speed and integrity and can be read here.

The protocol did not use the now conventional start/stop/BCC characters but used bits within the address/data fields to signify its function with the added security of different parity in each direction.

As far as I know the only ScR DAM System still functioning is my test system which I used to verify the workings of this simulator. The ScR TDM simulator provides the following functions:

Background scan.
Sends a bit immediately (Change of State).
Push a screen button changes a bit.
All off and group off buttons.

Below is a screen shot of the simulator and picture of the test system with the field end system being controlled by the simulator.

The simulators were written for the original Raspberry Pi but since then with newer Pi's it has been necessary to make some tweaks to enable the serial port for use with programs other than the console and bluetooth. The best guides I've found for pre and post Raspberry Pi 3 are on the AB Electronics web site - where I bought my serial ports. here for pre Pi3 and here for Pi3, 4 and Zero.

(It is very easy to convert it to work on a PC, change the reference for the com port and install Python and Pyserial)

ScR TDM Simulator script (just copy & past into IDLE 2.7).

A Simulator in development.

Raspberry Pi with serial port and real time clock.

Screen dump of Simulator screen.