The RC2014 currently uses a very simple, although inefficient method of addressing peripherals.  Most of the expansion modules feature a 74HCT138 used to provide up to 8 enable lines from 3 address signals.  For the purposes of this document, I will mainly refer to the Digital I/O Module, but the principals apply to all modules with a 74HCT138 (generally referred to simply as ‘138)

It is worth noting that the Z80 CPU can address up to 256 Input or 256 output addresses.  These are selected by the first 8 address lines (A0 – A7), IORQ going low and either WR or RD going low.

The ’138 has 3 enable pins, G1, G2B, G2A, all of which need to be true (G1 needs to be high, and both G2B and G2A need to be low) for the ‘138 to be enabled.  When it is enabled, the 3 address lines, A0, A1, A2 are read.  These 3 addresses have 8 possible combinations (000, 001, 010, 011, 100, 101, 110, 111), which will activate one of the 8 outputs Y0 to Y7.

In the Digital I/O Module, the ‘138 is activated when M1 is high, IORQ is low and A7 is low.  This corresponds to any port from 0 to 127 (IORQ being low indicates the address bus represents port, and A7 being low indicates the address bus is lower than 127).  [Side note – Serial I/O Module uses addresses 128 and 129, which are indicated by A7 being high].

The Z80 address pins A0 and A1, along with WR are connected to the address pins A0, A1, A2 on the ‘138.  This gives 4 addresses (00, 01, 10, 11) with the write bit high, and 4 with it low.

In normal use, the ports are addressed as 0 (In 0 or Out 0) on the Digital I/O Module.  (Or port 0, 1, 2 on the Digital Input module, for example).  However, any address that has A0, A1 and A7 low will work; 0—–00.  So echoes of this will appear on 4, 8, 12… 124.  So, whilst this works, and is fine for a small system without much I/O requirements, it quickly becomes inefficient as you need more ports.  In particular, it will clash with the Compact Flash Storage Module, which can have an impact on running CP/M.

In an ideal world, every peripheral should have a unique address, and with a lot of digital logic, this is certainly possible to do.  However, it will add both complexity and cost as well as needing more board space.

The easy solution, however, involves just 6 diodes and a resistor.  By connecting address lines A2 – A7 to the anode of each diode and the cathode of each diode to the G2A enable pin on the ‘138, any address above 00000011 will prevent the ‘138 from being enabled.  Effectively all the diodes are acting as a very simple OR gate.  A 10k resistor will bias the output low.

So with this set up, it will give just 4 unique addresses; 00000000, 00000001, 00000010, 00000011 (ie 0, 1, 2, 3) which for the Digital I/O Module, or the Digital Input or Digital Output is ideal.

Other addresses can be selected by changing which address pin the diodes are connected to.  So, for example, if A1 was connected to a diode instead of A3, and A3 went to the ‘138, the addresses would be 00000000, 00000001, 00001000, 00001001 (ie 0, 1, 8, 9).  Whilst it cuts down on the echoes at higher addresses, it’s still not perfect – but much better and still very cheap with minimal extra board space needed.

The Digital I/O Module has now been updated to reflect this change.  As PCB stocks run low on other modules, they too will have similar updates.  If you already have a non-diode selectable module, and wish to implement this, it is actually very simple to do as shown below.

Simple Guide To Getting CP/M Running On RC2014

With the right software, hardware and settings, getting CP/M running on a RC2014 is very easy.  This post is a guide to doing just that.  It assumes you are already familiar with the RC2014 and have built and tested your RC2014 running BASIC.

Required hardware

Optional Hardware

Software

Both the Pageable ROM Module and the Compact Flash Module are available with the CP/M Monitor pre-programmed on to ROM at 0x8000.

The Compact Flash Module is also available with a pre-programmed 128mb compact flash card which contains CP/M as well as the essential software required to get you up and running

Settings

The 64k RAM Module needs to be set to full 64k (ie start address at 0x0000) and in pageable mode.  For this, all 4 jumpers need to be set to the right hand settings as shown below.  If you soldered a link where indicated by the silkscreen, this needs to be remove as this is the page pin

The Pageable ROM Module needs to be set for an 8k page and starting at 0x8000.  See photos below for details.

The Page Pin from the ROM needs to be connected to the Page Pin on the RAM.  If you have the Backplane Pro and have installed the double header pins supplied with that then nothing further needs to be done.  If you are using a Backplane 8, however, you will need to add a jumper cable between the 4th pins on the 10 pin Enhanced Bus header.  See the photos below to illustrate either scenario

