Sunday, 8 March 2026

PET Serial Interfacing

It turns out it is actually quite easy to interface a Commodore PET or Mini PET to serial, as long as you don't want to go too fast.

There are various ways to do this, and this post by Paul Rickards describes several of them.

Those were all using vintage software, which has a couple of disadvantages, firstly it is difficult to change, but mainly it was designed to interface using crude RS232 level shifters.

The RS232 serial communication protocol was designed in 1960, and as such, was designed to be robust. Communicating over large distances in electrically noisy environments.

The RS232 standard* varies by revision and applications, but by the 1980s was mainly working with signals at +/- 12V. With +12V representing a binary 0 and -12V representing a binary 1. In practice you might find +12V down to +5V representing the zeroes, and anything from 0V down to -12V for the ones.

* it is with pure optimism that I use the words "standard" and "RS232"in the same sentence

This shows the "real" serial port on my PC which is giving 5V and -7V. This is the byte $42, a capital B. It is sent big-endian, with one stop bit (a 0 on the end). You can read that from right to left in the order it was sent as 0100 0010 (42) and then 0 the stop bit. (I realise now that 42 is a binary palindrome, so it not a particularly good example here)

Inside the communications equipment, there will be drivers to convert these RS232 levels to TTL levels. In the 1980s, these were 1488 and 1499 drivers, which required +/- 12V supplies. But the 1990s (when I started fiddling with serial comms) there was a family of chips starting with the MAX232 which did the level conversion and inversion and also generated it's own supplies from a single 5V rail.

In TTL land, the 0s are 0V (or there abouts) and the 1s are 5V (or somewhere over 2V at least).

Here is the same B, and it is now the more logical way around to show 0 0100 0010.

And $40, an @ sign to show the highest bits are indeed at the right of the picture. The transmitter sent 0100 0000 and the final 0. 0100 0000 = $40 = @.

When people were trying to interface to the PET in the 1980s, they went for the simplest solution, and used diode / resistor type level shifters to drop the RS232 input voltages down to safe* levels for the PET userport. The PETs output of 0V and 5V is just about enough for RS232.

A typical interface of the day would be something like this.

The diode protects against the negative side of the incoming signal, and two resistors form a potential divider to drop the signal level. The other resistor protects the output of the PET against the 50:50 chance you have wired up pins 2 and 3 backwards. (It is like inserting USB plugs, you get it the right way around third time)

* This seems to be expecting a maximum of about 9V as anything more than that would give over 5V at the out. I think I would have preferred if the 620Ω was more like 1KΩ to be safe

You will notice there is no inversion going on here, so the software of the day was expecting the input signals to be the RS232 way around, and carried out the inversion in software.

Roll on modern days, and "real" RS232 is rarely used. But it is common to use USB to serial converters, often called FTDI cables (since they made the driver chips). These operate at 5V (or sometimes 3.3V), and work with non-inverted signals.

That means you can connect up one of these FTDI cables to a PET without having to do any inversion in hardware or software. But that does mean the old software cannot be used.

There is however modern software which expects the non-inverted direct connect signals and so it all works together quite nicely.

The adapter I built here is the simple non-inverting, non-level shifting variety, with two resistors for a bit of extra protection.

This pin arrangement is slightly different, but is the same as that commonly used on the VIC20 and Commodore 64. (as it common with many of these things, CA1 is used to generate an interrupt, but it's value cannot be read directly, so the same receive data signal is connected to a pin that can be read. CB2 is the output of the shift register, although this may not be being used as such due to a bug in early revisions of the 6522 VIA it is connected to.

Although you can potentially use adapters designed for the VIC20 and the C64, it is important to remember that no matter what people on the internet tell you, this person on the internet is telling you there is no power on the PET userport connector.

I used the prototyping board in case I needed to add an inverter, something like this, but it wasn't required in the end.

That plugs into the userport and the FTDI cable connects, with ground (usually the black wire) to the left. RTS and CTS are not connected, there is no hardware handshaking.

The software I used was PETTERM, available here:

There are lots of versions. The release includes four, but if you build from source, there are thirteen more.

The main ones have 40 or 80 depending on how many columns your PET screen has, and G for normal/graphics keyboards (i.e. the Mini PET), and B for business keyboards.

I will come to the versions with a memory size later.

For the moment, I am just using petterm40G.prg which suits the MiniPET.

When it starts up, it defaults to 1200 baud, which is fine. 2400 is available, and seemed stable in this release build, but was a bit flaky in the later version built from source.

On the PC end, I setup Tera Term to match. The only setting I had to change was the end of line character. Carriage return just sent the cursor on the PET to the left, CR+LF was required to move it down a line as well.

It was time to try typing stuff.

Success!

Both ways!

I tried various things and it seemed to be working quite well, converting ASCII to PETSCII and handling various control codes for arrow keys, backspace etc.

Even big chunks of text.

It also supports 80 column mode on the Mini PET 40/80, so you can read even more.

This is working fine as a terminal, but is it possible to transfer files?

Yes, that's what the other versions were. Select the memory size of your machine, and load the appropriate version.

You will see it loads but does nothing. You need to type SYS 20480 to enable it. (there are different SYS commands for the different versions).

This brings up a slightly different menu, with two new options. These allow you to load a program into memory over serial. You can also send a file to the PC end. You would load it before you type the SYS command.

These transfers use the XMODEM protocol, so you need a suitable client at the PC end.

This gets the PET ready to receive, you then start up the PC end.

And away it goes.

The transmit pins using CB2 on the PET, which is the same used to drive the speaker, so you get a click when you press a key, or when each block is acknowledged, which is a handy indication things are progressing if you don't have a scope wired up.

Hey this is a posh modern scope, let's decode that serial and see what it says.

Ah no. The hardware and firmware on the scope are perfectly cable of doing it, and probably of higher bandwidth and greater sample depth, but it's all knobbled by licenses. Must remember to google how to hack it one day....

It's not immediately obvious what happens next. The program has been loaded into RAM, but the terminal is still running. You need to press CLR/HOME to go back to the menu, then X to exit. Then enter to get a READY prompt. And then your loaded program is ready for you to type RUN (or save to disk, or whatever you want to do).

And that all seemed to work nicely.

I had planned at one point to add an FTDI connector to the Mini PET, and to add "load over XMODEM" to the file browser, in the same way as on the Minstrel 4D.

Maybe one day I will revisit that.

I did make a PCB version of that.

Which makes things a bit neater.

If anyone is interested in one of those, let me know. Things seem to be running a bit slow on Tindie for some reason. The last few things I added, I had the PCBs made by JLCPCB, shipped here, built and tested, all before the listing was approved.


Adverts

My Tindie store contains all sort of kits, test gear and upgrades for the ZX80, ZX81, Jupiter ACE, and Commodore PET.


Patreon

You can support me via Patreon, and get access to advance previews of blog posts, and progress updates on new projects like the big news on the Mini PET that was announced this week, along with the and Mini VIC and other behind the scenes updates. This also includes access to my Patreon only Discord server for even more regular updates.