Friday, 27 November 2015

Commodore 64 PLA replacements

A common cause of  a black screen*, garbage on the screen, intermittent startup or general instability in Commodore 64's is the 906114-01 PLA chip. A custom gate array chip which handles all the address decoding in the C64. As usual, original stocks dried up many years ago, but there are various options to replace these. It is sometimes a bit of a lottery, as the timing in the C64 was never quite right. You can get a C64 that will only work with some PLAs, or PLAs that will only work in certain C64s.
I've tried various things in the past, a popular option is to use an EPROM to replace the PLA. This just need a bit or rewiring, I've tried that a few times (see previous article on C64 EPROM PLA replacements). It sort of works, but with mixed results, better on some boards than others.
There are a few designs around using CPLDs, but most of the 5V ones have been discontinued, so they would need 3.3V to 5V level shifters  on the outputs. I did try building one with two GAL chips a couple of years ago. I'm going to revisit that at some point, as it should be viable, but I haven't quite got the equations right yet.
Timing seems to be an issue, only certain EPROMs seem to work at the right speed, the Atmel AT27C512R-45PU (450nS) being a good choice. It appears the reason for the timing issues is that one signal (/CASRAM) needs to be delayed a little longer than the rest. When designing the two GAL version above, I passed that signal from the first chip through to the second to get the additional delay. That led me to adding an additional gate delay onto the EPROM board. I built this one with TTL logic gates buffering the /CASRAM signal between the EPROM and the board, shown without the headers for clarity.
The jumpers select 1, 2, 3 or 4 gate propagation delays, adding around 30 to 120nS to that signal. That works well in a lot of cases, 1 or 2 delays (30nS or 60nS) seems to be good for a lot of boards. Another simple option demonstrated in this video shows you can get a similar effect by adding some additional capacitance to the pin.
I've built up some boards with space for a suitable capacitor, 68 or 82pF being around the right value. It should probably be an RC filter, but just the C seems to work.
I've tested this on several boards, and it seems to work quite well. Testing over several hours with the diagnostics cartridge and test harness and with an assortment of games it seems to run well,
I dug out a a couple of boards which has been a bit picky about PLAs in the past, one liked it, one didn't. I've used turned pin headers which fit into most sockets. I've had a few boards with intermittent sockets, so it is worth replacing them with turned pin sockets. Also in a fit of optimism, some boards actually have the PLA factory soldered in.
After all the above photos, this one may look like a mistake, I've put the PLA in the socket at the back of the case, not the middle. Bit it isn't a mistake, at least not a mistake by me. The PLA is indeed in a different place. For some reason Commodore had a board that had been around for several years and several revisions with the only two 28pin socketed chips close by each other in the middle of the board. When they came to revise that board, not much else changed (apart from the VIC II and surroundings). But some clever chap decided to swap around the SID and the PLA between the two most common versions of the C64, the 250407 and the 250425.
What's great is the SID has 12V on pin 28, and the PLA has 5V. Get them the wrong way around and you fry the PLA. If it doubt, power on with both sockets empty and measure the voltage at pin 28, or look for the two capacitors around pins 1-4 of the SID. I've had at least one C64 arrive with those chips the wrong way around, and a baking hot PLA running at 12V. Since the PLA outputs are pulled up to it's supply voltage, that also sends up to 12V to all the chips connected to the PLA. That is most of the chips on the board. Oh dear, not a good move.
I have some of both the logic gate delay and the capacitor delay board. I can supply these with a programmed 27C512, tested on some of my Commdore 64's.Whether they work on your particular C64 is difficult to say. It would be nice to have a guaranteed replacement, but no sign so far.

* N.B. when I say black screen, this is video sync but only a black screen displayed. This is different from no video sync, which usually indicates the VIC II chip is at fault.

Thursday, 19 November 2015

VIC20 - The Penultimate Cartridge - Part 1