Then it is simply a case of installing all the modules (if using Backplane 8 ensure you have links between slot 2&3 or 6&7 so you can use the outer slots), connecting FTDI cable or monitor & keyboard if you are using the Pi Zero Terminal, inserting the compact flash card and applying power.

[On power up, a small bootloader will copy itself and a modified CP/M console from 0x0000 (ROM) up to 0xA000 (RAM), then page out the ROM and page in the lower 32k RAM, then copy Grant Searles CP/M Monitor (as modified by Mitch Lalovie and tweaked by me) back to 0x0000 (RAM) and run the monitor from there]

You will be greeted by a “Press [space] to activate console” message, and after pressing space you will be in to the monitor.

(Note that the B option for BASIC will not work with this hardware set up. If you want to use BASIC, either set the A15 Page Selection jumper to 0, or download a copy of mbasic to CP/M)

Press X followed by Y and it will boot CP/M from the compact flash card and you will be at the A> prompt.

The compact flash card is pre-formatted with 16 drives from A: to P:  The A: drive has DOWNLOAD.COM which is needed to transfer files on to the CF card.  Drive C: has CP/M utilities such as TYPE.COM ED.COM, STAT.COM etc.

To copy files and programs on to the CF card you will need to connect to your RC2014 over a FTDI cable, and either use Grant Searles Windows File Packager or manually package the files with a text editor.  When copied over the FTDI connection it will initiate A:DOWNLOAD.COM which will then take the file and put it on to the current selected drive.  Note that the flow control on the 68B50 is minimal with this setup, so a 1ms delay between characters is suggested to give consistently successful results.

After that, I highly recommend using a torch otherwise you will almost certainly end up being eaten by a Grue

If you are planning on installing a module that makes use of the additional signals available on the Enhanced Bus with a Backplane Pro, then you will need to use a double row right angle header on the module.

Unfortunately, the profile of single and double row headers are quite different, and they cannot be mixed and matched on the same module.

   

Removing the excess pins from a double row header is quite quick and simple, although if you mess up you could end up with pins out of alignment, and nobody wants that!  However, there is a neat little trick that makes things even easier.

Start by putting the double row header on the module PCB backwards, so that the short pins all go through the holes.  (Don’t solder them!).  Instead of using your module PCB then anything such as Veroboard could be used, just ensure that only one row (the short pins) go thought.  This will ensure that they stay in perfect alignment.

Then, with a pair of needlenose pliers, start to remove the long pins, beginning on the right hand edge

They should come out quite smoothly, although you might need to give some a little twist to loosen them up.

Keep on going until there are 16 pins removed.

Most modules have 10 Enhnaced Bus pins, so skip over 10 pins before removing the rest. (Note that because the pins are upside down, you can’t use the marking on the module as a guide as this is of-centre)

Of course, if your module has more than 10 Enhanced Bus pins, skip over this amount instead.

Remove the pins and put the header in the right way up.  It should all line up, and you will have one pin (pin 40) to remove at the very end.

You can now solder the header to the module.

Iterations of a SD Module

From the very earliest days of the RC2014, back when the whole thing was a bunch of wires and chips on a breadboard and before the RC2014 even had a name I knew that it needed some kind of storage.  The obvious solution to me was via SD card.  I had already made a simple PS2 keyboard and 4 line LCD display interface from an Atmel ATMEGA328, and it was easy enough to add an SD card interface.  The ‘328 was connected to the yet to be named RC2014 via serial, so anything I could type on the keyboard could be passed through to the RC2014.  Likewise, the contents of a text file on the SD card could also be put on the serial port.  Intercepting keystrokes like F1 would send the text file 1.bas to the RC2014.

It kind of worked, but was clunky at best.  The text files had to be created on a PC as there was no way to save anything – although I thought about monitoring the keyboard for SAVE to be typed which would be replaced by LIST and the stream coming back would be saved to SD.  But that was even more clunky and hacky.

Once the RC2014 appeared in PCB form, I returned to the idea of an SD card storage device.  This time it was to load raw machine code from SD to RAM – again, via an ATMEGA328 but this time connected via a Z80 port (Essentially, the same circuit as the Digital I/O Module)

The idea here would be a simple bootloader ROM would run on the RC2014.  This would set one of the bits of port 0 high so the ‘328 would know to load the first byte from a file on the SD card on to the data bus.  Once the Z80 had loaded this in to RAM it would toggle the bit and the next byte would be read until the whole file was loaded.

Although this worked, it wasn’t a solution I was particularly happy with.  The main reason was that it had very limited functionality and relied on a custom ROM image.

