Sunday, 8 September 2013

Vintage IBM 5160 XT Teardown - Part 1

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

I've recently got my hands on an IBM XT model 5160. This is the successor to the original IBM PC 5150. It was compatible with it's predecessor, so is probably one of the first to call itself 'PC Compatible'.
I think this is probably the first real PC, it was the first to come with a hard drive as standard, the one that introduced the legendary 640K RAM limit, and the first to use the slot spacing still in use today. The slots on the 5150 were wider, see later for an example of a 5150 card, whereas the 5160 used the same backplane format as use adopted as the standard for 8 bit ISA, 16 bit ISA, VESA, PCI, AGP and now PCI Express.
So this is what I got, it's fully equipped, and has had many upgrades fitted. The original would probably have had a full height 5.25" 360K floppy drive, and a full height MFM hard drive (tens of megabytes in size). This has been upgraded to have two 2.5" half height drives, and two half height MFM hard drives. There are also a number of add on cards.
First, the motherboard. This is smaller that I was expecting, about the size of an ATX motherboard. There isn't actually much on there when it comes down to it.
There is an intel 8088 processor, the 8 bit version of the 8086 processor that spawned the generations of processors to come. There is also an Intel 8087 numeric co-processor, which sped up the floating point mathematics capabilities of the 8088.
There are 4 banks of RAM, in this case, banks 0 and 1 hold 50256 chips (so each bank is 256K), and banks 2 and 3 hold 4164 chips (so each bank is 64K). That gives a total of 640K, which is the maxium supported, and although at the time, '640K Ought to be Enough for Anyone' (as Bill Gates didn't say), it proved to be quite a problem in future. The date codes on all the RAM are early 1986, and the board is dated later 1986, so I presume this machines was supplied with the full 640K from new.
There are various members of the 82xx series family on board, the 8255 I/O chip (providing keyboard, speaker and reading the DIP swich), and 8237 DMA Controller, the 8253 Timer and 8259 interrupt controller.
Apart from those, some glue logic, and the BIOS chips, the only other things on note on the main board are the 8 ISA slots. This is I suppose where the power of the PC family comes from. There is no real I/O capability on the main board, it is all on external cards. That means it can be upgraded and expanded very easily. PC's these days have grown to the point that there are often no add-on cards needed at all, everything is provided on the mainboard. In those days, everything was on cards, apart from the keyboard. This PC came with 4 add-on cards.
The first is the MFM hard drive controller. It's a DTC 5150 CX. I can't find out much about it. All the chips seem to be DTC custom parts (or at least custom marked parts).
Next comes the Floppy Disk Controller. This is based on the standard μPD765 FDC chip and provides two double density drives, that's 360K 5.25" or 720K 3.5".  High Density would have been 1.2MB 5.25", or 1.44MB, the standard 3.5" format in the 1990's. It's unusual to see an internal edge connector use for the drive connections. Most other cards used pin headers on the card. I see there are actually holes to fit one. There is also an external 37 pin connector, presumably for the 'expansion unit' IBM wanted you to buy, which was basically another PC case with no motherboard.
Next comes the IBM Colour Graphics Adapter. This uses the 6845 CRT Controller (the same as the BBC Micro, Commodore PET and Amstrad CPC464 for example). It has 16K display RAM and a 9 pin output (CGA) and a phono plug for composite video output.
This one appears to have come from a 5150 PC, as it has the larger plate on the end. The plate is a lot wider than a normal card, and takes up two slots on the 5160 XT. The date codes seem to confirm this, they are early 1982.
As an aside, the other card in that comparison above would have been an alternative at the time. It's an MDA (Monochrome Display Apapter). This also uses the 6845 (although the second sourced chip is marked CTC8645, the silk screen below says 6845). This has 2K RAM and the space to fit a parallel printer output at port 0x3BC, although it's not fitted here. It's the only bit I have left from my very first PC, which I got second hand in 1994. It was a 12MHz Tandon 80286 which weighed a ton. I remember I was out shopping and saw a notice in the window of a video rental shop that was closing down offering a computer for sale. I had to carry it all the way to the University flats where I was living at the time. And then I had to go all the way back to get the 12" amber screen monitor!
Another optional card not present in this machine is the parallel port, a simple output buffered affair, fixed at address 0x378. Like the port at 0x3BC on the MDA, this is another address options that will be familiar to anyone who used printer ports on PC's after this, they were all basically emulating this card.
One final optional card combined serial and parallel. This was actually configurable by moving the jumper chips around and could provide a single 9 pin RS232 serial port at 0x3F8 or 0x2F8 and a printer port at 0x378 or 0x278. Again, all these port numbers stayed with the PC for over 20 years.
That completes the standard cards, but there was one additional card inside this unit, it's called a AST MegaPlus II, so it must be good! And it appears to be packed full of stuff. It has two 8250 UARTS giving two serial ports. It has a parallel port, and a real time clock. There is also a pile of 41256 RAM chips which appear to be whopping 1 megabyte of RAM, not sure how that is used - the PC already has the maximum supported?
Two pins on one of the UARTS are bent up, not sure if this is deliberate, as they happen to be RX and TX. I need to do some more research on this card.

That's enough for Part 1. In Part 2, I'll go through the drives and the case and put it all back together.

2022 Update: I really must get around to putting this back together!

Friday, 6 September 2013

Arduino 80x25 TV Video Output Library

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

[Update: Please see the new version which supports multiple fonts and 'medium resolution' graphics]

Arduino TV Out has been around for a while, but you can't get many characters on the screen and uses a lot of the Arduino's resource. This is a library which will let you generate an 80x25 text screen on a TV or monitor from an Ardiuno. Well I say from an Arduino, it's more like two Arduinos, or to be precise, an Arduino and a second ATMega328P as a video processor, and one additional TTL chip.
The video processing work is all done by the second ATMega328P, the video processor. This leaves the main processor (the ATMega328P on the Arduino) to do whatever you like. There is a simple 8 bit data transfer whenever a new character is to be added to the display, in a similar way to driving an LCD display. The concept comes from Grant Searles Monitor and Keyboard interface, itself an update of code by Daryl Rictor (40x25 display using an ATmega8). The code in the second chip is unmodified from Grant's (download from his page above). I've completely rewritten the Arduino code, now in the form of a library to make it easier to use.

           Shift Register --> Char Data
               /                   \ 
Arduino <==> Video Processor        + ==> Video
               \                   /
                   Composite Sync

The idea is basically this, the Arduino (the first ATMega328P) has an 8 bit output port and two control lines. This interfaces to the video processor (the second ATMega328P). This has an 8 bit output port and 1 control line which is fed to a 74LS165 or 74HCT166 shift register (the pinouts are different, but they can both provide the necessary functionality, you may have more luck finding the 165) [Update: the 166 is preferable, and the HCT version should be used if possible]. The output of the shift register is the character video output data. There is also a composite sync is output from video processor. The composite sync and video data are combined via two resistors and this forms the composite video output. This composite video output is suitable to drive a modern LCD TV or an old CRT TV or monitor.
OK, so how do you do it? Well first you need to program the second microcontroller. This is written in assembler and does not use the Arduino bootloader, so needs to be uploaded via a programmer. There are many options, use an external programmer, use something like the USBTiny ISP to program in circuit, or use the Ardunio as an ISP.
If using an external programmer, such as the MiniPro, select ATMega328P, set the fuses to E6 D9 FF and select Grant's SBCVideo.hex file.
Alternatively, since there is already going to be an Arduino and a second ATMega328P, Arduino as ISP can be used. Wire up the circuit as per the Arduino as ISP demo (leave some space for the 74LS165). Here is an excellent tutorial on Arduino as ISP, and more info on avrdude.
Once built up, you can test it in the Arduino environment by selecting Arduino As ISP from the Programmer menu, As a test, load up the 'blink' example and use 'Upload using Programmer' to upload it. If all is well, the LED on digital pin 13 will blink. This is running from the second ATMega328P (their pin 13's are connected together). You can easily test this if you remove the wire and see it stop flashing. If it keeps flashing, you've reporgrammed the Arduino instead, try again. The fuses need to be set, and a hex file uploaded. This cannot be done from the Arduino environment, so you need to use avrdude on the command line to program the device. The commands required are as follows (change the com port as necessary)

  1. avrdude -P COM3 -b 19200 -c avrisp -p m328p -n
  2. avrdude -P COM3 -b 19200 -c avrisp -p m328p -U lfuse:w:0xe6:m
  3. avrdude -P COM3 -b 19200 -c avrisp -p m328p -U hfuse:w:0xd9:m
  4. avrdude -P COM3 -b 19200 -c avrisp -p m328p -U efuse:w:0xff:m
  5. avrdude -P COM3 -b 19200 -c avrisp -p m328p -U flash:w:SBCVideo.hex

Once the video processor is programmed, wire it up as per the circuit diagram. The pins on the video processor should remain the same (unless you want to modify the source). The pins on the Arduino end can be any. I chose the nearest ones. The only exception was choosing digital pin 13 as the Ack pin. This just shows activity on the LED on the Arduino for diagnostic purposes. The pin connections are:

  • Video Data In 0: Arduino D12 - ATMega328P pin 15
  • Video Data In 1: Arduino D11 - ATMega328P pin 16
  • Video Data In 2: Arduino D10 - ATMega328P pin 17
  • Video Data In 3: Arduino D9 - ATMega328P pin 18
  • Video Data In 4: Arduino D8 - ATMega328P pin 19 
  • Video Data In 5: Arduino D7 - ATMega328P pin 23 
  • Video Data In 6: Arduino D6 - ATMega328P pin 24 
  • Video Data In 7: Arduino D5 - ATMega328P pin 25
  • Video Available: Arduino D4 - ATMega328P pin 26 
  • Video Ack: Arduino D13 - ATMega328P pin 27
  • Reset: Arduino Reset - ATMega328P pin 1
  • 16 MHz Crystal to ATMega328P pins 9 and 10
  • 22pf capacitors from ATMega328P pins 9 and 10 to GND
  • Video Data Out 0: ATMega328P pin 2 - 74LS165 pin 11
  • Video Data Out 1: ATMega328P pin 3 - 74LS165 pin 12
  • Video Data Out 2: ATMega328P pin 4 - 74LS165 pin 13
  • Video Data Out 3: ATMega328P pin 5 - 74LS165 pin 14
  • Video Data Out 4: ATMega328P pin 6 - 74LS165 pin 3
  • Video Data Out 5: ATMega328P pin 11 - 74LS165 pin 4
  • Video Data Out 6: ATMega328P pin 12 - 74LS165 pin 5
  • Video Data Out 7: ATMega328P pin 13 - 74LS165 pin 6
  • Shift Register Load: ATMega328P pin 28 - 74LS165 pin 1
  • Shift Register Clock 1: ATMega328P pin 10 - 74LS165 pin 2
  • Shift Register Clock 2: GND - Shift Register pin 15
  • Shift Register Serial Load: GND - Shift Register 10
  • Composite Sync Out: ATMega328P pin 14 via 1K to Composite Video Out
  • Video Out: 74LS165 pin 9 via 470R resistor to Composite Video Out

The breadboard wiring is as follows:
It should probably look neater than this.
Once that is built, you can get on with the coding. Download the Terminal library, unzip it and copy the 'terminal' folder into the library folder in your Arduino workspace. You should then be able to include the terminal.h file in your projects.
There are a number of examples provided, these show using the library to generate things like a BBC Micro startup screen.
Or from a Commodore Pet  (notice different cursor options are available):
Since the work is now being done by the video processor, it leaves most of the Arduino free to do something more useful. For example, with a slight modification to Mike Field's Tiny BASIC, it can use the terminal as an output.
The input is from the serial terminal. It is left as an exercise for the reader to provide a keyboard of some sort. The I2C, and half of the input pins are still available, and SPI could be freed up so there are lots of choices.
Since the sync and video are available separately, it can even drive something odd like an Amstrad GT 65 green screen monitor which has separate sync and video inputs
The sync and video are wired to the monitor inputs directly. The the resistors can be removed if the composite video is not required.
The whole reason for doing all this is to drive a Commodore Pet monitor, as part of my Pet Project.
However, that turned out to be a lot more complicated. More on that later....

Wednesday, 4 September 2013

Commodore PET Project Part 1 - History

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

This is the first in a series of articles covering a project involving a Commodore PET. This PET has quite a life story, this first part covers how I what I did with it 10-12 years ago. The next articles will cover recent developments. Here it is, as it was in 2009 (ignore what's on the screen, more on that later).
The unit started life in the late 1970's as a 4032-32N. So 40 column display, 32K memory. 1MHz 6502 Processor. This one has a 12" green screen monochrome CRT monitor. Earlier models had 9" displays, certainly the 40 column versions. I think the 80 column version (8032) always had 12" monitors.
I'm calling it a PET (Personal Electronic Transactor), but I think that only refers to the original 2001 with the chiclet keyboard and built in tape player. The label on the back just says 4032-32N. The label on the front says CBM, but I have always and will probably continue to refer to it as a PET or Pet. It's probably more correctly a CBM - Commodore Business Machine(S), but I think I'll stick with PET.
The black name place has been replaced with a custom one from the original suppliers (Currie and Maughan of Gateshead), but unfortunately this has become damaged (the Tux badge is hiding where it is damaged). There is still a Maughan Microcomputers in the Metro Centre, I wonder if they are related? The normal 4032 has a black label. I may print a normal black CBM 4032 label and stick it over.
Anyway, at some point in the 90's, it died. The screen filled up with random characters - a common fault in PETs (the screen below is a 'reconstruction' of this sort of problem). At the time, a friend blamed the power supply (probably incorrectly) and 'fixed' it by removing the massive transformer and fitting a switch mode supply. That didn't fix the problem, so they took the board away to investigate further. Unfortunately, I lost touch and I never saw the board again.
So at this point (the late 1990s), I was left with the PET, with the keyboard and monitor intact, but without any of the internals. I tried to source a PET motherboard at the time, but failed. I wanted to keep it, but an empty shell wasn't much use. I decided to use what I had available, and installed a PC motherboard. There was plenty of space for a full size AT motherboard - no, I didn't forget the X, this wasn't ATX, but the older AT standard, before the standard rectangular cutout with all the connectors on. No USB, no onboard sound or video, not even a mouse port! However, it was a functional PC, but there were two main problems to solve, the display and the keyboard.
Firstly, the display. The PET display is a 12" green screen monitor with separate horizontal sync, vertical sync and video input. These are all at 5V logic levels. I'm not sure how I managed as I didn't have a scope at the time, but I found a PC video card capable of driving a monitor at a suitable resolution (it was the old Hercules spec) and built a little board to invert one or both of the sync signals to drive the display.
The video card is the one at the back, and the board on the right has the 74LS86 that inverts and buffers the sync signals. That actually worked quite well, apart from the 'enegry star' logo on the top right, it sort of works, but was sufficient for the purpose.
Next, the keyboard. The PET has an 8x10 keyboard matrix, and the chosen motherboard had the old 5 pin DIN keyboard connector (AT style). I adapted an old PC keyboard to drive this matrix, with an adapter board to interface between the 20 pin Pet keyboard and the PC Keyboard controller board. It was a partial success, as the matrix was different, so I needed to remap them in software at the PC side. Some weren't mapped by the controller at the keyboard end, so weren't sent through, but most of the keys worked. 
I fitted what would have been about a 5 year old motherboard at the time, a Pentium 120, with 32MB RAM, two network cards and a floppy drive. As it wasn't doing much, it ran fanless, underclocked to 75MHz. Note the wonderful original car bonet style prop for holding the case open!
The task it had was running some software called 'FreeSCO', (Free Cisco). This was a tiny linux distribution which booted from a floppy disk and basically does what you average home router does these days. It took the network from my cable modem on one network card and made this available to a number of PCs plugged into the other network. At the time, you could only have one PC plugged in at a time and needed to reset the router to change to a different PC. If I remember correctly, I had 128kbit broadband at the time, so this was more that capable. The floppy drive was accessible via a slot on the side intended for access to memory upgrades. I added a switch to turn off the screen most of the time and there it sat as a router for many years.
It was only when I moved back to Tynemouth in 2004 that I got ADSL broadband and replaced the PET encased router with a considerably smaller Netgear DG834. The PET then sat patiently waiting a new task. I had tried on a number of occasions to give it a new purpose in life, but the monitor was always the problem. The only thing I had that would drive it was an ISA video card, and any modern PC I put in there wouldn't support it. I looked around for quite a while for a 12" colour monitor that I could fit in the top casing, but couldn't find one.
I did spend quite a while trying to get it running from a BBC Micro motherboard, I got a model B with a tatty marked case and thought it would be a good match, The BBC and the PET use the same 6845 video controller, so I presumed it would drive it fine, however I just couldn't get it to sync up. I now know this is due to the standard video signal that the BBC outputs not being in the tight range the Pet monitor accepts. I also realised how lucky I'd been with the PC video card.
The CMOS battery had gone bad on the motherboard, so I removed the whole thing as I couldn't see it being used again. The Pet was once more empty. So there it sat, waiting for a PET motherboard or a new purpose in life.
Read about it's exciting revival in next week's thrilling instalment of The Pet Project!

Update: This Pet has now been fully restored

2022 Update: This PET still sits on my desk, although it now has a Mini PET 40/80D board installed. 

Saturday, 31 August 2013

Acorn Archimedes A3000 Repair

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

A recent video by Dave Jones on his EEVBlog showed a tear down of an Acorn A3000 (I think they had officially dropped the Archimedes name at this point, but it is still sometimes referred to as an Archimedes 3000 or Archimedes A3000). The one Dave had suffered from what is sadly a common fault on this range of machines (and things like the Commodore Amiga A501), that of battery leaking and damaging the boards. Knowing this often wrote off the boards, I had been looking for a cheap A3000 that looked good externally, but where the main board was shot. My plan was to 'upgrade' the ARM2 processor to the ARM11 of a Raspberry Pi. I was going to convert the keyboard (like my other USB keyboards) and run RISC OS on it, so externally, it would look like an A3000, just inside would be the pi rather than the A3000.
Looks ok, doesn't it? Many of these had school names etched into the top of them. This is also the A3000 which is the last model to have BBC style red function keys. The later A3010 and A3020 had green function keys and no reference to the BBC heritage.
Again, the inside loosk OK. The expansion cover is missing, there is no econet module or serial upgrade. There is however a 3MB upgrade (taking the memory to 4MB in total). The horrors lurk under the keyboard - those of a nervous disposition look away now...
Over the 20-25 years since these machines were manufactured, the batteries have leaked an alkali solution over the area of the board around them. In the case of the A3000, that is the RTC / CMOS RAM and the 4 ROM chips (RISO OS runs from RAM, so no need for an OS disk like the Amiga).
The alkali can eat away at the copper, and indeed both the legs of the 32.768KHz crystal had gone, as had one leg of a capacitor. The tracks all seemed intact, bar one connection from the RTC chip to the crystal which I patched up.
As horrid as it looks, a wash in a vinegar solution and a clean with IPA seems to have brought it up nicely. Originally, the battery was a 1.2V rechargeable, and the user guide recommended having the machine switched on at least 1 hour a week to keep it topped up. I didn't fancy that, so I went for a standard CR2032 3V battery, as used on almost all PC motherboards these days. The PCF8583P RTC chip claims to work from 1.0 to 6.0V, so 3V should do nicely. I added a diode in series to stop it trying to change the battery and powered it on.
I didn't get any photos of the screen at this point, but it wasn't a great start, the settings were wrong (it defaults to all the ROMs being virtually 'unplugged', like the BBC Master), so was just showing 'Supervisor'. However, I couldn't get a stable picture. I didn't want to reset the config until I could see what was going on. The LCD TV wouldn't lock on to the sync, so I tried the composite video on a Commodore 1901 monitor. Same thing. The 1901 has an RGB input, so I made up a lead for that and tried. Same again.Testing it with the scope showed the sync was around 31Khz, not the 15.4KHz I'd expect - it seems the machine was in high res mode. So I went for the factory reset (hold down delete whilst powering it up). I got the screen with a red border which synced up fine, and then up came the loading screen.
It looks to have been upgraded to RISC OS 3.11, which is the last version supported on this hardware. And there we have the RISC desktop.
There is still the issue of a mouse. I didn't get one with this machine, and they are tricky to find (round 9 pin connector, discrete wired buttons and quadrature outputs).
For the moment, pressing F12 allows you to type. All the keys and the floppy disk seem to work fine. Acorn always seem to be on the ball when it comes to thinking about expansion, and I found places on the board where sockets could be fitted for alternate mouse and keyboard connections. They are both controlled by an 8051 based microcontroller which converts key presses and mouse moves to serial data, presumably using the same protocol as the controller in the external keyboards on the earlier A400 series machines. There is even a jumper to interrupt that serial data and inject new traffic. So in theory, if I can work out the protocol, I could add a microcontroller with a mouse and convert it's output to serial and inject it into the system as if it had come form the 8051.
Having fixed it, that put paid to my plan to install the Raspberry Pi, I think I need to look for one a bit more broken - or try less hard to fix the next one.

Monday, 26 August 2013

ZX81 Clone Part 2 - ZX80 Clone

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

Following on from the previous article where I built a ZX81 on breadboard using the original chips and then modern equivalents of all but the irreplaceable ULA, I moved onto the next step, which was to replace the ULA. There are many alternative circuits on the next (I've already admitted I'm reinventing a wheel that's already been reinvented), however, the simplest circuit and a good starting point is actually the ZX80, so I started with that. There are rather a lot of chips required, so first I'm going to need a bigger breadboard. The one I had been using for many years seemed quite good, so I got another one of those to double the area. However, I took the opportunity took make a small improvement. The previous builds have taken power from the posts via wires to the top rails, and then via wires down the sides, and via smaller jumpers, across the top. Having all the rails separate does give increased flexibility, but pretty much everything I had built on there had been using the same 5V rails all wired together.
This had worked fine, but was a little untidy and limited the usable space a bit. So before I started, I took the new one apart to see if I could wire up all the rails up behind the board. Firstly the left and right sides of each rail were wired together.
Next each rail was soldered to a wire at one end.
These were there threaded through holes, glued in place and bolted to the posts.
This gave me a clean board with power to all 6 rails.
So no more delaying tactics, time to build a ZX80 clone. I followed the ZX80 circuit more or less. I made a couple of changes for layout and practicality, I kept with the 16K RAM and 74LS04 for the crystal oscillator that I'd used on the ZX81 and used a single 74LS245 instead of a pair of 74LS05's for the NOP generator (I ran out of space!).
I also jumped the gun on the next modification and added a couple of gates to generate the back porch and make the video signal suitable for a modern TV (the 'white level restoration' section from Grant Searle's ZX80 page).
So here is the ZX80 clone, next to the original I was using to compare signals. The top of the left hand board has the Z80, RAM and EPROM, below that, the things which use the address and data buses: the NOP generator, the input port at 0xFE, the character latch, address generation and video shift register. The top right is the rest of the glue logic, and the bottom right is the additional video tidying up and output buffer.
Next, I added the remainder of the NMI generation circuit as per Grant's page, which should in theory make it fully compatible with a ZX81. That has filled up the right hand side of the breadboard as well and it is looking rather messy now.
Unfortunately, somewhere there is at least one of these wires in the wrong hole - it may take some time to find out which.

To be continued......

UPDATE - I did just about get this working, but the breadboard version had some intermittent connections, so I didn't get much further with that. I have now revisited this and built a PCB version, a ZX80 clone I have called Minstrel.

2022 Update - I did go on to release ZX80 and a ZX81 compatible kits. There are currently a limited stocks of these left, available from TFW8b.com.