Sunday, 16 November 2025

A New Serial Card for Minstrel 4th and RC2014 - How It Began

When I originally wrote this post for Patreon back in September, it was going to be called "When to give up on a project because it is just not possible". However, as I was writing it, I kept thinking of new ways that it might work, so suggested that it may end up being called "Wow, look at my fantastic new product!". Place your bets now, which way it is going to go?

I don't normally push the Patreon, but if you enjoy posts like these, I would encourage you to give it a look. It starts at $1, but you can pay as much as you think it is worth. My Patreon supporters are great, and I thank them for sticking with me. The more support I get on there, and the more sales on Tindie, the longer I can keep this going. It's been a tough few years, not sure I can weather too many more if things don't pick up soon.
Thank you, now back to your normally scheduled programming.

A post 5 years in the making, let's go back and see how this journey began....

Back in 2020, when I was first working on the Minstrel 4th, I wanted to add a serial card, but had limited options available.

The "standard" RC2014 serial card at the time used an Motorola MC68C50 ACIA in an arrangement that was based on Grant Searle's Z80 SBC design.

I built one of these as part of my first RC2014 setup, using what is now the "classic" shape - the long and thin version, rather than the now standard punched card shape. (what do you mean you didn't know it was the shape of a punched card?)

This was intended to be used with a Z80 clock of 7.3728MHz, that may seem unusual, but the 68B50 divides that down to set it's baud rate, and if you divide that by 64, you get 115,200 which is a standard baud rate.

The Minstrel 4th needed to run at 3.25MHz to be compatible with the Jupiter Ace, although it could be jumpered to run at 6.5MHz or one of the clocks from the RC2014 bus.

To get around that, I designed a 68B50 card with a built in clock oscillator and a 7.3728MHz crystal. That was used to drive the ACIA and get the 115,200 baud rate, whilst the Z80 could run from a separate clock at 3.25MHz.

That worked well, and that was available as an option from my Tindie store when the RC2014 was first sold.

The 68B50 was discontinued many years ago, so is only available as "New Old Stock" (i.e. some actual NOS, some rejects, some pulls, some desoldered, some remarked, some fakes).

I never have much luck with NOS parts, so I like to use only new chips if at all possible. When I was selling those, I was going through tubes of NOS chips, testing them and only shipping the ones that actually worked. The yield varied, but once I had got a total of three working chips from two full tubes, I decided to call it a day and discontinued that.

Spencer who designed the RC2014 system seems to have better luck than me (or maybe a better supplier than me), and sells various versions of the RC2014 serial card and all-in-one RC2014 systems with the 68B50 on them. We came to an arrangement, and he now makes my serial card with clock kits under license and sells those on Z80kits.com.

There should have been another way.....

I decided I needed an alternate serial card. I looked at two options that were still in production (at the time), the Z80 SIO and the W65C51.

Z80 SIO

The Z80 SIO is a larger, more capable, dual UART designed for Z80 systems, so seemingly perfect, if a little expensive.

I did design a board for that, similar to the ones already on sale, but with the separate clock oscillator.

It seemed there were a few different designs in use with different addressing (hence the B/A and C/D jumpers). It also needed different driver code writing, potentially for two or three addressing options. There were already existing libraries with 68B50 support.

The Z80 SIO has now been discontinued, so no point in pursuing that any further.

I still have the PCBs and a tube of SIO/2 chips (which must be worth $1M each by now) if anyone is interested in such a card.

W65C51

The 6551 ACIA is a similar to the 68B50, but with some additional features, including a baud rate generator which needs a 1.8432MHz crystal to generate the baud rates, again chosen to divide down neatly (÷16 gives 115,200 baud).

The Commodore version of that, the MOS 8551 was used in the Commodore plus/4, complete with a massive 1.8432MHz crystal. A rare case of a proper serial chip in a Commodore product, sadly let down by the connector (that's the plus/4 story in a nutshell) as it pins were scattered around the userport. A built in terminal might have helped it as well?

There is a version of that in production now. The W65C51N from WDC, who also make the W65C02S, W65C21N and W65C22N chips I use on the Mini PETs.

This chip has, or rather had*, a problem. There is a bit in the status register that (TDRE, Transmit Data Register Empty) that is broken and always reads 0**.

* it is now a feature

** later chips now always read 1

It is meant to be normally 1 and is set to 0 when a byte is written to it from the Z80 side. After the byte has been read and transmitted, it should return to 1. The Z80 code polls this and waits until it returns to 0 before loading the next byte (or uses an interrupt based on the same bit).

When this chip was first launched this was in described as "an issue".

Later, they suggested using interrupts to get around that.

The datasheet has since been updated, I think they tried to fix it, but somehow managed to not fix it and it now always reads 1.

Oh, and they appear to have broken the interrupts in the process, so now recommend a delay loop.

What you have to do is send a byte and then wait a while and then send the next one. How long you wait is based on the BAUD rate, so you have to remember that and work out how long you should wait, plus a bit of leeway, and then just blindly hope it is gone before you upload the next byte.

Too fast and you can overwrite the currently transmitting byte.

Oh, and you need to check CTS isn't stopping it being sent, but you might have missed a brief moment when CTS was clear and it was sent and you think it still hasn't gone.

You can wait a long time to be safe, but that slows everything down.

Oh, and the latest datasheet seems to imply parity is now broken also.

I did design a board, but I don't think I actually got any made, due to those issues and also needing a different version of the driver software.

It's a real shame, if they could fix the issues features, the W65C51N would be the go-to chip for any of these 8 bit projects.

(I did consider a version which generated a valid TDRE flag by counting clock cycles of the RxC output after data had been latched and with CTS low, but that looked a bit over complicated, so I didn't bother finishing it. Maybe I should have spent more time of that option, but I thought they might just discontinue it)

Pseudo 68B50

Hang on, I thought to myself, the 68B50 isn't that complicated, why can't I just get a microcontroller to replace it?

How hard can it be?

(as I write this, I feel I maybe should have looked at the problems WDC had.......)

Well....... five years later, I think I might have finally given up.

I have been through various different iterations, all of which worked "most" of the time, but none of which were good enough for me.

V1

The first version used an Arduino Pro Micro module, an ATmega32U4 microcontroller with a USB socket and some IO pins around the side. (essentially a shrunken Arduino Leonardo)

My thinking was I could set that up as a USB serial port and then just mimic the four registers in the 68B50 to transfer the data from the USB.

Easy, right?

The 68B50 has four registers, two read, to write.

  1. Transmit data (write only)
  2. Control register (write only)
  3. Received data (read only)
  4. Status register (read only)

The problem I had was one of timing. Ideally, I need to support the Z80 running at up to 10MHz. They did make a 20MHz version, but that wasn't used much. It is more likely to be on a Minstrel 4th at 3.25MHz or 6.5MHz, or maybe used on an RC2014 system with an existing 7.3728MHz clock etc. so it could be anything up to about 8MHz.

That gives quite a small window to detect an IO Read, prepare the response, write it to the data port, enable the data port and then wait for the end of the read operation to disable the port again.

Write operations were a little easier, just detect the write operation, and read the data from the port in time.

But there just weren't enough cycles to make it work reliably, it kept missing things.

V2

OK, why don't I make the registers hardware and keep them topped up with current data whenever it changes?

I designed another board, not a very elegant solution, but maybe a solution.

This had four 574 latches for the registers, so they could be read from, and written to, at Z80 bus speeds without affecting the microcontroller, which could then deal with things in it's own time. Sort of like two bytes of dual port RAM.

It was very close to being released. I found I had actually written the blog post about it, 31st of March 2020, covering the new cards to be launched for sale in time for the Minstrel 4th release on May the 4th 2020.

That almost worked, but there was a race condition that the TDRE bit could occasionally get read before the microcontroller had a chance to set it, so if the code was fast, it could think it had been sent before it had even started.

V3

After a lot of testing, I concluded I needed an extra flip flop so the TDRE bit was automatically cleared when a byte was written, and I think I also automated the receive equivalent.

Again, that just about worked, but I don't think I can ship them like that.

Time for another PCB.

And a lot more testing. In both the Minstrel 4th

and an RC2014 system.

That was useful for running things like the RC2014 demo of a Mandlebrot set.

Again, it was almost right, but it kept skipping a beat every now and then. I think it was down to some timing condition around USB interrupts?

I couldn't get it to 100%, and I wasn't happy to sell something that only worked most of the time.

It also seemed a bit silly having all those chips on the board.

I concluded that wasn't going to work, so put it aside.

V4

Sometime later, I did wonder if it would be easier if I forgot about the USB side of things and I tried going back to a 5V serial port using an FTDI USB to serial cable and the standard 6 pin header, just like the other RC2014 serial cards.

That didn't really get off the ground, I can't remember why, I think it was the timing again.

I was considering pairing that with the Microchip MCP2221A USB to serial device, which was available as a through hole part. The earlier MCP2200 would have been better as that had RTS and CTS, but that was only available surface mount.

I tried that on a few things, including a C64/VIC20/PET board, but unfortunately I couldn't get hardware flow control to work with that, it doesn't seem to have a way to add byte level RTS/CTS control, it also had a limited buffer and would simply overflow on long lines.

V5

When I was looking at bringing back the Minstrel 4th earlier this year, it seemed like it would be good to have a serial card option.

Here we go again

I was investigating the newer AVR microcontrollers, and it seemed like they could breeze through something as simple as this.

My thinking was a Z80 OUT instruction is 12 Z80 cycles, say at 8MHz. That would mean the AVR at 24MHz would have 3 x 12 = 36 cycles to deal with it, and with mostly single cycle instructions, that should be easy.....

Well, no it wasn't.

Turns out my thinking was flawed, and the actual IO read part is 3 Z80 cycles at most, with the actual IORQ line only going low for about 5 cycles on the microcontroller, and that wasn't quite enough.

(I can't find any photos of the board I built to test this, but I did find the PCB design shown above, and also a version with an external clock that I had forgotten about)

V6

Recently, I decided to revisit this, and with a bit of shuffling around, I was able to reduce the number of cycles I needed to read the port by moving all the relevant pins onto one port and doing a single read.

I rewired one of the previous boards to give that a go.

But again, it just wasn't enough, and it would occasionally miss a byte depending on exactly when it sampled things.

I did nail one thing that had been annoying me with my standard serial module. The LEDs show activity on the RX and TX lines and they aren't very visible when you are just sending a few characters.

Using a convoluted combination of various timers and the CCL and event systems I was able to extended the pulses so the LEDs were always on for long enough to be visible even with single characters.

(this is the example I am working through on part 2 of the New Microcontroller Features post, but I really need to go back to an empty project and start again and get new screenshots for that)

Time to throw in the towel?

After many, many attempts and various different architectures, I finally concluded that such a thing was virtually impossible.

One night, a student left to clean up after a particularly unsuccessful party, found himself reasoning as follows: if such a machine is a virtual impossibility, it must be a finite improbability. So all I’d need to do is work out exactly how improbable it is, feed that number into the finite improbability generator, give it a fresh cup of really hot tea, and turn it on! - Douglas Adams

Tune in next week to see if the Bambleweeny 57 sub-meson Brain and atomic vector plotter I ordered off ebay arrive in time to make this a finite possibility.


Spoiler

Now I have all the issues resolved and a working solution, I have listed the new card on Tindie. A full post on that will follow next week, look away now if you don't want to see the solution.


Adverts

The Minstrel 4th is available form my Tindie store, optionally with a Software Serial card included:

The Software Serial card is also available separately, as a kit or assembled, and with an optional replacement ROM if you don't want to burn your own.

Shipping

I can still ship worldwide.

Currently shipping Royal Mail to the US is working. I can pay the 10% tariff upfront (as part of the postage), so that should be plain sailing and no problems with customs. We're all pawns in a petulant child's political games, but we've got to just keep going and try to make this stuff work.

I have also built some more Mini PET 40/80 Internal boards, since the Mini PET II is still in development but people keep asking, so here they are.



Patreon

You can support me via Patreon, and get access to advance previews of posts like this and development logs on new projects like the Mini PET II and Mini VIC and other behind the scenes updates. This also includes access to my Patreon only Discord server for even more regular updates.

Sunday, 9 November 2025

Userport LED tester for PET, VIC, C64

This is a very simple board I use for testing the userports of various Commodore machines.

The userport pinout on the PET, VIC20 and C64 have some similarities but are not entirely interchangeable (most importantly, the 5V and 9V AC power available on the VIC20 and C64 are not available on the PET and beware any userport devices which use those in case you damage your PET).

They do have two useful things in common, an 8 bit wide IO port on the middle 8 pins of the bottom row, and ground on all four corner pins.

That means I can make one board which will fit the PET, VIC20 and C64 (but not the plus/4 - that does have a 24 way edge connector userport, with an 8 bit IO port, but the pins are randomly arranged around the connector so this will not work on a plus/4)

Usage is very similar, the only difference between the machines is the addresses of the IO ports used to control the LEDS.

To drive the LEDs, first set the port to all outputs with one POKE:

  • POKE 59459,255 (PET)
  • POKE 37138,255 (VIC)
  • POKE 56579,255 (C64)

Then write a value to the port which is displayed by the LEDs as a binary value. There is no inversion, so write 0 ($00, 0000 0000) to turn all the LEDs off, and write 255 ($FF, 1111 1111) to turn all the LEDs on.

  • POKE 59457,42 (PET)
  • POKE 37136,42 (VIC)
  • POKE 56577,42 (C64)

I wrote a test program and adapted it for all the machines, this sets all LEDs as outputs, and then writes the numbers 0 through 255 to the port in sequence, with a short delay between each one.

If you want the full "blinkenlights" effect, you should write a random number.

You could also create a "Larson Scanner", which if you are not from the 1980s (let's face it, you probably are), that is the sequence of LEDs used on the Cylons from Battlestar Galactica and on KITT from Knight Rider.

The LEDs display the binary value sent to the port, with the MSB to the left, LSB to the right, so for example the display below is 1000 1101, $8D in hex or 141 in decimal (or if the Glen A. Larson reference is a bit modern for you and you want your blinkenlights 1970s style, that is 010 001 101, or 215 in Octal)

Aside from pretty patterns, it is useful to test the userport is working.

It also doubles as a power indicator when working on boards on the test bench.

The LEDs are driven to ground (remember there is no power on the PET userport connector), which has the useful side-effect that the LEDs will light dimly when the port pins are configured as inputs, due to the pullup resistors in the VIA / CIA chips.

The reset state of the chips have the pins set as inputs, so all being well, when power is applied, the LEDs will all light dimly.

Sometimes if you have a dirty edge connector you might not get the full set, clean the connector if you want them all to light.

I first made one of these to help with testing the Mini PETs.

I used a 20 way LED bar display, but I think I there were only a few more LEDs wired up than the 8 bit port.

That worked fine, but I thought I needed a slightly neater version, so designed the PCB version and have now made that available as a kit.

These are available as DIY kits from my Tindie store.

They are also available built, but it should be fairly easy to solder up.

I can even supply different colour LEDs if you like.

If you want more userport LED goodness, check out this video from Tim's Retro Corner

And for more on Octal LED displays, this one from Curious Marc.

If you aren't already following Tim or Marc, why not? go and give them a like and a follow now.


Adverts

This and other PET repair parts are available from my Tindie store:

PET ROM/RAM:

PET Diagnostics:

PET Dual Userport Joystick:

Mini PET 40/80 Internal

Or if you decide you want to take the easier route, I have recently built some more Mini PET 40/80 Internal boards, that are a drop in replacement for boards like this one.

Shipping

I can still ship worldwide from my Tindie store and US orders are now tariffs paid.

Currently it looks like Royal Mail to the US is working. I pay the 10% tariffs as part of the postage to (hopefully) avoid delays and additional costs at customs. The increased US postage costs cover this.


Patreon

You can support me via Patreon, and get access to advance previews of development logs on new projects like the Mini PET II and Mini VIC and other behind the scenes updates.This also includes access to my Patreon only Discord server for even more regular updates.