What I wanted was a way to fill the RAM without worrying about what’s in the ROM (or even having a ROM), and bypassing the Z80.  An old idea that I had for making an EPROM burner was recycled in the form of this prototype;

This used a couple of 74LS393 counters connected to the address bus via 74LS245 to count from 0 to 65535 (ie the whole Z80 memory address space).  A bus request (BUSRQ) from the ‘328 asked the Z80 to disconnect itself from the bus.  When this is acknowledged (BUSACK) the ‘245s have control of the bus and can increment the address from a pulse from the ‘328.  The prototype proved the concept worked, so time to spin up a simple board to take things further.

The first spin of the board was focused on the Z80 interface with the SD pins and any spare GPIO pins from the ‘328 bought out to headers.  I still hadn’t decided yet how the SD card would actually be fitted.  Every SD card socket I could find was surface mount, and if this was to be made in to a kit, I wanted to avoid surface mount components if possible.

The next spin of the board refined more of the control circuitry.  The spare GPIO pins had been connected to switches, LEDs and some of the bus lines.  Not everything quite worked as planned, as the subtle bodge wires allude to.  In hindsight, using black solder resist for a prototype board wasn’t such a great idea either.  However, I got it to work and was able to get the firmware on the ‘328 doing what I wanted it to do.

I had been using a cheap Chinese SD module to connect the ‘328 to an SD card, and these actually work very well as well as being a kind of standard, so to get around the surface mount issue, I decided to use the whole module in the finished product.  Oh, and as you can see, there really isn’t much spare PCB space for an SD card socket either!

With a bit of swapping around, I managed to free up an analog GPIO pin that I could connect to a potentiometer.  This works as a crude file selector.  The initial firmware I wrote for the ‘328 works, and loads an image from SD card in to RAM, or dumps the whole contents of memory in to a file on the SD card.  Scott Lawrence has updated this to give access to different file images and protects these against accidental overwriting.

So far, this is the best SD card storage for the RC2014 that I’ve made.  I wanted to share this though to give you an idea of how a new module is created, from conception, through prototypes and to final product.

RC2014 Module Template

One of the things I am keen to promote about the RC2014 is that designing your own modules is very simple and straightforward.  The standard bus layout gives access to all of the basic signals that you are likely to need and the enhanced, or v2.0 layout builds on this with access to extra lines.  PCBs can, of course, be whatever shape and size you want, but you may have noticed that since around April 2016 I have settled on a standard shape for all new modules.

In this post, I want to discuss the past, present and future of the RC2014 bus, the physical modules, and what you might want to bare in mind when designing your own modules.

rc2014-v2-0-pcb-layout-png

 

Mechanical Layout

Firstly, to dispel a few myths about the shape of this; It was not designed to mimic an SD Card, a New Document icon or even an Apple II expansion card.  The shape was actually inspired by the Hollerith, or IBM punched cards with the cut off corner being an easy way to identify which end Pin 1 is.

The default size, 99.1mm x 49.9mm was chosen to fit within a standard 10cm x 5cm PCB manufacturing size, whilst also being within the 100mm limit of the free Eagle licence.  (Personally, I use and recommend KiCad, which does not have such limitations).

A drawback of the length is that there is only room for a 39 pin header.  To comfortable fit a standard 40 pin header it would need to be 104mm.  Therefore, the length is nominal and can be adjusted, either longer to accommodate the extra pin, or shorter to reduce PCB cost if necessary.

Height is also nominal – although a suggested ‘low profile’ height of 38.1mm could be used, which will allow for a small angled cut off to indicate pin 1 and also leave room for the mounting hole.

The 45° corner cut off not only signifies the orientation of the module, but would allow for a case to be designed to take advantage of this.

The mounting hole can also be used in case design to anchor all modules in place if necessary.

A KiCad template can be downloaded here (delete the .txt extension and rename it according to your KiCad project)

 

Bus layout

When the idea of the RC2014 was conceived, the goal was to get a Z80 based computer running on a backplane as simply as possible.  Some signals that were not required in the basic design, such as BUSRQ, were not bought out on to the backplane and were simply terminated on the CPU module.  As the RC2014 has developed, however, some of these signals are needed to support more advanced modules such as the SD Memory Dump Module.

The challenge has been to expand the bus to allow for this, whilst keeping things compatible with older modules and backplanes.  The solution is to add an ‘enhanced bus’ – a partial secondary line of pins above the original (on the module) and to the left of the original (on the backplane).  Standard right-angle header pins can be used for the original parts and double right-angle header pins used where the enhanced bus is needed.

Standard Bus