This is a quick preview of an upcoming project, in response to a video by GadgetUK164 on the VIC20, where he kindly mentioned my blog. I hope I haven't broken the internet with a circular reference.
This is a VIC20 cartridge I'm working on at the moment. In this version, it can provide the following features:
  • Selectable RAM upgrade, 3K to to 32K
  • Selectable Read only for RAM blocks 3 and 5
  • Selectable ROM image, one of 8 - 8K ROM images only
  • Externally accessible configuration and reset switches
The memory can currently occupy the 3K expansion in block 0 (RAM1/2/3) and blocks 1,2,3 and 5. Block 5 is not counted by BASIC in the total, but can be used to load ROM images. This and block 3 can be made read only of cartridges that require that. I may remove the 3K option in future versions, unless anything specifically requires it. The selectable ROM images mean this can act as a real cartridge so you can have a selection of you favourite carts available at the flick of a switch (well, a couple of switches and a press of the reset button).
This fits into a standard cartridge case, with the DIP switch for configuration and a reset button sticking out. Most Commodore cartridge cases have the slot there, so I thought I'd use it to add the external switches, so no drilling or cutting of the case is required.
Inside, there is a 32K RAM chip and currently, a 512K EPROM, although I'll be putting a large ROM in later versions. The smaller chip is a GAL which handles the address decoding.
There is a lot of space left on the board, deliberately. This space will be used to add the following features:

  • Selectable ROM image, one of 32 up to 16K ROM images
  • Integrated IEEE-488 adapter
  • Integrated IEEE-488 SD card disk drive (a version of PET microSD)

This should result in a self contained cartridge with just the configuration switches, reset button, activity LEDs and microSD card sticking out. No additional wires for power or the IEC port, it will all be contained within the cartridge. The parallel IEEE-488 bus is also a lot faster than the serial IEC bus, so there should be a speed improvement as well. I have previously tested that the PET microSD on a VIC20, and it works well.
More revision of that to come, on the way to 'the Penultimate Cartridge'. I've decided to call it that as every time there is a Final or Ultimate cartridges there seem to be quite a lot of versions that follow it. So I thought I'd be honest with the name on this one.
On a slightly related note, the issues in GadgetUK164's video with Rockwell chips, I can't say I've had any problems. I've tested this on a VIC20 with a Rockwell R6522P, and they are fine, as expected. Also tested with the original CPU (a standard MOS 6502) and a Rockwell R6502P. I've used this to load Dig Dug from an SD2IEC into my Penultimate Cartridge, and that seems to run fine with no need for the diode mod. Maybe he had a duff chip, or a fault elsewhere on that particular VIC20.
As far as I know, it's only the WDC W65C22S chips which changed the IRQ pin (to improve speed). They also produce a W65C22N version, which is compatible with the older NMOS devices (like the R6522P and the MOS 6522), and that also works fine in the VIC20.
It's good to know you can buy modern replacement parts without having to risk 'new old stock' from China.  I've used these in VIC20s, PETs, BBC etc. I also use a lot of W65C21N (again the N suffix is important for NMOS compatibility). This is a replacement for 6520, 6521, 6821 etc. and I've used those in PETs, Dragon32's, Atari 800XL etc.
So I had no problems loading or running Dig Dug with Rockwell chips or WDC chips (or Synertek for that matter).

Update: As requested, I've also checked the Rockwell R6522AP, which is just their version of the MOS 6522A, which is a faster speed graded version of the MOS 6522.

Saturday, 7 November 2015

Commodore PET 2001-8 Mainboard Repair - Part 2

