Saturday, 18 April 2015

Petdisk clone

A few weeks ago, I wrote about building a prototype version of Bitfixer's Petdisk, an IEEE-488 disk drive for Commodore Pet computers, using an SD card for storage. Credit again to Bitfixer, the creator of the original Petdisk. This was the first stage of a plan to build my own Pet disk drive emulator, recreate what has already been done to prove the principle.
That version was built on an Arduino UNO, using the same pins to connect to the IEEE-488 port as the original version of Petdisk. This allowed me to load the original firmware in to check everything was working.
I did get some way along the road writing a version in the Arduino environment. I started from scratch, but followed the general lines of the Petdisk firmware. I was hoping this might come out to be a some nice short simple Arduino code using the SD libraries etc. However testing showed the I/O operations needs to be fast, so I had to replace all the nicely wrapped Arduino DigialRead and DigitalWrite calls with direct PORT and DDR access. I ended up removing most of the serial debug I had added as well. But it did work. I started with an empty directory and a simple hard coded 48 byte test program.
Whatever filename was requested, it would return the same 48 bytes. With that working, I started using the Arduino  SD library to load files. That is working, but is unfortunately limited to 8.3 filenames. I didn't get around to writing the directory listing bit, but that should be possible. So, the new firmware can be written, but probably best not in the Arduino environment.
The next step was making a PCB version of the SD card version. This would again use the same connections to the IEEE-488 port as Petdisk, so it could use that firmware. As with the Arduino UNO, I used the ATmega328P. Not the actual chip used on the Petdisk (that was the ATmega168), but similar enough to allow the firmware to be used.
Rather than the diode / resistor level conversion used on Petdisk, I went for a 3.3V LDO regulator, and a 4050 hex buffer working as a level shifter. I also went for a microSD card socket rather than full size SD. I added a power LED and using a spare gate of the buffer, an activity LED.
The board slides into the pins of IEEE-488 24 way 0.156" edge connector and it is soldered down on both sides. I missed out the pass-through connector and the USB power connector and went for a simple two pin header for the power. OK, it's sounding less and less like a clone now, not quite an emulator, but the only thing in common between this and the Petdisk now are the edge connector and the microSD card.
The pins at the back are the power in, the 6 pin Atmel programming header and the three jumpers. Two for the address setting, one can be used for serial out.
I built a few for my machines and a few friends who have also tried but been unable to buy a Petdisk. I have a few boards left if anyone else is in the same position.
With the Petdisk v2.0 beta firmware loaded, that is working nicely. I am in the process of writing some new replacement firmware, I've gone back to plain C in Atmel studio, rather than in the Arduino environment.
In my version, I'd like to add some new features, BASIC 4.0 disk commands like 'DIRECTORY' and DLOAD, shift + RUN/STOP support, non- PRG files and file OPEN commands.
One of the things I've been looking at is an old text adventure game. I've found a D64 image, which contains a .PRG file and many .SEQ data files. With those transferred to an 8250 disk, it loads and runs. With the Petdisk firmware it gets so far but cannot load the instructions or start the game as these use OPEN and INPUT# commands. The aim is to get that working.

Thursday, 9 April 2015

Atari / Commodore 9 way D USB Joystick adapter

A while ago I designed a board which allows you to plug in one or two Atari / Commodore style joysticks and use them on a PC or Pi with modern games or emulators.
I used this on Spectrum +2's, Commodore 64's, Atari etc., poking out the holes in the case originally used for the joystick connectors. 
I've had a few requests to add this to Spectrums, but there isn't space inside, so I took what was designed to be an internal board and made an external version, the same board in an ABS project box. It looks a bit ugly, and it's a pain to file out three odd shaped holes, but it does the job. 
There has been more interest in this, so I thought I'd design a proper external one. I wanted something that would fit into an existing case, without modification. I initially looked at using a 9 way D connector hood. 
The board had to be very small, only 17mmx17mm. I decided this was just going to be too fiddly as it ended up with components mounted on both sides of the board.
I did look at 3D printing a case, and got some way into designing that. I then found an easy solution staring me in the face on my desk. The case used on the USBtinyISP, was actually designed for a 9 way D to RJ45 adapter. The USBtinyISP uses the RJ45 hole for USB, which fits fine, and the other side was designed to fit a 9 way D connector.
These cases are the Pac Tec CNS-0407. I found they were available (without the LED holes) from Mouser, so I got some and designed a board to fit in there.
One end has the full size USB connector, and the other end a 9 way D connector. Plug in any Atari or Commodore style joystick with a 9 way D connector and it will show up in Windows or Linux as a USB joystick.
The board fits snugly into the case, which tapers at the 9 way D end. There is a bit of space on there, so it's spread out a bit to fill the gap between the two connectors.
The case snaps shut and makes a neat enclosure.
This can just sit inline between the PC and the joystick.
Testing here with a nice microswitched zipstick.
These will make a nice addition to any of my vintage computer USB keyboards, available from my Etsy store. You can buy these singly, or as a pair, or until I run out, with a refurbished vintage joystick.

