Saturday, 28 March 2015

Arduino based Pet Disk Clone

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

Since it's Arduino Day, here is a project a built up a while ago. There is an Arduino UNO under that lot.
I've restored a number of Commodore PET computers recently (amongst them a 8032 and a 4032), and I've been working on various IEEE-488 devices to plug into them.
It seems every time I mention the PET, someone suggests I should get a Pet Disk. This is a small board which plugs into the IEEE-4888 port and emulates a floppy disk drive using the files on the SD card. The full details are on the Pet Disk website. I have tried a few times to get one of these, but have not been able to. The project appears to be in the public domain, so all credit to BitFixer, the original author.
I've been thinking about building my own Pet disk drive replacement for a while. In order to get going, I thought I'd start by seeing if I could recreate the Pet Disk as a sort of proof of principle. The hardware details are on the Pet Disk website, it is basically an ATmega8 (and later an ATmega168), and an SD card.
So here is my version, it's an Arduino UNO and an Adafruit micro SD card breakout board. The UNO uses the ATmega328P, similar enough for this purpose, just with more available memory and program space. The original schematic used diode clamping to convert from the 5V of the microcontroller to the 3.3V required for the SD card. Here, the circuitry to do the level shifting with a 4050 rather than diodes is on the Adafruit microSD breakout board.
Power comes from the cassette port on the PET - the USB socket on the Pet Disk is for power only. The rest is connections to the IEEE-488 port of the PET. I made up a reusable cable as I'm planning to develop this further.
I followed the same pinouts as the Pet Disk, so I could initially re-use the existing firmware. Here is a table of the various connections.
IEEE-488 Pin
IEEE-488 Signal
ATmega328P pin
Arduino pin
1
DIO1
PB0
8
2
DIO2
PB1
9
3
DIO3
PD2
2
4
DIO4
PD3
3
5
EOI
PC4
A4
6
DAV
PC2
A2
7
NRFD
PC3
A3
8
NDAC
PC1
A1
9
IFC
-
-
10
SRQ
-
-
11
ATN
PC0
A0
12
GND
GND
GND
13
DIO5
PD4
4
14
DIO6
PD5
5
15
DIO7
PD6
6
16
DIO8
PD7
7
17
REN
-
-
18
GND
GND
GND
19
GND
GND
GND
20
GND
GND
GND
21
GND
GND
GND
22
GND
GND
GND
23
GND
GND
GND
24
GND
GND
GND
The SD card connections are shown here. On the original circuit, /CS, DI and SCLK pins have diode clamps to limit the voltage to 3.3V. Power is fed via a diode / resistor dropper. Here I'm using a breakout board which includes the level shifter, so connections are direct.
SD Card pin
SD Card Signal
ATmega328P pin
Arduino pin
Micro SD board pin
1
/CS
PB2
10
7
2
DI
PB3
11
6
3
VSS
GND
GND
3
4
VDD
-
-
1
5
SCLK
PB5
13
4
6
VSS
GND
GND
3
7
DO
PB4
12
5
With that all plugged together, the firmware is loaded via ICSP with a USBtiny ISP. It could probably be rewritten in the Arduino environment, but for the moment I'm using the original firmware.
The Petdisk firmware uses address 9. It should be possible to change this via jumper, but I think there is some problem with that.
Directory listings seems to work nicely. as does loading and listing.
With that working, I can start working on my version. I did some brief testing with a Netduino. This is an Arduino alternative, running the .net micro framework on an Arm processor, I had several left over from a training course I gave last year to a group of software developers who wanted to get into hardware, but preferred to stay with the familiarity of C#. This already had a microSD card built in, and filing system support as part of the .net micro framework. I swapped over the wires and wrote a simple version in C#.
The Netduino is useful for things like IoT devices, you can write a webserver in half a page of code, and for simple I/O such as reading sensors and driving LCD displays. However, it wasn't going to work here as it's I/O was just not fast enough to meet the timing specifications of the bus. So, yes, the 168 MHz Arm Cortex-M4 with code in C# and the .net micro framework couldn't go fast enough for the 1MHz 6502.
So back to the Arduino for the moment. I've written alternative firmware which does basically the same thing as the Petdisk firmware, again as a proof of principal. My aim is something slightly different, rather than the SD card, I have a pair of two megabyte flash chips. The idea being to write what is basically an 8250 emulator. This is a dual floppy drive for the Pet, so the flash devices will be the two floppy drives. That's currently a work in progress. I'm also thinking of getting it to work via USB, so the disk images inside can be accessed via openCBM apps, like the xum1541 style devices I previously built for IEC and IEEE-4888.
In the mean time, I've designed a PCB for the Pet Disk clone, using the smaller surface mount version of the ATmega328P, and going for a 3.3V regulator and 4050 level converter and a microSD slot on the board. Just waiting for those board to come back now. I've kept the original pin out again, so the traces aren't as neat as I'd like.
I normally go for the neatest layout on the board if it's not important which I/O pin is used, so my USB keyboard boards are usually a neat fan out of all the pins, and minimal use of vias.

