Friday, February 10, 2017

My Commodore 64 Saga Part I : Initial Observations, Restoration and Repair Attempts

A couple of years ago, I had traded my Atari 800 for a Commodore 64.  The C64 was a breadbin model and while it had a power supply, it did not come with a disk drive or any software other than a single cartridge.  When I took it home, I noticed that the keyboard was extremely stiff with some of the keys on the left side barely registering to keypresses.

The C64 keyboard's matrix attaches to the motherboard via a 20-pin keyed header.  There are no electronics on the keyboard assembly itself.  Unfortunately, you cannot remove the keyboard from its plate without desoldering the shift lock switch.  Fortunately this is easy enough due to the long wires connecting the switch to the PCB.  The C64 uses capacitive switches, but the key is held together by a single spring.  The spacebar does not often register if hit on its side.  You must press the shift key with the cursor control key to make the cursor go left or up.  Similarly, you must press the shift key to activate F2, F4, F6 or F8.  The ← and ↑ keys literally just put those glyphs on the line, they are not Backspace and Up keys.  The Inst/Del key functions like a Backspace key by default and like modern spacebar when pressed with the shift key.  The Clr/Home key acts like a home key by default and will clear the whole BASIC screen when pressed with the shift key.  It will not erase your program, fortunately.  Pressing Run/Stop while holding down Restore is a way to soft-reset the computer, but this can be disabled by code.

The keyboard can be taken fully apart by desoldering the shift lock switch and unscrewing all the tiny screws holding the plastic plate and PCB together.  Removing the keys with a keypuller for cleaning will be a test of strength.  I found a DIP chip puller to be more effective than a modern key puller. Even though I tried to pull straight up, I managed to break the keystems of two keys.  The keystems are easy to replace once the keyboard is separated.  I had to drill out the plastic bit of the keystem wedged into the key, which was frustrating but better than having to find a replacement key.

BASIC starts in uppercase, but the shift keys do not give you lowercase letters.  You can shift between uppercase and lowercase by pressing the Shift and C= keys.  Underneath most keys are one or two special characters.  You can use Shift and the key to enter the character on the left side of the key and C= and the key to enter the character on the right side of the key.  To change the color of the cursor and the characters you type, you can press C= and 1-8 or Ctrl and 1-8.   This allows you to cycle through all 16 colors the C64 can display.  Pressing Run/Stop is essentially typing LOAD and pressing Enter when shifted and will break into a BASIC operation when not shifted.  This is helpful if a program or load command seems to be going in an infinite loop.

Joysticks on the C64 are its own subject.  Most C64 games, except for RPGs, either require or support joysticks.  Only about two dozen games support paddles or mice.  The standard C64 joystick is an Atari 2600 compatible joystick and only supports a single fire button.  If you want a D-pad, you can use a Sega Master System controller, but only one button will be supported.  Sega Genesis controllers, at least the 3-button models, work in both ports but should only be plugged into Controller Port 2.  In Controller Port 1 they can confuse programs because those lines are shared with the keyboard read port lines.  The fire button for a Sega Genesis controller will be Button B.  Some games, mostly earlier ones, will require the joystick to be plugged into CP1, but later games will more likely require it in CP2.  Games that use both the joystick and the keyboard at the same time also will have the joystick in CP2.  If you push the joystick in CP1 at the BASIC prompt, you will be able to type some keyboard characters.  So I suggest putting a Sega Master System game pad or Atari 2600 joystick in CP1 and a Sega Genesis game pad in CP2 to avoid unnecessary wear on the CPs.  Also, the joystick lines are wired directly to one of the MOS 6526 CIA chips inside the C64 with no protection between the pins in most systems, so static electricity from your finger can easily destroy the chip.  Occupying both ports is a good safety precaution.

Atari 2600 paddles will work with most C64 games, although some games like Omega Race may be too twitchy to play with Atari 2600 paddles.  Atari 2600 paddles use 1MOhm pots and C64 paddles use 470K pots, so if you can find true C64 paddles, you should use the more common Atari paddles.  Some early C64 paddle games from Commodore will not work correctly if a Sega Genesis Controller is plugged into Controller Port 2.

In the United States, there was very little cassette software released commercially for the C64.  Games came on cartridges (until 1985) or disk.  Cartridges are easy to use, simply insert it snugly into the Expansion Port and turn the system on.  They boot almost instantly and you don't need to worry about BASIC.  US cartridge games tend to be small because the C64 can only address a 8-16KB ROM without additional hardware inside the cartridge.  Some European games were released on larger cartridges but required bankswitching hardware and they tend not to work with NTSC machines.

