Saturday, 26 October 2013

Commodore 64 DRAM Repair

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

I have a Commodore 64 in for repair at the moment that is showing some intermittent memory faults. For once, it doesn't seem to be the PLA. The same fault has been seen with a working PLA and the PLA from this unit working fine in a test C64 board.
There is evidence of a historic memory repair. Some time in the past it looks like 4 of the DRAM chips were replaced.
In the process, a couple of tracks must have been lifted as there were a few wire mods on the back of the board.
Looking at the replacement chips, all four of them are different makes and part numbers, and are different again from the four remaining original chips! The data code of the original chips and the rest of the board is 1983, the new ones look to be around 1986. I don't know if they were done one at a time, or if the repairer couldn't find two the same.
The way these are used is that each of the eight 4164 chips is 64K by 1 bit, which together make the 64K by 8 bits required. The originals were NEC D4616C-2, and the replacements were a KM4164A-15, a TMS4164-15NL, a Hitachi HM4864P-2, and an OKI M3764-20RS. All 5 parts are compatible with the standard 4164 part, but their timings are different. I always try to match the part number, manufacturer and if possible the date code, so that they perform the same so there are no timing glitches caused if one chip is marginal faster or slower than another.
In order to test this further, I removed all the chips and replaced them with sockets, repairing the previously damaged tracks.
I then installed a matched set of working 4164 chips (TMS4164-15NJ) and away we go, the Commodore 64 is working again. 38911 bytes free as their should be.
The chips I removed have all separately tested as working, I think it was just a slight difference in timing or a bad connection on one of the repaired tracks. The assortment of chips will be useful to keep though, to add to my collection of assorted DRAM chips used to find matching replacement chips for future repairs.

Saturday, 12 October 2013

Z80 CP/M Single Board Computer

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

Following on from the Z80 Single Board Computer I previously built, I've now turned this into a computer which can run CP/M. This was a popular alternative (and predecessor) to DOS in the early 1980's. It ran on most Z80 or 8080 based computers, many of the multiple board S100 backplane type systems from the late 1970's / early 1980's, such as the Altair 8080 and the RML 380Z. Some home computers of the day had add ons which allowed them to run CP/M, such as the Torch BBC Z80 second processor.
Later ones could run it natively (the Commodore 128, the Amstrad CPC 6128). Much software was written for CP/M, but it lost in the end probably due to the graphics capabilities and standardisation of the IBM PC. Display support in CP/M was a bit patchy as it seems every machine had a different display with different capabilities, so there were often multiple variants of the software for different feature sets. They also had various disk formats and so again, multiple versions may be required. DOS had clearly defined MDA and CGA displays, and disk formats (see here for everything you ever wanted to know about disk drives - but were afraid to ask), so was easier to support.
Huge thanks here to Grant Searle, for his CP/M on breadboard page, upon which this is based. He has put a lot of work into that and provided clear instructions and all software required to get up and running.
The starting point was the original Z80 SBC I built previous. The top half of the breaboard remains basically the same with ROM, RAM and CPU. The EPROM is different, with Grant's CP/M BIOS and ROM BASIC. The ROM is larger (16K as opposed to the 8K on the plain BASIC SBC), so has an additional address line - which I had forgotten and it took me quite a while to realise that. Beneath, the 6850 UART is removed, to be replaced by a Z80 SIO. However, the new SBC also has disk storage in the form of a compact flash card, and the advice is keep the cables short, so that has been placed there, close to the Z80 CPU.
The clock remains (although using different gates) and there is fuller address decoding with a 74138 giving 8 I/O blocks. The serial IO is provided by a Z80 SIO/0 chip, giving two serial ports. One is used to connect to the PC via an FTDI serial cable, the other is connected to the TV and keyboard interface as before.
When initially fired up, the flash card is blank, so ROM BASIC is available, and it runs as the previous Z80 SBC. When connected up to a PC serial terminal, you can setup the CP/M system on the CF card, and then transfer software over. Grant has provided quite a neat mechanism for doing this, with a PC application which generates a text file with the software converted into hex codes, and software which sites on the CP/M side which reassembles the hex into applications, ready to run. One of the first things I tried was Richard Russel's BBC BASIC for CP/M.
The next step is to build this up onto a board, just waiting for a few parts.

Monday, 7 October 2013