Part 1 of this Commodore PET 2001-8 repair left the main board running, but with most of the parts replaced.
In that state it's all working, so now I can put back any of original parts which are working. I used the ROM/RAM board to identify the faulty ROM and RAM chips. The latest version allows me to test individual ROMs (or pairs or ROMs). From this, four of the seven ROMs were bad.
To test the RAM chips, I used the PET tester ROM image which tests the first 1K of RAM. By shuffling the 6550s into the right most sockets, I was able to find a pair that worked. I can then test all the chips using one good one and one potentially bad one at a time.
This is a typical result, G shows a good bit, B a bad one. If you look carefully, you can see a couple of bits of memory that actually work. Fourteen of the eighteen chips were bad. I did manage to get it to work as a 2K machine.
But that's not much use as there is just under 1K available to use. Fine if you are a ZX81, but not much use here. Notice the old character ROM is still in there - 1023 BYTES FREE. This was before that new character ROM was installed.
There are replacements for the 6550s available, each using a single 2114 chip, but replacing all of those would work out rather expensive. Given that four of the ROMs were also bad, we've gone for the option of leaving the ROM/RAM board in place. This comes with the option of running with BASIC 2 and 8K of RAM as it originally was, or selecting from 8K, 16K or 32K RAM and BASIC 1,2 or 4, so you can have the fully loaded 32K and BASIC 4. I was, however, able to use two of the working 6550 RAM chips from main RAM to replace the video RAM.
The CPU and keyboard VIA were confirmed as faulty, the other VIA was just bad contacts. The PIA was also fine after the edge connectors were cleaned. One datasette was still not working. I noticed the central leg on one of the TIP 29 transistors was actually snapped. I've unclipped the heatsink to show it more clearly.
These transistors are 'flapping about in the breeze' with clip on heatsinks, and so prone to stress the legs. One looked to have been replaced in the past, but I replaced both anyway as it looked like it that could be starting to go as well. These control the motors in the datasettes, and they are now both working. Later PET boards had these riveted to the boards, with no heatsinks. Later still, on things like the Commodore 64, the transistors were back to levitating above the board.
The two bypass capacitors on the main rectifier diodes were also down a leg each, so I replaced those.
The originals were rather large 10nF ceramic capacitors, so I replaced those with 10nF axial ceramic capacitors so it wouldn't happen again. It would work (and obviously had been working) fine without them, they just reduce the RF noise a bit.
This also shows the replacement power socket. This is a new one as the original had wires soldered onto it. To go with that, I made up a new wiring harness, but have also supplied a short lead with just with 5 wires, in case the owner prefers to avoid soldering to the transformer and keeps the terminal block.
With everything back together, I can get back to testing. The original 2001 has a built in diagnostic, activated by a special loopback plug on the user port.
When that is running. a small square moves over each position on the screen, then it shows the character map and lights the red LED on the board if all is well.  You can just see the LED in the centre of this photo, artistically framed by the keyboard loopback plug.
Not that useful really, later PETs replaced this with the machine code monitor - which is why the monitor is sometimes activated when you have problems with the 6522 VIA that monitors the diagnostic pin. At least you can see the problem with the character ROM has been fixed.
The owner had requested a PET microSD to go with their newly repaired PET. I initially had problems with the IEEE-488 on this PET, testing with my IEEE-488 diagnostic board showed up intermittent connections on the edge connector, but after a good clean, it was fine.
Don't worry, I won't be sending it back with all those boards hanging out the back, I'll be using the internal version of the PET microSD, to keep it all self contained and tidy.
That normally gets it's power from the internal power connector which is fitted on most later PETs. The 2001 doesn't have that, so for these. I supply a longer lead with a clip on the end to attach to the unregulated 9V supply, right where it enters the board on the reverse protection diode.
This should minimise the impact of the PET microSD on the power supply. The original board would have drawn between 3 and 4amps on the 9v rail. With the ROM/RAM board, this is now about 1 amp. With the PET microSD, it's around 1.1 amps.
Here is the final repaired board, ready to go back.
The main issues:
  • Faulty ROM and RAM - replaced by ROM/RAM board
  • Faulty CPU - replaced with NOS 6502
  • Faulty keyboard VIA - replaced by WDC 65C21N
  • Damaged TIP29s - replaced by NOS TIP29
  • Partly faulty character ROM - replaced by 2716 EPROM and adapter
  • Faulty video RAM - replaced by 6550s from main RAM
  • Soldered on power cable - replaced by plug and socket and new wiring harness
That's has been run in with various tests and seems very stable. The only real issue being the noise on the screen when updating fast which is inherent in the design of the 2001.
The result of all of this? - my Tetris score is getting better....

Sunday, 1 November 2015

Commodore PET 2001-8 Mainboard Repair - Part 1

