Wednesday, 23 October 2019

St Petrock goes AC

Once upon a long time ago I was privileged to be a regular operator on Peter Denny's famous Buckingham model railway. My station for the best part of 37 years was Grandborough Junction, where one of my important jobs was to communicate with the signal box up the line at Quainton Road... except that there wasn't a Quainton Road on the model.  To simulate this station, Peter built an amazing electro-mechanical computer that ran the timetable, controlled the clock, set points in the storage sidings and communicated with the 'up' block instrument at Grandborough.

Hitherto, the 'Quainton Road' storage sidings had been operated by Peter's youngest son Crispin, but sons don't stay at home for ever. The computer that replaced him was therefore known as the Automatic Crispin. Peter wrote an article about it for the Railway Modeller and I well remember the title  - "Buckingham Goes AC".

It will therefore come as little surprise to friends and followers of the St Petrock saga that my station should also have a computer to simulate the signal box up the line. However, time and technology move on, so rather than building it from plywood and Meccano, I've used a Raspberry Pi single-board computer. In honour of its illustrious ancestry, though, it too is known as the Automatic Crispin.

Mine has a slightly simpler job to do as I don't have points on my storage sidings, but I did want it to display operational notes and the timetable for the St Petrock operator.

My first task was to learn how to instruct the Raspberry Pi to perform to my wishes, so I spent several weeks teaching myself Python, then writing a program.  Fortunately, Python has some similar features to the Control Basic language that I used to use at my work, so the task wasn't too daunting.  I also discovered that program code for many of the routines was available on the Internet.

Here's a little bit of the code that checks the St Petrock bell button and trip rail near the storage sidings, and displays the 'hours' value. It would probably turn expert programmers to drink, but it works and I'm actually rather proud of it.

def get_button_push(after_push_time):
    GPIO.output(12, GPIO.HIGH)
    while True:
        if (GPIO.input(20) == GPIO.HIGH):
            time.sleep(0.1)
        else:
            GPIO.output(12, GPIO.LOW)
            time.sleep(after_push_time)
            return()

def get_storage_exit():
    while True:
        if (GPIO.input(16) == GPIO.HIGH):
            time.sleep(0.1)
        else:
            time.sleep(2)
            return()


def display_clock(hour,clockhr,minute):
    if (minute == 0):
        rect = Rectangle(Point(377,10), Point(417,50))
        rect.setFill('black')
        rect.draw(win)

    if (clockhr)>9:
        txt = Text(Point(397,30),clockhr)
    else:
        txt = Text(Point(407,30),clockhr)

       
    txt.setTextColor('white')
    txt.setSize(30)
    txt.draw(win)


The screen is an Elecrow 5 inch LCD display that plugs directly into the Raspberry Pi and sits on top of it. Here's a close-up.  You'll see that the operator has a couple of instructions to carry out before train working No.2 can depart for Tregarrick North at 6.40am.


Now the M7 has been attached to its auto coaches and waits at platform 2. A light beneath the bell-push reminds the operator that the clock has stopped  – trains at St Petrock never run late! After checking that the rotating storage sidings are set to road 5, the operator presses the bell once (call attention). The signalman at Tolcarne Junction responds with one beat on the bell.



The St Petrock signalman (or frequently signalwoman) sets the points, then pulls off signals 15 (platform starter) and 12 (advanced starter). The Gas Street crossing keeper also obediently opens the gates.


St Petrock now rings '3 pause 1' – 'Is line clear for a stopping passenger train?' Tolcarne Junction responds by ringing 3-1 and turning the block instrument to 'LINE CLEAR' (green).


The M7 sets off with its train, past the signal box. (Note to self: "That box needs a name board and some levers!")

As the train passes the signal box, the signalman observes that it has a tail lamp (and therefore hasn't left its tail behind) and rings 2 bells (ding...ding... train entering section). Tolcarne Juntion acknowledges with 2 bells and turns the block instrument to 'TRAIN ON LINE' (red).


As the train enters the storage sidings it crosses this trip point (two breaks in the nearside rail) that momentarily energise a relay, instructing the Automatic Crispin to ring '2 pause 1' (train out of section).


St Petrock acknowleges with 2-1, which restarts the clock. The Gas Street crossing gates close once more and the sequence is complete.