May 19, 2013
May 19, 2013
I am building a robot controller board using a Zilog Z-80 processor. For those who don't know, the Z-80 was one of two major CPU chips in the late 70s and early 80s, before the IBM PC ruined ruled the world. The other was the 6502. I hope you will follow along as the project progresses. It will be fun. Why on earth would I want to do such a thing? Glad you asked.
The first computer I ever got to play with was a Radio Shack TRS-80 Model I. It had 4K or RAM (not megs or gigs). There was no 2 terabyte disk drive. There wasn't even a floppy disk. It had a cassette to load and store programs and data. There was no Linux or Windows, or MS DOS, or even CP/M (which existed but wouldn't run on that machine). It had a screen with 16 lines of 64 characters, black and white only, no grays or colors. It had very crude graphics that were made by having special graphic characters. That was at school, it wasn't mine. When you turned it on you got a BASIC programming prompt. You couldn't do ANYTHING unless you at least could type enough BASIC commands to load another program. But programming is mostly what we did. And it was fun. And sometimes, by accident, we even got real work done on those machines. I got my own computer soon after. A Sinclair ZX-81 with 1K of RAM. Not the Timex version with 2K of RAM. Then I had a series of machines that were more and more powerful. But I always had a fondness for those old computers. They were simple and worked well. YOu could actually understand EVERYTHING about them. And they would do all kinds of cool stuff. I was especially fond of the Z80.
So I have been wanting to build a "retro" project for quite some time, using an old Z80 and mostly similar technology. But I just couldn't decide on a good project that would actually be useful. Two things have recently made it easy to decide what to do. The first was the recent wave of hugely powerful ARM based controller boards, like the Raspeberry PI and BeagleBone Black. These are incredibly powerful machines. More powerful and a lot more memory than the most powerful supercomputers made when I started out ( Cray 1 ). They have video output unimaginable in 1979. There are programming resources on them that are worlds beyond the best things available 30 years ago. And yet, most of the robots built with them don't do much more than a Heathkit Hero 1 from 1983. In some cases, much less. That really bothers me. I have actually seen people complain they aren't powerful enough! The second bit of inspiration came from robot.grl. In the shoutbox, she mentioned she had built a robot some time ago using a z80 processor. AHA! My project was born. I shall build a z80 based robot controller! Then, just this very morning, in the shoutbox MarcusB just happened to mention he was building a z80 computer! WOW! The stars are aligned. After some discussion it seems he and I were having similar thoughts. We discussed some of our inspiration, why we wanted to do this, and some technical details. Then we both said we would write up our build as a blog here on LMR. I'm sure we will exchange ideas along the way. It should be interesting. If you haven't yet seen his writeup, please take a look. I will put a link to it here when I see it.
The Plan: First Iteration
Now that the heady days of inspiration are over, time to get on with the perspiration. The z80 is a processor. That's all. It has no memory or input/output on the chip. It doesn't even have a clock circuit! First you have to build a clock circuit. Oh, yeah. No reset circuit, either. I'll need one of those. Then it will need some memory. How much and what kind? Well, definitely some RAM. Probably fill it up with 64K. Probably some ROM. EPROM is the "logical" choice, since I have some chips and a programmer and eraser. But eprom sucks. It's a pain to program and erase. You have to take it out of the socket, put it in the eraser for about 20 minutes, load it into the programmer and program it, then put it back in the socket and try your new program. The crash and burn cycle. Then change your code and do it again. I could use flash or eeprom, but there still isn't an easy way to program them without either using extra circuitry or an external programmer. Hmmm, maybe add a little AVR to interface to the PC and act as a bootloader! I'm not building a 1982 microcomputer replica, just a computer that uses 1982 technology, so that isn't really cheating. And of course we need some I/O. Probably some 8255 I/O chips to start. All this stuff has to be connected to the address, data, and control busses. If I use a large ( 6 x 9 inch ) PC board I can probably fit everything I need on it. We'll see. I might get away with only those chips, but I may need to add some bus driving chips, too. Not sure yet. I hope not. The goal is a one board solution. I will have to have some kind of storage, and sd cards look like the way to go. But maybe I will just add a flash chip or two. I could also use the AVR chip as an I/O and communication device.
Back in those days, the z80 was considered to be quite fast. Especially if you used the z80A that ran at four Mhz. Compare that to an AVR ATMega that runs at 20 MHz. And the z80 took 4 to 20 clock cycles per instruction, where the AVR takes 1 or 2. And the instructions on the AVR are more powerful. So, in all, the AVR is about 25 times faster than the z80. And I will be using the stock 2.5 MHz z80, so it's even slower. But the Hero 1 had a 6808 with 2K of ROM and 4K of RAM, and probably ran at 1 MHz. We should be ok.
Only the Beginning...
The title of this blog post is Beginnings. It has two meanings: It takes us back to our beginnings, where it all started, and it is only the beginning of a long project. I will add to this blog as time goes and I hope you will follow along. If you are really adventurous, maybe you will join MarcusB and I and build one yourself!
Update Sep 17, 2014
This project got sidelined for a long time for various reasons, but thanks to vis it is back on track. I have started designing the schematic and researching some development tools. The design isn't final yet. Much will depend on what parts I have or can get easily. The construction method will be important too. I will probably design and build a single sided, home made pcb. That will limit the complexity somewhat. We shall see where it goes.
References, Links, and Further Resources
This section will have a list of resources used or that might be interesting or useful. More to come...
http://www.retroarchive.org/cpm/lang/lang.htm Lots of z80 and CP/M stuff, including microsoft basic
http://www.z80.info/z80os.htm Another z80 specific site with lots of info and software
http://www.tramm.li/i8080/ An online simulator for the 8080, the z80's predecessor
http://www.joelowens.org/z80/index.html An old z80 control computer site, with a FORTH interpretet!
http://www.classiccmp.org/dunfield/altair/altair6.htm The one that started it all: Altair. Some good stuff that may help out.
http://www.virtualaltair.com/virtualaltair.com/vac_introduction.asp More Altair stuff.
http://www.cpm.z80.de/source.html Digital Research wrote CP/M and lots of other 8080/z80 sw. Lot of source code here.
http://www.interact-sw.co.uk/altair/index2.html Altair basic, with disassembly. The FIRST Microsoft product!
http://www.cpm.z80.de/ More Z80 specific stuff. Lots of good stuff with a lot of overlap from previous sites
http://www.retrotechnology.com/dri/howto_cpm.html What is CP/M and how can I use it?
http://quinndunki.com/blondihacks/ A similar project but with a 6502. Lots of other cool stuff, too.
https://en.wikipedia.org/wiki/Zilog_Z80 Wikipedia entry on the z80.
http://www.zophar.net/z80.html Z80 emulators to run on PC. This will be very useful.
http://www.autometer.de/unix4fun/z80pack/ Z80 pack simulators and software