Monday 30 September 2013

Z80 Single Board Computer (PET Project Part 3)

This is an old post, preserved for reference.
The products and services mentioned within are no longer available.

This is a further use of the Arduino TV Out Library I previous posted. It is effectively a Z80 single board computer.
OK, it's made on more that one board, but you get the point. Based on Grant's 7-chip Z80 computer, it uses his modified version of the NASCOM computer version of Microsoft BASIC running from an 8K ROM. The remainder of the Z80's 64K address space is taken up with 56K of RAM. The board on the left contains the Z80 side of the system and the right hand side controls all the input and output, leaving the Z80 free to run code all of the time rather than having to bother about screen display or keyboard scanning.
The keyboard is borrowed from a Commodore Pet as this will end up as part of my 'Pet Project', a plan to fill the gap inside an old Commodore Pet where the mainboard was removed 20 odd years ago. The box on the bottom right is an in circuit programmer, the USBtiny ISP (see my review of the USBtiny ISP), to program the chips from the Arduino IDE.
On the left there is the Z80 side of the system. The EPROM, RAM and the Z80 CPU, are all under the nest of wires on the top row of the left breadboard. On the bottom of the left board is the clock, running at 7.3728MHz. A slightly odd frequency, this is used as it is exactly 64 times 115200, which is the BAUD rate used by the serial communications within the system. Those serial comms being handled by a 6850 UART on the bottom right on that first board. There are three connections across to the second board, RX, TX and reset (there is now and additional RTS line to ensure the serial buffer doesn't overflow).
On the right are two ATMega328P microcontrollers. The left hand one is connected to the serial RX and TX from the Z80 SBC. Also connected to that are the 8 column lines of the Commodore Pet keyboard. There aren't enough pins spare for the 10 row lines, so I borrowed the idea from the Commodore Pet itself of driving those via a 74LS145 BCD to decimal converter. That means it uses just 4 lines to drives one of 10 outputs. The columns are read as inputs, pulled high internally. The keyboard is scanned and any key presses sent over serial. Any data coming back over the serial is send out of the I2C port to the second ATMega 328P, using the Arduino TV Out Library. That is basically the same thing which is on the shield version, an ATMega 328P and a 74HCT166 shift register.
Indeed, I initially build this up on the shield version, but fell foul of the fact the hardware serial port on the Arduino is used for serial programming, and so cannot be used for other purposes. I thought about switching to the Leonardo, which does have two serial ports, but the I2C pins are in a different location, so the shield wouldn't have worked. So I went straight to breadboard for it all. The components of the shield are duplicated, and together, they generates a composite video signal which is sent to the TV. On power up, the keyboard / serial processor holds down the reset line of the Z80 until it is ready, then releases it, so there is always a clean start.
I'm planning to build a series of boards inside the Pet, this will be the first, a simple Z80 SBC running BASIC. I've build up a slightly different version using a 63B50 (a CMOS version of the 6850), a modern CMOS Z80 CPU, 74HC chips and 32K of RAM.
This version uses less than 20mA, so can easily be powered via a USB to Serial adapter such as the FTDI clone Arduino USB2Serial Light, and run from a serial terminal. For reference the left hand breadboard version uses around 150mA, with 50mA for the keyboard / display side.