Update: The PCB version is now complete: http://blog.tynemouthsoftware.co.uk/2015/04/petdisk-clone.html

Update 2: I've now designed a cut down version of petSD running NODISKEMU firmware, in a similar form factor, this is pet microSD.

2022 Update: I have since designed a much nicer SD drive for a PET. The SD2PET is available from The Future Was 8 bit: SD2PET

Sunday, 22 February 2015

Atari 2600 Jr Composite Video Modification

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

Following the Atari 2600 Composite Video Modification article last week, I've been asked if the same thing can be done on the Atari 2600 Junior?
The answer is yes, although very different in size and appearance to the original Atari 2600, the Atari 2600 Jr uses mainly the same parts, laid out a little differently.
It's all on one board, the sockets and switches that were on the larger board on the 2600 are visible here, the interesting stuff is all under the metal shield. The two momentary switches (game select and reset are now on a membrane connection on the top of the case. The power and 'TV type' select are on the left (still don't know why people needed frequent access to change the type of TV they owned in 1989).
Here are the same three main chips as the 2600, and the 4050 buffer used to improve the mixing of the video signal (which was missing in some of the 4 switch 2600 versions). Rather than the fixed RF cable used in the 2600, there is now a phono socket on the outside of the case for the RF signal, the same arrangement used on the ZX81 and Spectrum etc.
This one is faulty, doesn't turn on. This is a simple case of a dry joint on the power connector. There is no ground connection from the power supply to the board. With the solder reflowed on that, it will be fine.
The composite video modification is basically the same, stop the audio and video being combined, route the audio to a connector, and route the video via a buffer amplifier to another connector.
The audio / video circuitry is all on the bottom right of the board, Here, I've gone for a different approach to the previous modification, and removed the circuitry not required around the audio / video combination circuit.
The main parts to remove are the modulator and connector, Q4 and R56, but I've also removed C53, C53, L8 and L10. This leave that area clear, and I've reused the holes to mount the new video buffer components.
I've fitted two phono sockets in the holes used by the original RF connector, and installed a simple emitter follower video buffer.
The video signal is already biased via R42, so the base of the transistor (2N3904) can be connected to that point (the top of R56). The collector is connected to 5V via the lower hole of Q4. The emitter uses the right hand hole of Q4, which is connected to the pads of C54 and L10. These have been removed, so this trace is no longer in circuit and can be reused. L10 is replaced with a 75 ohm load resistor to ground, and the video signal is taken from that point to the yellow socket.
The audio is collected from the  bottom of R34 or the top of C49 and connected direct to the white socket. Ground on the two sockets is taken to the thick ground trace.
I've applied a little hot melt glue to hold down the sockets, and the covers fit back to cover up the rest of the mod.
The original RF output hole has been enlarged to allow both photo sockets to stick out, and the mod is complete. As before, the colour can be trimmed via a variable resistor (R9, middle left of the board).
I've only used a single audio jack (as the PAL TIA is only mono), but you could add a second audio jack wired in parallel if there were space. More testing required, Maze Craze this time, simple but addictive.
UPDATE:
The black Atari 2600 Jr contains the same board, so the same modification will work these.
This is the simplest single socket version, just giving composite video, audio was added later with a 3.5mm jack socket.


Saturday, 14 February 2015

Atari 2600 Composite Video Modification

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