When I first received my C64, I noticed that the color was dark beige.  I thought that it had been yellowed by the sun's UV rays, but apparently that was the color.  The cases of the early bread-bin ranged from gray to dark beige.  So when I tried using Retr0bright, all I saw were bleach streaks.  Commodore used cheap plastic, when I unscrewed the case I saw that a few plastic screw posts had been completely stripped or broken.  I may get one of those new C64C cases made from the original molds, but I will need a pair of keyboard mounting brackets from a C64C or have them 3-D printed.

When I received my C64, the inside was not too dirty except for the top of the RF modulator's shield, which was rusty.  My motherboard did not have any socketed chips except for the 6567 VIC-II.  The video chip area is enclosed in metal and the chip makes contact with the metal and thermal grease, which acts as a heatsink.  I ordered a set of 3 heatsinks, one for the 6510 CPU, one for the PLA and one for the 6581 SID.  These chips run the hottest of all the chips in the system.  If the CPU or the PLA goes, the system is a paperweight.  If the SID goes, there will be no sound and no paddle support, but the rest of the system will work.

The C64 has a rather large external power supply.  This power supply is sealed in plastic and epoxy and is not servicable.  It outputs +5VDC at 1,5A and +9VAC at 1A.  The power supply is linear, with a pair of transformers reducing the 120V or 240V from the wall socket to 9V and 5V.  C64 power supplies are not universal, you cannot use a PAL power supply with a 120V outlet without a step-up converter.  The 9v is AC, meaning Alternating Current.  The 9VAC signal is sent into the C64 where a charge pump boosts it to 12v and is rectified for the VIC and SID.  9VAC can also be found on the User Port and it also provides 6VDC to the Cassette Port.  The 8580 SID uses 9v rectified. The 5v is fully rectified to DC inside the power brick and is the main power supply for the system.

The US power supplies Commodore included are not known for their reliability.  Heat can build up inside the brick and cause the power supply to malfunction or cause voltage spikes that can kill your C64.  I originally checked mine and everything was working OK, but what I didn't know was that the 9v supply was dying.  I used a multimeter to measure the +5v output and it gave 5.12v.  This is slightly above normal.  In order to measure the +5v, put the multimeter into DC voltage reading mode and put the red probe on the 5v pin (5) and the black probe on the GND pin (2).  To measure the 9v, put your multimeter into AC voltage reading mode and put one probe on pin 6 and one probe on pin 7.  When I found one day that I could not get any kind of video output, but the Power LED lit up.  The Power LED uses 5v and that voltage checked out OK.  But I was getting puzzling readings from the 9VAC pins, they were showing up as no more than 1.5V.

I figured I had a partially dead power supply.  I decided to replace the 9VAC of the power supply.  I did not have any spare DIN7 connectors on hand, so I figured the easiest way to test my theory was to cut open the brick's cable near the connector, find the appropriate wires, cut them and solder in the wires from a replacement transformer.  I could have used a NES power brick, which is 9VAC and 1.3A but I did not want to sacrifice one if I did not have to.  Searching through the adapter bricks of the local thrift store found a suitable non-Nintendo replacement.  When I finished soldering the wires to the brick's connector and plugged both into the wall socket, the system miraculously came back to life.

Unfortunately, even after that repair not all was well with the system.  Before the power supply failed, I discovered that the SID would start outputting degenerating sound some time after booting the system.  Usually I could hear breaking up music, distorted notes or low sound channels within two minutes of playing a game.  I figured it was a symptom of the failing 9VAC power supply, but after replacing that supply, it would happen even quicker.  Within two days the sound would almost completely be gone within two minutes.  The SID was running very hot, substantially hotter than the other chips.  I figured that a heatsink would not revive the chip and resolved to replace it.

I had a good working 6581 in my Innovation SSI-2001 replica.  I made sure the SID was working by testing it in a PC for a while, and then I secured the heatsink to it with thermal glue.  Once the heatsink was set, I resolved to remove and replace.  My C64's mainboard had a metal shield underneath the solder side, and this shield was soldered in many places to the ground plane of the motherboard.  In between the contacts of the solder side and the metal shield was a piece of cardboard to prevent contacts from touching the metal and shorting out.  My C64 did not have a metal or foil shield covering the component side of the board.  I understand that Commodore used foil-covered cardboard shields in some models, which trapped in heat.