Keyboard Error, Press F1 - IBM 5160 Part 3

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

When I last wrote about the IBM5160 I was in the process of stripping down and rebuilding, it turned into a brief history of disk drives, mainly because I didn't have an XT compatible keyboard. The system was sitting there showing keyboard error (301) and requesting F1 be pressed to continue.
Although it had the same 5 pin DIN connector, the XT had a different keyboard protocol to the AT standard, which is still in use today, only the connector has changed from the 5 pin din on the AT to the 6 pin mini din connector on the PS/2.
Both protocols (the nice, elegant XT one and the later overcomplicated AT one) required only two pins, a clock and a data pin. I had started to design a simple converter using an 8 pin AT Tiny microcontroller. When looking for further information on the protocols, I came across this thread on the Vintage Computer Forum. It appears I'm not the only one in this predicament, and someone had already designed such a device, using an 8 pin PIC. Rather than reinvent this particular wheel, I programmed the firmware supplied by Chuck(G) in this post into a PIC12F629 and built the circuit on breadboard. It worked first time. Further information and schematics here.
I had removed all the drives and most of the cards and had only just started putting bits back together, so with no boot device available, the 5160 loads Microsoft BASIC from ROM.
A quick bit of testing and the keyboard is working fine, so I built it up into a little box.
A 5 pin cable plugs into the XT, and there are two options for a keyboard to plug in.
Either an older AT style keyboard.
Or a recent PS/2 keyboard.
Adding the drives back and trying a DOS disk, booted up into DOS and away it goes.
I also had a try with the hard drives. Initially they were reporting problems, but I found an old copy of Norton Disk Doctor and set it going.
It didn't seem to like the CGA card, so I tried another and got the same result. Must not be compatible, so I dug out an 8 bit compatible VGA card and tried again.
That sorted out the problems and started booted into DOS 6.22. However, it then started some type of 'Power Menu' which wouldn't do anything without a password. I tried the usual candidates, but didn't manage to guess it. Easy enough to bypass though. I need to copy off things like software for the 'AST MegaPlus II' card, and then go for a clean install of DOS and all my usual software. Drives of that vintage are rather noisy and delicate, so I'll will probably mothball these as they are and look at using something like a compact flash card.
The power supply is likewise rather noisy, I've started stripping that down, with a plan to potentially replace the fan with a quieter one. I've noticed a couple of X type mains filter capacitors which have a habit of exploding, BBC model B's suffer from that a lot. I'll replace those, give it a good clean and check out the rest of the capacitors before putting it back together.
There is also a bit of a bodge where one of the disk drive power cables has been cut and and extra power cabled spliced in and the joints wrapped in cloth tape. I'll probably try to undo that mod and return it to its former condition.
Read more in the next article....

2022 Update: The next article will arrive at some point. I really must get around to getting all the 5160 bits out of storage and build up a working machine.

Friday, 4 October 2013

VIC20 Repair Revisited

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

A while ago I wrote an article about how, in the dim and distant past before I had a decent EPROM programmer, I had repaired a problem with a faulty VIC20. As well as a few corroded chips and bad connections, the Kernal ROM had failed. This was a 24 pin 8K mask ROM, and at the time, the only solution I had was to use a 27C64, a 28 pin 8K EPROM in a socket adapter. The result, although successful, was less than elegant.
Since then, I've managed to get hold of some MCM68766C25 EPROMs, which are pin compatible with the original mask ROM, and a far more elegant solution. The only problem is, since they are rather old and obscure EPROMs, none of the programmers I have support them. So, it's time for another adapter, but this time, one that only needs to be used on the programmer. Rather than make yet another variation of 24-28, 28-24, etc., I decided to make a 'universal' one. Most of the left hand, and half of the right hand pins are consistent across nearly all the devices, so I created an adapter with sockets to allow all the other pins to be wired with jumpers.
This is only going to be used for reading and writing on the programmer, so I added a ZIF socket to the top. It can then be wired appropriately for the task in hand, sit in the programmer, and have the necessary chips inserted in the top.
This turned out to be useful when I was checking through a load of potentially suspicious ROMs from a couple of 8032-SK's which were non-functional. Out of the 12, 2 were dead and 2 were slightly wrong (but slightly wrong in an identical way, I need to investigate that further). It also allowed me to program some 2532 EPROMs (which are pin compatible with the Pet 4K mask ROMs) as temporary replacements
Anyway, back to the VIC20. The standard 8K EPROM, the 27C64, has 3 enable lines and a separate VPP pin, but the 68766 has a single pin for enable and VPP. One solution would be to build a simple transistor circuit to use the enable pin to switch VPP to the G/VPP pin on the 68766. However, I went for the easier way of setting the programmer to 27C512 mode. That standard chip also has a single G/VPP pin, so it just needs to be set to only program the first 8K. Mine has the option to skip 0xFF bytes, so can actually work over the full range. The spec of the chips says 25V in 2mS pulses. The closest I could get was 21V in 1mS pulses, it took a couple of goes, but it worked in the end.
Once programmed, the chip is then a direct replacement for the original mask ROM, so can be used without an adapter. It's not the most elegant way of programming it, but seems to be the cleanest end solution.
The VIC20 is then up and running again.

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.

