There are two versions, one that allows any address between 0 and FF to be selected. The other uses only address D7 or A7. These are the addresses that Spencer has reserved for Rotary Encoders on the RC2014.
Apart from the addressing, the main changes were to add pull up resistors to the input pins. This means when a rotary isn’t attached, they are held high. This matches the behaviour when a rotary encoder is attached. To save space on the PCB, I swapped from using separate resistors to using resistor arrays.
They work perfectly.
I do like the look of the two new boards. They look like a real product.
The biggest change I wanted to make was to introduce a sensible spoke size to the ground plane. Imagine my disappointment when I still struggled to solder to ground. I went back and looked at my design. The ground plane spoke sizes looked sensible at 0.25mm. Then I realised what I had done. I had placed a ground plane on both the front and back of the PCB. I never changed the spoke sizes on the back. This meant as I was soldering the heat was being wicked away in the large copper ground plane.
I did eventually complete the PCB, and this time I used blue switches for the address port select and for the LEDs. This helps me tell the two different versions of the boards apart.
Plugging it in and running my tests, I was happy to see everything still worked.
She mentioned she had spoken to Spencer Owen about the best port to use. I have followed her example and reached out to Spencer. He has kindly reserved port D7 for rotary encoders on the RC2014. There is also A7 as a reserve port in case of clashes. This port can be used by other rotary encoder modules in the future, not just mine.
One thing Spencer mentioned was about making it simpler to set an address port on the board. Rather than having 8 switches that allow any 8 bit port address to be used, a simple jumper to allow either D7 or A7 could be used.
I have taken this on board and decided to design two more versions of the PCB.
The first is essentially the same as my existing board, but with a single ground plane to the rear of the PCB. This also has smaller spoke sizes for ground so should be easier to solder.
The second is a version without the full 8 bit port select switch. Instead I now have a single jumper to allow either D7 or A7 to be selected.
This is what the binary forms of D7 and A7 look like. They are the same apart from bits A4, A5, and A6.
D7 1101 0111 A7 1010 0111
To allow the switching bits A6, A5, and A4 must be inverted when the jumper is swapped. I can just connect the jumper to either GND or +5V, that will allow A6 and A4 to swap, but A5 must always be the inverse of them. This will need to use an inverter.
Rather than adding an extra chip to invert a single value, I decided I could swap the 74HCT32 OR chip to a 74HCT02 NOR gate. I was only using one of the existing OR gates, so swapping that over to a NOR, then running that through another joined NOR gate will give me the same result. I can also use one of the spare gates as an inverter for A5.
When no rotary encoder is connected
At present, when no rotary encoder to port 1 or 2, the output for the Schmitt Trigger is high. When a rotary encoder is present it is low. This could cause a false reading as I check for high in my code.
To solve this, I have added a pull up resistor array between the rotary encoder pins and the Schmitt Trigger. This is 100k resistor connected to +5v.
To test this works I added a 100k resistor array to a breadboard and connected it between the PCB and Rotary Encoder. When the encoder was present it worked as expected. When I removed the encoder, it also worked.
I have added this array to both of the new PCBs.
The final change was to remove the ground hook from the top right of the board. This was only for testing and ground is available on the debug port anyway.
Will the new PCBs arrive in time
There are only 9 days left before the official end of the 2024 RetroChallenge. I have ordered the new PCBs from JLCPCB, but I don’t know if they will arrive in time. I have also had to order some NOR gates from AliExpress, so that will also be over a week to arrive.
Will they arrive before the end of the challenge? I hope so!
The existing PCBs work, I just know they could be better.
The parts I needed to solder onto the board have also arrived from AliExpress and CPC Farnell.
I found one very annoying mistake try to solder up the board. I had forgotten to add a sensible spoke width to my copper ground plane. This means the ground plane is soaking up the heat from my soldering iron anytime I try to solder any pin connected to ground. I was able to solder up the board, but those pins took between 10 and 20 seconds to solder. I’m not confident the connection will last.
In the next iteration of the board I will set the spoke width in the EasyEDA CopperArea properties to 0.3mm. This should still give a good ground connection, but also be easy to solder.
I’m not happy with the position of some of the text on the board. Once wired up, pins obscure the Port 1 and Port 2 text. The debug port is also obscured. I will move these so they are visible when connected.
The debug port is a bit too high so the pins are clear of the top of the board. I will move them down.
I also realised that Spencer calls all his PCBs “modules”, so I will call mine “Rotary Encoder Module”.
It was with great excitement I plugged the module into my RC2014 and turned it on. The LEDs for Port 1 were all off, but the LEDs for Port 2 were all on. That didn’t seem right, but then I realised I had only plugged a rotary encoder into Port 1. As Port 2 is returning logic 0, the 74HCT14 was inverting this to logic 1 so the LEDs lit. So it was working as expected. Adding another rotary encoder to Port 2 fixed that.
Turning the encoders the LEDs were flashing in the expected order. The BASIC program was returning “Left” and “Right” depending how I turned the encoder. It was working!
I decided to test the address switches and so set it them to 01111011, which is hex DE, and decimal 222.
I modified the BASIC program to read address DE instead of 0.
30 LET IN = INP(&HDE)
Running the BASIC program, the module now responds to address DE as expected.
One final test was to plug in my RC2014 Digital IO module. This is set to address 3. I modified the BASIC program so the OUT statement used address 3.
40 OUT 3,2^COUNTER
I can now use my rotary encoder module to successfully move the LEDs on the Digital I/O module.
Despite the issues with soldering to the ground plane, my module works as I hoped. I am going to tweak the layout and order replacement PCBs from JLCPCB.
To use Z80 assembly language on my RC2014 Classic 2, I have a few options.
Use BASIC to load and execute a hex dump of the my assembled Z80 code.
Use SCM to load and execute a hex dump of my assembled Z80 code.
Burn my assembled code into a ROM and run that directly on the RC2014.
The ROM board for the RC2014 Classic 2 has the ROM chip socketed. If I wanted to use my own ROM image I can lift this out and replace it. However, the board is low down and I would need to also remove the board from the RC2014 backplane. This would add mechanical wear and tear.
I have a similar problem if I want to switch between ROM images. For example, from BASIC to SCM, or to my own custom ROM image. There are jumpers on the ROM board, but I would need to lift the board from the backplane to be able to swap them.
So, what is the solution?
Well, Spencer does have an RC2014 riser card available on the Z80 Kits website to lift the board above the other cards. This makes it possible to reach the jumpers, but still difficult to remove and replace the ROM.
After writing about designing the PCB for the rotary encoder, I thought I could just build my own ROM card. What I want my new ROM board to achieve is…
Use a ZIF (zero insertion force) socket for the ROM so I can easily remove and replace it.
Use switches instead of jumpers for the ROM select so I can easily change which part of the ROM the RC2014 is seeing.
Have the ZIF and switches above the other boards so I can easily access them.
The circuit design of the ROM board is essentially the same as the original ROM board, just with some pull down resistors near the address switches. The board height will be the same as a standard RC2014 board.
I couldn’t find a DIP package with 3 switches in the EasyEDA library, so I have used a 6 pin socket in the design which should have the same footprint.
Here is my PCB layout.
I have sent this off to JLCPCB to be manufactured. The cost including delivery was just £2.53 using their 10 to 14 day delivery option. I’m not in a rush for this board, so I think that is a fantastic price. There is also a $2 discount at the moment, so that also reduced the cost.
I am expecting the board to arrive towards the end of the month but this won’t stop work elsewhere in the project.
One thing I really wanted to do as part of this year’s Retro Challenge was to build my first custom PCB for the RC2014 computer.
I have chosen to use EasyEDA to design my PCB. I was heavily influenced by watching James Sharman’s excellent YouTube videos in which he designs his own CPU using EasyEDA. The alternative was KiCad, which seems more complex for a beginner.
Spencer has kindly put the specifications for a RC2014 module template up on the RC2014 website. I will try to follow this when it comes to laying out my PCB.
The Circuit
The RC2014 Peripheral Addressing didn’t originally target exact addresses, instead it used 74LS138 chips to target ranges of addresses.
The SC219 takes a different approach, and uses a 74HCT688 8-Bit Magnitude Comparator to target a specific address. I think this is the best approach for my circuit. Using switches for the comparison will mean I can easily change the matched address if there are conflicts with any other cards on my RC2014. I will use the IORQ line from the RC2014 as the OE (Output Enable) line. I can take the output from the 74HCT688 and use a 74HCT32 OR Gate with the RD line to know when the peripheral address I want to respond to is being used. I will use a 74HCT245 Octal Bus Transceiver to present data on the data pins when active.
In my initial post I mentioned I had to use a 74HCT14 Schmitt Trigger to invert the input from the rotary encoder and help produce a cleaner digital signal. This will be connected to the 74HCT245’s D0 to D5 pins. This will allow me to support two rotary encoders, and leave D6 and D7 spare. I will provide two blocks of input pins, one block for each rotary encoder. Each of these will support the CLK, DT, and SW pins, as well as GND and +5V.
I will add some debugging support to the circuit. I like the input LEDs on the SC219 so I will also add these to my circuit so I can see the incoming data from the rotary encoders. I think a breakout of the incoming data lines before the 74HCT245 will be useful to see what is going on, and also allow the board to be used as an input device when the rotary encoders aren’t being used. Finally, I saw a discussion on one of the Sinclair Spectrum groups about adding a hook to GND to attach an oscilliscope to when debugging. This could be very useful if the circuit doesn’t work, so I will add in provision for this.
This is my initial design.
The PCB
As I mentioned earlier, there is a specification for the shape and size of PCBs for the RC2014.
Laying out the board I have tried to use EasyEDA’s measuring tool to ensure this is correct.
Adding the curved corner I found tricky, but eventually I was able to do this by targetting the BoardOutLine layer in EasyEDA.
I read on various forums that adding a ground plane to a PCB was a good idea, so I have done this on both the top and bottom layer of my PCB.
As my circuit is reasonably simple, I used EasyEDA’s auto routing functionality. This worked quickly and I didn’t need to do any manual routing.
For manufacturing I decided to use JLCPCB as EasyEDA has built in support for this manufacturer.
The board itself cost $3.20 for 5. I paid for express delivery because if I have made a mistake and need to create a new revision, it could take several weeks to arrive. The total for the 5 PCBs, delivery, and tax was £20.21. These are due for delivery on October 8th 2024.
JLCPCB adds a manufacturing code to each PCB. You can specify where this appears by adding the text “JLCJLCJLCJLC” to one of the silk layers. I put mine on the BottomSilkLayer so it’s not forward facing.
This is the final layout for my board. I can’t wait for it to arrive so I can solder it up and see if it works.