Saturday, 27 September 2014

Pegasus Autocode Revisited

Pegasus, courtesy Wikipedia
Is this the longest-running debugging session of all time?

Back in 1958 I wrote a little program in Pegasus Autocode.

The Ferranti Pegasus was an early (and very successful) UK computer, and as an 11-year old I was lucky enough to borrow a manual and have my program run.

The kind person who ran my program fixed a couple of problems for me, but I've never been quite sure what they were.

Today I found out, and finally got to fix the program myself.

PEGEM to the rescue

I've known for a while about Chris Burton's wonderful PEGEM Pegasus Emulator. This is a DOS program which provides a pretty complete simulation of the Pegasus.

You control the program via the switches on the operator's console. The drum is loaded with the Initial Orders (the Pegasus Operating System), and you can create your own five-track punched paper tapes which you use to program the computer and provide data.

A missed excursion and a loose end tidied

Yesterday I had hoped to join a group of enthusiasts on a Computer Conservation Society outing to IBM Hursley Park, but a tummy bug meant that I was unable to travel.

I decided to install PEGEM on my workstation and have a nostalgic play with Pegasus.

I hadn't realised until yesterday that PEGEM's virtual storage cabinet of paper tapes included the master tape for Pegasus Autocode. This meant that I could try to recreate my program and run it again - after a lapse of over 50 years!

Calculating e

The program attempted to calculate the value of e using a power series. Pegasus Autocode had a perfectly good EXP function available, but back in 1958 I thought I would learn more by doing it the hard way.

I still have my own copy of the Autocode manual, so I decided to have another go.

I recreated the program (from memory) as a text file and converted it to paper tape format.
I managed to reproduce the original bug but this time I was able to fix it.

The problem was due to a well-documented restriction in the Autocode language. I'd attempted to mix floating-point and integer calculations in a  way that Autocode does not support; once I fixed that the program ran and printed out a reasonable approximation of e.

The working version - after 55 years

Here's the final working version. The format looks a bit strange, as the paper tape had its own specialised character set. The ^ is actually a right arrow, representing a jump (goto) in autocode, and the | is a figure shift character used as a spacer.


v1 = 1.0
v2 = 1.0
v3 = 0.00001
v4 = 1.0
1) ^2, v3 > v2
v2 = v2 / v4
v1 = v1 + v2
v4 = v4 + 1.0
2) PRINT v1, 3026

and the result when you run it is: +2.71828


Wednesday, 13 August 2014

C3Pi: The Teensy and Motor Driver are talking

C3Pi Teensy 3.0 and Motor Driver
At the end of the previous post I let myself get a bit carried away!

C3Pi has always used a Solarbotics motor driver. In the past it's been controlled by an Arduino Pro Mini.

While the software for the Teensy is very similar, I needed to make a couple of changes to the code and more significant changes to the pinout.

Slow and steady

So my rush to solder up some stripbaord was premature. I've breadboarded the circuit instead.

I've now got the Teesny 3.0 controlling it, and the Teensy is controlled by serial input.

Since I've already checked that the Pi can drive the Teensy's serial port, I'm ready to go.

Tomorrow's plan

Tomorrow I will prepare the stripboard, connect the motors and take C3PI for his first outing. Initially I will control C3Pi via ssh over wifi.

Come back tomorrow to find out how the project is going. If you want to meet C3Pi in person, come along to this Saturday's Southend Raspberry Jam. There will be lost of other exhibits and talks, and it's going to be a lot of fun.

Book your free tickets via Eventbrite.

C3PI: the Pi and Teensy are talking

The Pi and the Teensy are talking.

The Teensy is running the fortune cookie sketch. I've been using pyserial on the Pi, and using interactive python.

Here's a screenshot of an ssh session on the Pi:

Next Step

Next I'm going to solder up a mini-stripboard for the Teensy.