The original RC2014 only needed 34 pins to operate, with an extra 2 if the serial module is to talk to other modules.  This leaves 4 pins of the 40 pin header which users are free to use for whatever they want – however, be aware that using pin 40 will take the module over 100mm (see mechanical layout above)

Pin LabelDescription  Note
 1-16 A15 – A0 Address lines for up to 64k of addressable memory
 17Gnd0v power supply
185v5v power supply
19M1M1 control line from CPUActive Low
20ResetReset line for CPU and optionally other modulesActive Low
21ClockMain CPU clock signal and optionally other modules
22INTInteruptActive Low
23MREQMemory RequestActive Low
24WRWriteActive Low
25RdReadActive Low
26IORQI/O RequestActive Low
27 – 34D0 -D78 data lines
35TxSerial transmit
36RxSerial receive
37 – 39USR1-33 spare pins for user functions
40USR44th spare pin. Suggest it is not usedAvoid

 

Enhanced Bus

The enhanced, or v2.0 bus, adds to the standard bus to allow for backwards compatibility whilst giving access to other control lines not available on the original bus.  This is intended to be an optional bus, only used if it is required.  However, if it is used, the 10 pins in the center should be the minimum.  Having additional clock, reset, Tx and Rx lines opens the RC2014 up to more advanced peripherals and the extra 8 data lines would be required if a 16 bit CPU was used.

Pin LabelDescription  Note
 1-16 Not used
 17Gnd0v power supply
185v5v power supply
19RFSHM1 control line from CPUActive Low
20Reset2/PageSecondary reset or page line for other modulesActive Low
21Clock2Secondary clock line for other modules
22BUSACKBus AcknowledgeActive Low
23HALTHaltActive Low
24BUSRQBus RequestActive Low
25WAITWaitActive Low
26NMINon-maskable InteruptActive Low
27 – 34D8 -D15Additional 8 data lines (for 16bit CPU)
35Tx2Secondary serial transmit
36Rx2Secondary serial receive
37 – 39USR5-73 spare pins for user functions
40USR84th spare pin. Suggest it is not usedAvoid

 

Making your own modules – Designed for RC2014

If you wish to design your own modules, you are, of course, free to use whatever shape, size or pin arrangement you wish.  However, keeping to the above guidelines should give your modules compatibility with other RC2014 modules.  If your module may be of use to other RC2014 owners, please consider sharing your design or selling them yourself.  I’m happy to help you with this and to spread the word.  Note that “RC2014” is a registered trademark, so you are not allowed to call your module “RC2014 [thingy] Module” or use the RC2014 logo.  However, feel free to mark your modules as “Designed for RC2014”

If you need clarification on anything here, please feel free to contact me directly using the Contact Me link or start a thread on the RC2014-Z80 Google Group.

Accessing the BUSRQ and BUSACK Pins on CPU 1.0 Modules

If you have a v1.0 CPU Module and wish to use the SD Memory Dump Module, you will need access to the BUSRQ and BUSACK pins.

BUSRQ is pin 25 on the Z80

BUSACK is pin 23 on the Z80

The good news is that the BUSACK pin is not connected to anything else and is fairly easy to solder a connector to on the PCB.

BUSRQ, sadly, is not so easy.  The 5v supply from the backplane goes via pin 25 and off to 3 other pins.  You have got a couple of options from here; Modify the PCB or solder to the CPU directly.

To modify the PCB you will need to cut 3 tracks and solder 3 wires before you can connect to pin 25.  See images below;

cpu1-0-module

cpu1-0-module-close-up

Luckily, the tracks shown in green are on the back of the PCB, so aren’t too hard to get to with a sharp knife.  You’ll need to cut each of the connections around pin 25 and then solder links to rejoin pin 11, 17 and 24 to 5v

cpu-module-1-0-after-mod

Good luck!

Retro Challenge 10/2016 – Still a work in progress

So, who remembers my entry for Retro Challenge in January?  It was quite devoid of effort and results I think you’ll agree.

Well, this time around, I’ve taken that theme and pushed it even further!  Even less effort and much less result.

Since January, I have had a few opportunities to carry on with the ZX81 Module.  Because I wanted this to be a Retro Challenge project, I deliberately avoided doing any work on it, so I could save it all for October.  Well, October started and I was overwhelmed with non-Retro Challenge stuff.  But after a couple of weeks, I had a spare afternoon, and decided to dedicate this to the ZX81 Module!

So, I dug out the PCBs I had manufactured in January and fired up the soldering iron;

retrochallenge10-2016_1

