Let's Make Robots!

Beginnings

 

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.

Programmer view of the Z80 architecture

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

any progress here? I like your project :)

I still plan to finish this, but many other projects have taken priority.  I hope to come back to it before too long.

I loved the Z80. Been a long time since I used one. I look forward to seeing your progress.

I had to build my own Z80 based computer as part of my associate diploma in electronic engineering. I think I still have the schematics and PCB layout somewhere. It was the first time (only time) I made a double sided PCB.

because the Z80 was limited to addressing 64K of memory I used 64K of RAM, 64K of ROM and a bank selection system that allowed the software to switch between RAM and ROM in banks of 4K.

By breaking your main program up into 4K sections and just copying the sections you needed into RAM when you needed them it meant you could run with as little as 8K ROM and 56K RAM but still run complex software that was stored in the 64K of ROM.

For example if your robot needs to be able to follow a line through a maze and perform different task at different locations in the maze then the line following code might be part of the base 4K of ROM but the code for the different tasks within the maze would only be loaded into the next 4K of ROM as they were needed. This then leaves 56K of RAM for processing the code and storing a map of the maze as the robot explores it.

I considered bank switching, but I will probably not implement it.  I want to keep it as simple as possible.  64K should be enough, especially if I use an sd card to load programs in.  I "could" even put in a simple virtual memory system if I need bigger programs, but for what I have planned I don't think that will be necessary.  At some point I have to say "enough".  Besides, I will probably run CP/M on it and CP/M 2.2 can't use more than 64K anyway.  Thanks for the input.

I will start my blog today as well :)

Regarding bus drivers: I saw many projects which omit the bus drivers. I have a CMOS version of Z80; ROM, RAM and logic IC's will be CMOS too, so I see no obvious reason to use bus drivers, but I have to dig deeper into it.

You have certainly seen the book Build your own Z80 computer, which is completely available at Google books.

Another work I have studied with great interests is this: searle.hostei.com/grant/z80/SimpleZ80.html

 

If there aren't many chips on the buses, drivers won't be needed.  It is mostly a capacative loading problem.  My NMOS z80 is a lot more likely to need them than your CMOS.  Less than say 6 chips, all on one board, I should be ok.  More, or more than one board, I will probably have to have them.

I read the build your own z80 30 years ago when it came out.  I recently found it in a library and read it again.  Great book.  The other link I wasn't aware of.  Thanks.

 

When I started thinking about doing this, I dug out the old stuff.  I have a wirewrap proto board I built with a z80 and an eprom on it.  I also have some 8255s and some other assorted vintage hardware, and some newer stuff like ram chips.  I'm pretty sure I have everything, or at least all the hard to get stuff.

Thanks for the feedback and encouragement!

Question is if you can get the antique chips you will be needing. I have built several Z80 based computers in my younger days. Mostly using wire-wrap, but also at least one using a breadboard.

Using an AVR as bootloader will be nifty. Back in the days I used a homegrown eprom emulator, worked like a charm, Z80 based as it were.

Unfortunately I trashed all my Z80's and related chips some years ago, so I will not be able to join you folks on your journey back in time. But I'm going to follow your work closely, it's gonna be awesome!

Mogul - who's first computer were a 1K ZX81