Following on from the previous Atari 2600 black screen repair, I had been asked to modify it to composite video output. The original design has a UHF modulator which outputs the video and audio on analogue TV channel 36. Modern TV's no longer have analogue tuners, and those that do, don't cope with the signals from old computers and games consoles too well.
I've seen many versions of the composite video modification for a 2600, ranging from very simple (capacitor coupling the modulator input) to very complex (recombining the chroma and luma from the TIA in various ways).
Here I went for the fairly simple version, a single transistor emitter follower circuit to boost the video signal. Some circuits miss off the 75 ohm resistor, but it should be there to impedance match the TV input. The transistor is a basic NPN, I used a 2N3904.
The signal which goes to the modulator is actually video and audio combined. The TIA generates these separately, so it just a case of stopping the signals being combined. The easiest way to do this is to remove the parts which combine the signals. There are various suggestions as to how this is done, the chief part is Q202. The signal seems to be improved by the removal of L201 as well.
The audio is then tapped off separately, There is a spare pad to the side of C120 which has the audio signal on. Ground is taken from a convenient point nearby, I chose side of C238. This wire is then fed out of the metal box.
That is then connected to both the left and right audio outputs. That leaves only video on the signal going to the modulator. That can now be removed, and the 5 pins next to it carry 0V, 5V and video.
I built the circuit on a small piece of padboard and fixed that where the modulator used to be. I had left space on there in case I needed to go for a more complex circuit, but the basic one worked well.
You could drill holes in the case and mount phono sockets or a scart socket, but I went for running a cable out of back, and started with an old composite video lead from a pound store, I think this was for a PS2.
Notice the large moulding at the connector end. This would normally be a ferrite to reduce interference. In this case, it appears they have just gone for the plastic shell to give the appearance of a more expensive cable. Nice touch.
That wasn't a problem here, as I just needed to cable, and it was a bonus that the ends were nicely tidied up so I just needed to remove the original connector and crimp on a 6 way header for my board.
The cable then runs out the case where the original RF lead went, quite a neat (and reversible) mod.
This now gives a very good picture on a modern LED TV. I had to adjust the colour timing slightly, I used Galaxian running on an emulator as a reference to get the rainbow colours right.
Composite will never give as crisp a picture as the high resolution digital connections like HDMI, but it's very usable.
Ah well, more testing on Galaxian to do, Atari Space Invaders seems very slow in comparison, Galaxian plays very well.
One Atari 2600, repaired and upgraded ready to go.

Update:
I have designed a PCB for this, and a version is now available from The Future Was 8 bit.

Atari 2600 Black Screen Repair

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

Here we have the classic Atari 2600 Video Computer System. This is a six switch model from 1980 and is suffering from the good old black screen problem. That covers a variety of problems, from nothing at all being output to a correct video frame being generated, just with nothing on it.
This is the second case, tuning an analogue TV into the signal from the unit finds a black screen on channel 36. There isn't much other than noise on an analogue TV these days, but it's easy to test by turning the 2600 off and the screen returns to static, power back on and it goes fuzzy black again. OK, so there is power getting in, at least enough for the modulator to be outputting a signal. Time to open it up.
Inside you can see they multipart construction, there is a large single sided board with the switches, voltage regulator and TV modulator, and a large metal box containing the rest. Testing this, there is 5V being generated by the 7805 regulator.
I've been asked if it is worth replacing this with a swich mode regulator, as I have done on ZX81 and ZX Spectrums (7805 regulator replacement on a ZX Spectrum Plus). This 2600 draws about 350mA in operation. So at 9v input, that is (9-5)*0.35 = 1.4 watts. The heatsinks probably equates to something like 20°C/watt, so they will end up 28°C above ambient, not too much of an issue. Given this one is working, no need to do it here. The ZX81 with a RAM pack is two or three times that and becomes noticeably hot, and so is worth doing on a ZX81.
The capacitors can also be points of failure, but these tested fine, so no need to replace those either.
Checking the other side of this board, the modulator. Looks similar to the UM1233 modulator used on many 1980's home computers. There are only three connections, ground via the case, 5V via a filtered input, and the video input. With a known working cartridge installed, checking the video on the scope shows only a flat line.
Time to go inside the big metal box. Here is the heart of the 2600, three chips. At the top is the MOS Technology 6532, otherwise known as the RIOT (RAM Input / Output Timer). 128 bytes of RAM (yes, bytes), two 8 bit I/O ports and a timer. Atari uses their own part numbers, so this is marked C010750. The big chip the bottom is the TIA (Television Interface Adapter), the chip responsible for generating the video and audio, This is the PAL version, marked this C011903. The smaller chip in the centre is actually the CPU, a MOS Technology 6507, a cut down version of the 6502. Atari code C010745.
Reseating the chips often helps, but in this case, it made no difference. Failure of any one of these could lead to a blank screen, but the usual culprit is the TIA.  As is the case with Sinclair ULAs and Commodore PLAs, this is a difficult part to source. The choice for replacements being basically another 2600. The donor in this case is a spare 4 switch 2600 board with a faulty RIOT chip (another part that can only be gleaned from another 2600).
By this stage (1983), the design had been reduced to a single board. Two of the switches (difficulty A and B) had been moved to the back. I would have through the TV type would have been the least used, you don't often switch the type of TV you own.
With the TIA replaced, the screen now shows Space Invaders, in glorious black and white analogue TV.
The signal wasn't too bad on an analogue colour TV either.
The owner had requested a composite video conversion. I'll cover that in a separate article (Atari 2600 Composite Video Output modification).
The final steps were the usual clean up the case and clean the switch and connector contacts and then it just needs extensive testing. It's a hard job playing video games, but someone has to do it.