Saturday, September 24, 2022

Building The Z80-MBC2 Retro Homebrew Computer (Part 1)




Project Source: https://hackaday.io/project/159973-z80-mbc2-a-4-ics-homebrew-z80-computer

Project Source Alt.: https://www.instructables.com/An-Easy-to-Build-Real-Homemade-Computer-Z80-MBC2/

Author's Website (Just4Fun): https://j4f.info/z80-mbc2 <--- Check it out!

My first adventure into the wonderful world of home computers was in 1981, with the Texas InstrumentsTI-99/4A, from there my horizons expanded to Commodore, Tandy, and forward into what we would better recognize today as a home computer. I never had the opportunity to play around with early home computers like the Altair 8800, IMSAI 8080, or Southwest Technical Products Corporation 6800, they were all before I was old enough to understand what they were, outside of just a cool futuristic looking piece of technology.

As I got older my interest in these early machines grew, but I never really had any interest in owning one simply because I had no idea what I would do with it. Fast forward to 2022, and Adrian Black from Adrian’s Digital Basement featured the SWTPC 6800 in one of his repair videos, and that once again sparked my interest. Still, I had no desire to own an original machine, they’re simply too large and difficult to maintain, but modern reproductions, or similar modern homebrew computers, that’s a completely different story.

The problem with most reproductions is they’re mostly all emulated devices in housings simply made to look and work like the original machines, and I wanted to build something that was less about software emulation and more about the actual hardware. That search led me to two different machines, the RC2014 and the Z80-MBC2, both homebrew computers reminiscent of these early machines, with a few modern conveniences built in.

After quite a bit of consideration, I decided to go with the Z80-MBC2, the amazing little Z80 based homebrew computer from user Just4Fun over on Hackaday.io. Yes, the RC2014 looked the part and had more expandability with its era appropriate card style layout, all plugging into a single back-plane, but I wanted something smaller, with the same basic capabilities. The Z80-MBC2 was simple and cheaper to build than the RC2014, could still run all the software I wanted, and fit better into my final vision of what I wanted to build. 

I also wanted the learning experience of building a homebrew computer myself. Many of the projects I do are primarily based around micro-controllers, but having the ability to learn and understand how to build a simple basic computer would also help me with future project ideas. So this is a win-win for me, I get to build a very cool little retro homebrew computer, and I also get to learn how it’s designed and how it works.

This project will be broken up into 3 parts, the first will be building the Z80-MBC2 itself and getting it up and running. The second will be building the uTerm, a VT100 style terminal add-on from Just4Fun that allows the Z80-MBC2 act more like a stand-alone computer. Finally, putting all the hardware into a case to make an awesome little homebrew computer that feels like a modern extension of these early machines of the 1970s. I will also include links to all the resources you should need to build this project, as well as hints that may help someone building one themselves that may not have as much experience.

First off, it goes without saying that basic soldering skills and tools are required. You'll also need tools to program the AtMega32 and communicate with the Z80-MBC2. A basic understanding of electronic components is also recommended, as well as how to use software tools like the Arduino IDE, AVRDUDE (if necessary or using Linux), and a terminal emulator like Putty (what I use but you can use anything you like). Moving forward, I will assume you have a general understanding of what you’re doing, or are willing to learn. This won’t be a full-on step-by-step tutorial since everything you need to know is already out there, this will just be an overview of how I did my build, and to maybe help point others in the right direction. I will also try and keep everything in “simple English” as much as I possibly can. Lastly, I won’t be covering any troubleshooting since that’s a whole different ball of wax I just don’t have time to work on right now. 

That all being said, let's dive into it!




Everything you need for this build is on the project page for the Z80-MBC2 linked at the top of this post. Moving forward, I'm going to assume you've read that already!

Building the actual computer is relatively straight forward once you track down all the parts you’re going to need. Just solder it all together as indicated in the included BOM (Bill Of Materials) and schematics. Every part, it’s value and location, are clearly spelled out in those documents. If you're in need of software to view the documents, I suggest OpenOffice. It's 100% free, trusted, and can handle most document formats easily.

 

Here are a few key points worth noting for those who may not be as familiar with electronics.

1. As a matter of practice, if you’re able, you should test all your components before soldering them into your project. Personally, I suggest a component tester like one of these, https://amzn.to/3R9azhC or https://amzn.to/3Ra19Tl, but you can also use a good old-fashioned multimeter if you have one, here’s how: https://www.electricaltechnology.org/2014/01/testing-electrical-and-electronics-components-with-multimeter.html