Saturday, 28 September 2013

Arduino TV Out Terminal Library

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

This is an update to the library I have written for the Arduino which makes use of Grant Searle's Video Processor. Grant has recently updated his video processor code to support 40 character mode as well as the original 80 character mode, added a second font and a double line mode. There is now also a 160x100 pixel graphics mode.
The principal is this, you have an Arduino with your code in and this library, and connected to that you have a second ATMega328P (the same chip as is used in the Arduino) and a 74HCT166 shift register. Together they do all the work involved in generating a composite video signal suitable to connect to a TV or video monitor. You can build up these additional components on breadboard, or I have build a shield which fits onto the Arduino with all the required components on. The DIP switches select the default font and communication settings.
Interfacing between the Arduino and the video processor can be done in three ways. The original way was an 8 wire parallel bus with 2 handshaking control lines. A second mode was later added which allowed this to be reduced to 4 wires and 2 handshaking lines. The third method uses 2 wires in TWI or I2C mode, which was originally a fork of the code as part of an earlier version of this library, but has now been rolled into the main code. (Note: the diagram below shows shift/load connected to the ATmega in the way I had originally connected it. Since this post, Grant has changed the code to use PC3 (A3) for shift load).
The pin assignment on the video processor has been updated so that the two TWI pins will always be connected (they are used for handshaking in 4-bit and 8-bit modes). The library and shield support all three, just make sure the library and the wiring match.  The 8 bit is up to twice as fast as TWI mode (30,000 characters / second vs 18,000), but for most applications, either should be sufficiently fast. The 8 and 4 bit versions can use any pins that are spare, the TWI version needs to use A4 and A5. So unless you need to have A4 and A5 for some other use, or you really need speed, it's probably easiest to use TWI mode. All the demos are coded for TWI, but can easily be adapted to 4-bit or 8-bit mode by changing only the terminal constructor line. See the comments in the code for further information. I also connect the reset lines together, so the video processor gets reset when the Arduino is reprogrammed, so you get a clean start each time you change your code. Otherwise, tie the reset line high.
The source and hex file for the video processor are unmodified from Grant's original and are included in the library with permission. The fuses need to be set to E6 D9 FF. You can program an ATMega328P using an EPROM programmer (such as the mini pro shown above) or Arduino as ISP (see the earlier article for further information on this and the avrdude command line).
The library can be downloaded here. If you are using Arduino 1.0.5, you can import this be going to the 'Sketch' menu, selecting 'Import Library' and then 'Add Library'. Browse to the downloaded zip file and add it. With older versions, just unzip the 'Terminal' folder and add it to the 'libraries' folder in your Arduino directory.
As previously, I've had fun writing a few samples. The mock up BBC start screen now looks better in 40 character mode which more closely matches mode 7 (the previous demo was more like mode 0). The homage to Look Around You also works better in 40 character mode.
I've updated the Hello World samples to show the character set in a more useful way, and added spinning characters in the corners.
The new version of the video processor supports multiple different styles, on a per line basis, there is now a demo showing off the various options.
The new version also brings graphics mode. The ability to address the display as 160x100 pixels with set pixel and clear pixel commands. I've extended this functionality in the library and added functions to draw lines, boxes and circles.
When testing the line drawing, it reminded me of the old Missile Command games, so I mocked up a demo of that. This is just a simulation, it just fires at the bases and loops around after firing 5 shots. I don't know if there is enough to be able to make that a playable game, maybe.