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

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

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, more info on that build in the blog post about the Atari 65XE USB keyboard and joystick with Raspberry pi 3.

Monday, 9 March 2015

Sinclair ZX Spectrum+ new fully mappable keyboard membranes - available now

Previously I announced I was working on a new replacement keyboard membrane for the Sinclair ZX Spectrum+ computer. This solves two problems when looking to use the Spectrum+ as USB keyboard. Firstly, many Spectrum+ membranes fail due to cracks or breaks in the membrane, and secondly, the keyboard mapping is limited by design decisions taken 30 years ago. Some can be repaired, but often need to be replaced.
The original membranes had a 8x5 matrix with 8 way and 5 way tails to plug into the original ZX Spectrum main board. That gave the original 40 keys, plus extra keys by pressing two of the existing keys together (i.e. the arrow keys are caps shift + 5,6,7 and 8, delete is caps shift + 0). This limited the remapping as there was no way to detect if the user had pressed the arrow key, or had actually pressed caps shift and a number.
These new membranes are replacements for the original ones, but have a different keyboard matrix, and a different connector. The new 5x13 matrix allows each key on the keyboard to be individually scanned and remapped. Ironically, in the USB keyboard firmware, I have a mode which is designed for use with emulators, and in that mode, I have to do the double keypress in firmware, and send caps shift+0 when the delete key is pressed etc.
The single 18 way connector is more convenient for connection to small microcontroller boards, Until now, I had been using long boards with the connectors at each end. These worked out quite expensive to produce and took up a lot of space inside.
The new controller sits on the back of the keyboard and leaves space inside the case for things like a USB hub or a Raspberry Pi etc.
I now have the first batch of membranes, so I have now updated my Etsy store listings, and can now offer fully remapped USB keyboards, with and without integrated Raspberry Pi,
The ZX Spectrum+ USB keyboards are are plug in and go keyboards for any device which supports standard USB keyboards. No additional software is required. The standard build now has a mode switch. What was the reset switch on the side of the case is now used to change keyboard mapping modes.
In the first mode, the keyboard works best for general use. Any keys with symbols on will generate those symbols when pressed with symbol shift. Dedicated symbol keys and arrow keys work as expected. The extra buttons on the left give things like home and end, delete, caps lock, tab, alt and the Windows key. With caps shift, the top row of numbers now give functions keys F1 to F10. In this mode, they keyboard makes a tick sound as each key is pressed, to give some feedback, as the original did.
When the mode switch is pressed, the keyboard beeps and changes into a mode designed for use with Spectrum emulators such as fuse. In this mode, the keys all act as the would with a Spectrum+, so you can use it as if it were a Spectrum, It doesn't tick in this mode as the emulator does that. Press the mode switch again and it returns to the normal mode.
Also updated is the version of the ZX Spectrum+ USB keyboard with integrated Raspberry Pi 2. This is the same USB keyboard with new membrane and mode switch, but now with a Raspberry Pi 2 integrated into the case, so it still looks like a Spectrum+, but with a quad core ARM processor and an SD card full of games, and the internet etc.
I've had a few requests on recent builds to have the option to use this as a USB keyboard without the pi. I am now providing this as an option, the keyboard controller can be fitted with an external socket, so a normal USB lead can be plugged in for use without the Pi, or a short loopback cable when using the Pi. Normally, the keyboard controller is wired directly to the Pi, so no loopback is required.
I get asked a lot about buying just the controllers, rather than complete keyboards. I've put this together as a kit with all the parts necessary to convert a Spectrum +, The kit consists of a new membrane and one of my USB keyboard controller boards, loaded with the appropriate firmware.
Finally, if you just want the membrane to interface to your own project, that is also available. It is fitted with an 18 way 0.1" female header, so you need an appropriate 18 way 0.1 pin header on whatever you want to connect it to.
TheZX Spectrum Plus USB keyboard kit is available from my Etsy store, or you can contact me directly.

UPDATE: Also available, ZX Spectrum 48K rubber key USB keyboard conversion kit.

Friday, 6 March 2015

ZX Spectrum USB keyboard review in Micro Mart

Following on from the review of my ZX Spectrum Pi in Micro Mart a few months ago, there is a review of the ZX Spectrum USB Keyboard version in this weeks edition (5th-11th March, Issue 1352).
The score again was 9/10.
I had a query about the button on the back, this is used to change the keyboard mapping mode. The first mode is the everyday usable mode where the buttons make a click sound when pressed and the keys are mapped based on what is printed on the. The other mode each key is mapped directly, so it will work with an emulator. It's better than a PC keyboard when using an emulator, not only because the look and feel, but because the keys have all the marking on them (P=PRINT, J=LOAD etc.)
These are available from my Etsy store, where I've updated the listings for the version with the integrated Raspberry Pi. These are now offered with either the Raspberry Pi B+ (at a reduced price, whilst stocks last!) or with the new Raspberry Pi 2.