2. If you do decide to go with a component tester, note that most do not read capacitors under 25pF, so they will likely read as unknown or damaged, and the Z80-MBC2 does require two 22pF ceramic capacitors. You can still test these with your multimeter, here is a link on how to do that: https://www.electronicshub.org/how-to-test-a-capacitor/

3. To test your crystal oscillator you need either an oscilloscope, multimeter with the ability to check crystals, or a stand-alone crystal oscillator tester. While I do have an oscilloscope, my preferred method is to use a simple and cheap tester. It's quick, easy, and they're readily available online for under $20. Here is a link to the one I bought, built, and use (https://amzn.to/3SAMiD2), it comes as a DIY kit. However there are many of them available, some assembled, some as kits. Just do a bit of searching for what you prefer.

4. The electrolytic capacitors must be soldered in according to polarity, like a battery, they have both a positive and negative terminal, and is clearly indicated on the capacitor itself. On the PCB the positive side is indicated by a "+" sign and a square pad. The negative is solid white. The ceramic capacitors do NOT have a polarity and may be soldered in any orientation.

5. The diodes must also be installed in a specific direction, as indicated on the PCB. Simply match the line on the diode with the line on the PCB. The side with the lines will also have a square pad. The LEDs are diodes and work the same way, they must be installed one way, according to polarity. The square pad is the "negative" (cathode)  side, and the negative side on the LED itself is the short leg. The long leg is "positive" (anode). The LED colors used are also important becasue different colors have different forward voltages. Sticking with the suggested colors is your best bet if you're not sure.

6. The standard single resistors can all be installed however you choose, but the two resistor arrays (also called network resistors) must be installed one way, as indicated by the small dot on one end of the package. Line up that dot with the square pad on the PCB, the pad on that side is also square.

7. The sockets also have an orientation, simply match the notch on the socket with the notch indicated on the PCB.  

8. The buttons will work no matter the orientation and will only fit in a way they will work.

9. Lastly, look at the photos of the Z80-MBC2 for the orientation of the SD card reader and RTC module. Installing them backwards can and will likely damage them.

All of the parts you need are in the BOM (Bill Of Materials) that you can download on the projects homepage, it's labeled as "A040618 BOM v2.ods" in the "Files" section of the page. 

Below is a list of links to help you track down the components to build the Z80-MBC2.

Buy the Z80-MBC2 PCB


eBay: https://www.ebay.com/sch/i.html?_from=R40&_trksid=p2047675.m570.l1313&_nkw=z80-MBC2&_sacat=0

PCBWay: https://www.pcbway.com/project/shareproject/Z80_MBC2__4ICs_homemade_Z80_computer.html

Individual Components


The following are all Amazon links to the individual components, when possible, just to keep it fast and simple. However, all these components can be found at many other sites like Mouser, Digikey, and more, many can even be found on eBay. You can shop around to save a bit of money, especially when buying in bulk. Many of these components are also available in “kits” on Amazon and other sites, giving you a variety pack you can have on hand for other projects.
 
These are mostly all components I have purchased and used. You will see sellers like HiLetgo, Bojack, Chanzon, E-Projects, and EEEEE pop up a lot in my links because I've bought from them in the past and had good luck getting good quality components. 

Here is a socket kit I have not used, but contains all the necessary sizes: https://amzn.to/3E5tuaz

Notes

I prefer the standard (dual leaf) sockets over the round hole (turned) style. This is just a personal preference, both will work and you can choose whatever you like.

I did not include individual links to all the resistors because these are really easy to find and have a pretty wide tolerance, and it’s somewhat difficult to get resistors so far out of spec you can’t use them when a project like this gives you a 5% tolerance variance. Many "cheap" resistors that claim they are within 1%, are actually 2-3%. Either way, for this project and many others, as long as you buy ones that say 1%, you’re generally safe.

Amazon Search 1/4 Watt Resistors: https://amzn.to/3SCccGt

Also, there are a lot of good resistor assortment kits sold on Amazon, and many contain almost all the ones you need for the Z80-MBC2 and uTerm, so you will only need to but a couple values separately. Just remember 5% (shoot for 1%) and ¼ watt and you’re good.

In the bill of materials, they list 4k7 and 1k2 resistor values, this is just another way of writing 4.7K  ohms and 1.2K ohms.

I will include the link to the 10Kx8 resistors I bought in a kit. I needed a couple others for another project, but just in case you’re having trouble tracking them down or need more.

https://amzn.to/3LWxVGg

 
For the LEDs, be sure to use the colors indicated, or other colors with the same forward voltage value. This is talked about on the project page as well.

Lastly, all the IC's you need can easily be found on eBay, simply search the part numbers. Buy from sellers in the USA (or your local area) when possible to increase your chances of getting "good" parts. It  also makes it a lot quicker and easier to not only get your parts, but do returns if necessary.
 
eBay Search for Z80 CMOS CPU - Remember, Z84C0008PEC and Z84C0020PEC CMOS processors will both work. The number before the "PEC" denotes the max clock speed, so technically anything "08" or higher should be fine.

 
eBay Search for TC551001-70 CMOS RAM - I specifically purchased and used Toshiba TC551001BPL-70L.
 
 eBay Search for 74HC00 Quad 2 Input NAND Gate - Specifically, the SN74HC00N.

eBay Search for MCP23017 16-Bit I/O Expander - Specifically, the MCP23017-E/SP.
 
Important Note: The RTC (Real Time Clock) module, and the MCP23017-E/SP chip listed above, are NOT required for the Z80-MBC2 to operate. The MCP23017-E/SP controls the GPIO on the Z80-MBC2, and if you have no intentions on using the GPIO, then you don't need this chip. The RTC is only needed if you require or want a real-time clock function. Both of these parts can be added later is needed.

RTC Module: https://amzn.to/3CjAEXf



Once you have everything assembled, it’s time to burn the bootloader to the AtMega32 chip and then load the “sketch” that acts like the system ROM. A ROM (Read Only Memory) is a chip used to store information a computer needs to operate, and they’re still used today, the BIOS or UEFI in your modern home computer is a type of ROM. On older machines these would contain the information necessary for the computer to function such as the operating environment (like BASIC) and the characters the computer can display, and things of that nature. Without it, the computer has no idea what to do when you turn it on. In the case of the Z80-MBC2, instead of using a ROM that requires an expensive tool to program, they opted to use an Atmel Microchip AtMega32 micro-controller to act as the system ROM. These can be easily setup right on the board using cheap readily available tools and can do the exact same task as a ROM chip would have done in older machines. This is an over-simplification, but you get the idea.

In order to burn the bootloader to the AtMega32, you’re going to want something like this: https://amzn.to/3ffchky or https://amzn.to/3C7pJA1 They’re not that difficult to use and it can all be done from within the Arduino IDE, here is a link to guide you though the process. 

https://www.instructables.com/Z80-MBC-Programming-the-Atmega32a/

Important Note #1: Make sure nothing else is connected to the Z80-MBC2, other than the programmer. Disconnect the serial USB adapter, SD card reader, and RTC module if you have one.

Important Note #2: Some of these programmers will not work with Windows 10/11 out of the box. Some of them can be flashed with updated firmware to add support, but that’s a whole different ball of wax I don’t suggest for inexperienced users. Be sure to read the information provided for the programmer carefully before buying one, many list what operating systems they’re compatible with. If they don’t, then read the reviews. If you still can’t find that information, then you may want to look at a different one that does list it. However, most all of them work fine in Linux.

In my case, the programmers I have do not work with Windows 10/11 without their firmware being updated, but I opt to just use Ubuntu instead of Windows when I need to use one of them. This is also one of the reasons why I have a “bench computer” running Ubuntu, just in case I run into problems using Windows. Using the Arduino IDE, install MightyCore as you would under Windows, and install AVRDUDE. That combination will work with most of these programmers under Linux and save you a lot of headaches using them on Windows if they’re not already capable of doing so. 

If you already have Arduino IDE and MightyCore installed per the instructions in the link above, installing AVRDUDE in Linux is easy, just type the following into the terminal. Once done, you can burn the bootloader right in Arduino IDE as covered in the link above.

sudo apt-get install avrdude

Once you have the bootloader burned onto the chip, it’s time to load the “sketch”, and that’s a much simpler process. All you need to do is connect the Z80-MBC2 to your PC using your serial USB adapter, making sure all the wires are connected properly so you don’t damage anything. Make sure you have MightyCore installed and setup correctly in the Arduino IDE according to the instructions in the link below, load the sketch into the Arduino IDE, and then click the upload button. If all goes well, it should load the sketch onto the AtMega32 and indicate a successful upload. Here is a link to those instructions, as well as covering the bootloader if you're still having troubles. 

Serial USB Adapter: https://amzn.to/3y6d6CM

https://www.instructables.com/An-Easy-to-Build-Real-Homemade-Computer-Z80-MBC2/



If you haven’t done so already, now would be a good time to copy the OS onto your SD card. Just format the card as FAT32, a 1GB card is more than enough space for anything you’ll likely be doing with this computer. Unzip the contents of the "SD-S220718-R191018-v1.zip" file to the SD cards root directory. It's as simple as that!




Ensure the Z80-MBC2 is disconnected and powered down by unplugging the serial USB adapter from your PC, now connect the SD card reader with the SD card inserted, and RTC module if you have one, then reconnect the serial USB adapter to your PC to power the Z80-MBC2 back up. Press and hold the “USER” button, then press and release the “RESET” button. Continue to hold the "USER" button until the green IOS LED begins to flash, then release. This will bring up the “setup” menu for the computer, but how do you see it?

 



The terminal emulator is the software you use to interact with the Z80-MBC2, allowing you to use your computers monitor and keyboard to control it. Personally, I use Putty as my goto terminal emulator. It’s free, trusted, and easy to use.

Once you have Putty open, you need to tell it where to look for your serial USB adapter, to make this as easy as possible, here are my profile setting I use for the Z80-MBC2. The COM port may be different for you, it’s most likely going to be COM1, COM2, or COM3. If one doesn’t work, try another. 

 

Once you have Putty (or whatever terminal emulator you use) connected to the Z80-MBC2, reset the computer as described above, and you should be greeted with a screen that looks something like the one below, if not, try the reset process again, there is no need to unplug the serial USB adapter. Note that mine may look a bit different since it's been setup already, yours may say the clock is set to 4MHz for example (to set it at 8MHz, just use option 6).


From this menu you can set the operating speed of the computer, I suggest 8MHz, and what operating environment to boot into when you power it up, I have mine set to CP/M 2.2 for the moment. You can make these changes by simply pressing the corresponding number. Easy peasy.

You can setup the system to boot directly into BASIC, the problem is you can’t save your work to the SD card this way. Booting into CP/M and loading up MBASIC gives you the ability to save and load your work easily. You can even control the GPIO pins via BASIC programs.




There is a good deal of software out there that can run in CP/M on the Z80-MBC2, and thankfully a huge archive of it can be found at the link below.

http://cpmarchives.classiccmp.org/

Getting the files from your PC to the Z80-MBC2 can be done in two ways, and one is significantly easier than the other. The drives accessible to CP/M are stored on the SD card as disk images, so you can’t just drag and drop files onto the SD card and access them in CP/M. However, a simple tool does exist that allows you to easily add and remove files from the disk images on the SD card, and this is the method I prefer to use.

Read this first! https://www.instructables.com/Z80-mbc2-Virtual-Disks-Copying-Files/ Read this first!

Authors Site: http://star.gmobb.jp/koji/cgi/wiki.cgi?page=CpmtoolsGUI

Mirror Download: https://www.mediafire.com/file/v0n6vxkqh0o0gw6/CPMTG20190501.zip/file

There is a bit of prep that needs to be done first, and that’s to copy the "diskdefs" from the root directory of the SD card to the same directory you unzipped the software into. Copy it and overwrite the one that’s included with the software.

Once you’ve done that, simply run the software, select the disk image you wish to access, select the proper format, “z80mbc2-d1” for CP/M 2.2 or “z80mbc2-cpm3” for CP/M 3. Now you can add and remove files from the disk images with ease. The "G" button is to "Get" files from the image and move them to your computer, the "P" button it to "Put" files into the selected image from your computer. In the example below, I have image file DS0N06.DSK selected, that is drive "G" in CP/M 2.2.

 

I highly recommend reading the article I linked above on the “manual” way adding files, even if you plan on using the "Cpmtools GUI" software, specifically the section that explains how the image system works so you know where to add your files and how to access them in CP/M on the Z80-MBC2.

If you’re unfamiliar with how to use CP/M, it’s very similar to MS-DOS, but I highly suggest checking out some of the links below to learn more.

CP/M 2.2 Users Guide: http://www.cpm.z80.de/manuals/cpm22-m.pdf

Alt Link: https://vt100.net/rm/docs/pn11901.pdf 

CP/M 3 Users Guide: http://www.cpm.z80.de/manuals/cpm3-cmd.pdf

Alt Link: http://www.s100computers.com/Software Folder/CPM3 BIOS Installation/CPM3 System Guide.pdf

Full List: http://www.cpm.z80.de/drilib.html 




Now that I have my Z80-MBC2 up and running, I will go about customizing the software library to fit my needs and work on building the uTerm board so it can operate as a standalone computer. Then I can start to work on customizing the case I want to put it all in. Look for all that in parts 2 and 3!

For now though, it's time to just mess around and have some fun! 

Thanks for reading and happy retro computing!!!

Read Part 2 - The uTerm Build: https://theclassicgeek.blogspot.com/2022/10/z80-mbc2-build-part-2-uterm-vt100-style.html


 
 
Updated on 9/30/22 to include component links.

No comments:

Post a Comment