Saturday, 28 March 2015

Arduino based Pet Disk Clone

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 deveoplers 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

Monday, 23 March 2015

Atari 800XL PC

I've build Atari 800XL and Atari 65XE USB keyboards before. I've also built a 65XE with an integrated Raspberry Pi. This one is a step further.
From the front, it still looks like the traditional Atari 800XL. Quite a nice little 64K 6502 based machine with a good mechanical keyboard. I had an Atari 800XL back in the 80s, and used it a lot.
From the back, it's quite different. There are 4 USB 2.0, 2 USB 3.0. Gigabit LAN. Mini HDMI and Mini Display port. Headphone jack, power in, mode switch and power switch.
Inside is also quite different. The main board is an Intel NUC motherboard. With an Intel i5 processor, 16GB RAM and a 250GB SSD. This is actually quite a powerful PC, and they are so efficient these days it barely gets warm.
It's a small form factor, the 'Next Unit of Computing' apparently. With RAM, mSATA and mini PCI slots on the bottom, and the heatsink and fan on the top.
The keyboard has been converted to act as a USB keyboard with one of my USB keyboard controller boards. The mode switch on the back switches between the normal mode where all the keys act according to what is printed on them, When the mode switch is pressed, the board beeps and changes to a mode where the keys are mapped to work with an Atari 800 series emulator.
There were quite a number of very different keyboards fitted to the 800XL. This one has individual mechanical keyswitches, which just needed cleaning up. These have a really nice feel to them when typing. Other 800XLs had a PCB with carbon tracks (like the Commodore 64), and some had membranes (like modern keyboards).
Uniquely (I think), the Atari had a build in self test in ROM, and that included a keyboard test, so running that in the emulator, I was also to check all the keys were mapped correctly.
I also fitted one of my Dual USB joystick boards, slightly modified as the 800XL joystick ports are not right next to each other like most of it's contemporaries. This allows original Atari or Commodore style 9 way D joysticks to appear as USB joysticks, for emulators or modern games.
I managed to find a 4 port USB hub which fitted exactly in the hole for the old serial bus connector. Which seemed sort of appropriate.
The NUC PC also fitted neatly in the parallel expansion port, although I had to cut out a small section for the fan exhaust at the top.
The NUC has a slot of an mSATA SSD, but since there was room in the case, I went for a full size (well, 2.5") SSD. As with the rest of this build, I had to make up custom cables to connect that.
The USB and front panel connectors were 2.0mm pitch, rather than the usual 2.54mm (0.1") pitch normally used, so just a bit more fiddly. The header provided two additional USB 2.0 ports, which I used for the keyboard and joystick controllers. There were two internal USB 3.0 ports, one of which I used for the USB hub. The other could be used for a wifi adapter or wireless mouse etc.
With it all wired up, time to plug in a USB optical drive and install Windows. Running for half a day doing the Windows install, updates and installing and testing the emulator it barely got warm and you can hardly hear the fan.
So there you have it, an Atari 800XL PC with quite a powerful i5 PC inside. Equally at home with either mouse or joystick.
Would you like something like this? contact me, or see my Etsy store. I have the later version of this, the Atari 65XE USB keyboard listed, the Atari 800XL USB keyboard isn't there yet.