Here we have a 2001-8 board in for repair.
This is an early model with 6540 ROMs and 6550 RAM.
The first thing you would notice is the power cable, I don't like the look of that. It appears someone has cut off the original connector and soldered the wires onto the board.
At some point later, they wanted to remove the board, so cut the wires and use a screw terminal block to reconnect it. It then got sold on in that condition, and also not working. Thanks to the new owner for the photo of the board in situ.
I'll replace that with a plug and socket later. For the moment, I'll temporarily power the board from a 9V bench power supply, clipped across the reverse protection diode.
The rest of the board looks in reasonable condition, although, the CPU isn't sitting properly in the socket.
The same with some of the other chips - could I be that lucky?
No. I removed and reseated all the chips and tried it, but that didn't help. It wouldn't have helped either if it had be run with the chips making partial contact for any length of time. My usual tests of power, clock, reset were all fine, but the screen was showing what looked like some really complicated version of Hopper.
So, not all that bad, some things are running, but not enough. Time for one of my ROM/RAM boards.
I set that to replace all the ROM and RAM and powered on.
OK, not as bad as it looks, the mess at the top looks like it is trying to show the right thing. A bit of maths and checking with the PETSCI character set, and it appears that the lower 4 bits are stuck high. So,
should be
The space is 0x20, and / is 0x2F. The numbers are 0x33 etc. and ? is 0x3F. The upper case letters are in the range of 0x40 and 0x50, so are replaced by 0x4F (O) and 0x5F ().
I verified this using the PET tester ROM image on the ROM RAM board, this was meant to be the full character set, but as you can see, it is mainly runs of 16 identical characters with the odd exception.
The video RAM on the 2001 is a pair of 6550 RAM chips. So the one of these which handles the lower nibble is faulty. I had previously made a board to replace the video RAM, using a modern SRAM chip. It is actually 32K, but only 1K is used. That may be considered a waste, but it is cheaper and easier to find than using a pair of 2114 chips to make 1K. This sits across the two video RAM sockets. I've added a cut out for the decoupling capacitor in between to help with orientation of the board.
I had thought I could get away with only the RAM chip on there as most of the enable lines are tied high on the video RAM, but when I tested this on another board, I found it is going to need some logic to combine the read/write line and the clock, so it only writes on the high phase of the clock. I've designed a new board, but for the moment, I'm stuck with a 7400 bodged on the top, dead-bug style. Not pretty, but good enough for testing.
That did indeed work, so I reinstalled the working 6550 and borrowed a 6550 from the main RAM and tried again. The borrowed 6550 didn't work either. After trying four of the 6550 chips, I got lucky and found another 6550 that worked.
That's not quite right though, It seems several characters seem to have a built in underscore. Here on the full character set, you can see if consistently affects certain characters. Ones where the character code ends in a 5, %, 5, e, u, E, U etc. and only on the last row of pixels?
I puzzled over what could be causing that for a while, but it just came down to a duff character ROM. I did consider building a circuit to blank out the bottom row of pixels on certain characters, but that would be been quite a bit of work to fix the one faulty chip. It could also get worse over time, so best replace it.
That is a MOS MPS 6540-010, MOS produced their own ROM and RAM chips for a short while, but they were quickly abandoned, and a year after this board, they were using 2716 compatible ROMs and 2114 SRAM in the 2001.
There aren't any EPROMs that will directly replace the 6540, but you can get very nice replacements on ebay. I was going to make my own, but this looks a very neat job, so I used one of those. I'll take a point off though, as the label was upside down.
At this stage of testing, the 2001 board has replacement system ROM and main RAM. Replacement video RAM, Replacement video ROM. Replacement power supply. Replacement monitor (composite video out board) and a PET microSD IEEE-488 disk drive replacement. There is also a piezo on the user port to make sounds.
With these modern replacements, the power consumption is just under an amp. With the original chips, it's between two and three amps.
That runs stably now with no other problems showing up. This is post is already too long, so I'll split it up. In part two, I'll finish off cleaning the board and put back as many working parts as I can and sort out the power connection.
In the mean time, more testing required, Tetris this time, since I don't get to test that much as it doesn't work on later PETs.