Time to wrack my brains and work out what my plans had been 9 months earlier.  I had failed to put any component values on the PCB, or even my Kicad schematics, so had to rifle through original ZX81 schematics to work out what these should be.

Now I knew what components I needed, it quickly dawned on me that I didn’t have very many of these at all.  This didn’t deter me though.  I fitted everything I had; IC socket, pin headers, some resistors and some transistors that may or may not be compatible;

retrochallenge10-2016_2

And that’s about it.  I have ordered the rest of the parts now, but not had an opportunity to fit them.  yet.

One thing I have learned from this experience though, is that if I get any opportunity or urge to work on this, then I will seize it.  Not wait until the next Retro Challenge.  If I’d done work on this months ago when I had the chance, then this would more likely be a trouble shooting / tweaking / developing challenge.

One other good thing that has come out of this though, is that when I started this in January, I had a few design changes or additions required for the RC2014 for it to work.  The Backplane 8 has the ability to add resistors between the CPU and the RAM.  The Universal Micro Keyboard has the right connections to work with a real ZX81 or this ZX81 Module (including diodes).  The CPU Module also now has BUSRQ, WAIT, NMI and WAIT pins broken out which is required for this.  These changes should all make things much easier.

Despite my poor efforts this time around, I have thoroughly enjoyed seeing what everybody else has achieved with their Retro Challenge.  Good work everybody else!

Use Pocket C.H.I.P as RC2014 Terminal

If you don’t know about Pocket C.H.I.P, then firstly, where have you been? And secondly, check out getchip.com

Assuming you have one, and assuming you have an RC2014, I’m sure you’re wanting to connect them together. Well, good news… it’s easy!


To begin with, open the Terminal and download Screen;

sudo apt-get install screen   (Default password is chip)
The biggest “gotcha” is that the internal serial port service needs to be turned off, otherwise it just spews stuff.  To do this, 

sudo systemctl stop serial-getty@ttyS0.service

(Have a look at this article on more info about that) 
Then start screen

sudo screen /dev/ttyS0 115200

The connectors on the top of the Pocket C.H.I.P are those nice offset ones that will take a strip of straight header pins and hold it there (Thanks NextCo!), so plug in a 4 way header to the very right, and connect Ground, UART:TX, UART:RX to the RC2014.

And that’s it! You’re good to go! 

Retro Challenge 2016 – My Dog Ate My Homework

So, all the way back in deepest darkest December, I announced I would enter the Retro Challenge 2016 competition that ran throughout January.  Those of you that followed by blog or Twitter account when I did this in 2014 will know that I blogged and Tweeted relentlessly for the whole month, but, this time around, almost nothing.  Obviously, I’m keeping some secret about an amazing breakthrough or something, right?  Well, truth is, I’ve done almost nothing.

Things started well, and on 1st January, I designed a new backplane for the RC2014.  Although I hadn’t studied the circuit diagrams for the ZX81, Jupiter Ace or ZX Spectrum yet, I knew that there were resistiors between the Z80 CPU and other devices.  The stripboard backplane I’d been using had served me well, but it was time to progress to a better solution, and one that could be adapted better to my needs.  Knowing that PCB delivery times could be against me, I thought it best to crack on and get this  ordered.

Screenshot from 2016-01-31 16:01:00

The basic circuit is very very simple – however, I wanted to get this just right, not only for Retro Challenge 2016, but for other possible RC2014 uses.  Essentially, there are 8 40 way connectors that are linked straight through – however, the data lines and address lines for the leftmost 2 connectors and rightmost 2 connectors are separated by a pair of pads.  These can either be shorted together for up to 8 commoned connectors, or have resistors soldered across them.  I also added a power connector and the option of either running 5v directly in to the board, or regulating a higher voltage down via a LM7805.

(more…)

HDMI and USB Keyboard Support

So, the RC2014 is a great little computer.  We all know that.  However, to communicate with it, it is easiest to use the serial port and hook it up to a laptop or desktop PC.  This makes detracts from the fact that it is small, portable and cheap as well as missing the point of running code on such a basic computer.  So I’ve been looking for a solution to this.

Back when this was still running on a breadboard, I hooked up an Atmel ‘328 that was connected to a keyboard and 4 x 20 LCD display.  It communicated with the RC2014 over the serial port and kind of worked ok, although 4 lines was very restrictive and the Atmel couldn’t really keep the screen running and listening at the same time.   I have thought about using a ‘328 to drive a composite output, or maybe some kind of bigger LCD panel, but nothing really struck me as just right.

That is, until the kind people at Raspberry Pi released a cheap multifunction interface device a couple of weeks ago!

2015-12-18 22.13.44

(more…)