However, given that the metal shield is designed to keep RF interference from reaching the board, I decided not to cut off all the soldered tabs securing it to the PCB.  Nonetheless, in order to desolder the SID, I had to get by it.  It took a lot of desoldering braid and patience to pry up enough tabs to fold the shield over so I could work on the solder side.  It turned out that removing the SID was not as hard as I anticipated.  I cut the plastic housing from the legs of the chips on one side and wiggled the chip until the legs broke off on the other side.  With a pair of pliers I was able to pull out each individual leg from the cut side but there was nothing on the bent side to pull.  My Radio Shack-quality solder sucker was up to the task of cleaning out the holes and the bit of pin stuck in half of them.

Once I had two rows of 14 clean pins, then I had to improvise a bit.  I did not have a 28-pin socket and the odds I could obtain one from the seemingly only micro-electronics hardware store I know of in my state was a risky proposition.  I did not think it was worth it to drive for an hour each way just to end up disappointed.  Fortunately I had quite a few 14-pin sockets from a previous project.  So I took my dremel and cut a pair of them in half to get what I needed.  Getting them aligned took a bit of patience, but when I was done soldering I had something that would function as a socket.  It was not pretty, but I was able to fit my working SID in it with minimal pin bending and it restored the sound to my system.  I used the program here to test the SID :  The only real downside is that my Innovation clone now has a socket to fill.

My PCB is an Assembly No. 250407 and the Schematic No. is 251138.  This is the first NTSC model to have the 8-pin DIN video.  The 8-pin DIN adds the signals that allow the C64 to give S-Video output.  Commodore called these signals separate chroma and luma and intended this port to connect to a C1902 or C1084 monitor.  The VIC outputs NTSC or PAL encoded video, so this is the best signal available from a C64.  Commodore's cables used a pair of RCA jacks to carry the separate signals, but most TVs have S-Video sockets that use a 4-pin mini-DIN.  This DIN also has a pin for composite (combined) video.  In a pinch, you can use a Sega Master System or Sega Genesis Model 1 A/V cable to send sharp B&W video to a TV.  The audio pin on the Sega Genesis's AV output is the same pin as used for luma on the C64's AV output.

Rather than building my own cable, which I could have done, I decided to order a custom cable off ebay.  Like the heatsinks I ordered, the cable was shipped from the U.K.  It is hard to find anything custom-made for the C64 from a U.S. Seller.  I have also read that Commodore's separate chroma and luma is a bit hot for modern S-Video, so a resistor may need to be added to each line of the video cable for a non-washed picture.  Unfortunately I did not spring for a combined composite & S-Video cable, so for my small TV I am still stuck with RF for the time being.  You only need a 5-pin DIN for a composite AV cable, so the next time I get around to the electronics store, I will pick up a connector.

Commodore used edge connectors and DINs on the C64 because they were cheap.  Edge connectors are really part of the board and DINs are typically cheaper than DB-style ports.  The very earliest C64s used a 5-pin DIN 41524 45/180° for the A/V connector, but the later C64s use a compatible 8-pin horseshoe DIN 262° .  The power jack uses a 7-pin circular DIN 45329 45/270° that is incompatible with the DINs used for the video jacks (but can sort of fit if you push hard enough). A 5-pin DIN video cable will fit in the power jack, but not much is going to happen if you do that!  The IEC/Serial Port socket for the floppy drive uses a 6-pin DIN 45522 60/240° cable that is incompatible with the other DINs.  5-pin DIN connectors are the most common because they were used for PC Keyboard ports and MIDI ports.

In Part 2 I will try to tackle and do justice to the Ultimate-1541 II Flash Cart!


bleuge* said...

Please do more posts like this, i have an old C64 (EU) here, not turned it in 10 years or so, i was thinking precisely to do all this you are doing, also maybe a full recap (nice recap kits in ebay). I got myself a FinalCartridge III+ from lemon64. I got a floppy disk also, it will nice to load again my old AD&D games, Ultimas, etc. Unfortunately a floppy emulator is a bit too much for me lately.

pgodwin said...

My understanding is that Sega controller should NOT be used with the C64 without an adapter. The Sega controlers pull the lines High and cause issues with the keyboard, potentially burning out the CIA. Eg

Anonymous said...

Yep, accidentally pressing two buttons on a genesis controller at the same time may cause a short circuit.