Showing posts with label USB. Show all posts
Showing posts with label USB. Show all posts

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

Saturday, 17 January 2015

USB to IEEE-488 for Commodore Disk Drives

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

Here are the details of the USB to IEEE-488 / GPIB adapter I have been using to test the Commodore PET IEEE-488 disk drives.
Like the USB to IEC adapter I build last year for testing Commodore 1541 disk drives, this one is based on xum1541 firmware. That needs to run on an ATmega32U2, and as before I adapted one of my USB keyboard PCBs for the purpose. The latest PCB for the ZX81 adds a sounder to click on each keypress (which makes typing easier), and a mode switch. That leaves a pile of the old style PCBs for tasks like this.
I've added a piece of padboard to add the additional circuitry, held in place with a couple of cable ties and by the resistors which bridge the boards.
There are 8 grounds, 8 data lines and 8 handshaking lines on the 24 pin connectors, I've wired all those to short lengths of wire.
The two LEDs for power and activity fit in the lid.
The rest of the circuit (a 7406 hex invertor) also goes on the padboard, and it is all wired together.
That just fits in the box.
The circuit is actually the same as the IEC version, so I could have added a 6 pin DIN socket, but there wasn't space. Once complete, the unit plugs into the back of the disk drive.
I had forgotten the 8250 drives have the connector mounted upside down, so the LEDs are pointing downwards. I should be able to turn the connector round later on, although it is the right way around if testing with the board loose though.
However it's connected, the drive can be accessed using the xum1541 versions of the opencbm command line apps.
The CMBXfer GUI also works with this
It also works with the 1541 disk drive converted to a 2031.
I don't think anyone expected these two things to be connected together, so it is not recognized by the detect command.
I'm having a few problems with the 2031 clone responding intermittently. I'm seeing the same problems talking to the drive from real Commodore PET computers, so I don't think it's this adapter at fault. As a test, I went back to the 8250 disk drive, I tried copying a .d82 disk image to a real floppy disk.
Don't be fooled by the progress bar, that's only the first track of many.
It took almost half an hour to copy the whole image, certainly a good test of the adapter and the drive.
Once complete, a directory showed just how little was actually on the disk image, but still it had been a useful test, and I now have an 8250 demo disk to test the drive out.
Checking the disk on a real computer, the files have transferred correctly. Another useful bit of kit to add to the collection.
As ever, credit to those who created the xum1541, opencbm, CBMxfer and other tools I have used.

Saturday, 1 November 2014

USB to 1541 Adapter

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

Most 1980's home computers that had disk drive options used an internal disk controller with external drives attached under the control of the computer. The BBC, Spectrum and Apple were like this. Commodore and Atari disk drives are rather different. They are in fact computers in their own right, connected via a serial bus. So in modern terms, more like a network server that a USB hard drive.
The most popular of the Commodore drives is the 1541. These things are about the size and weight of a concrete breeze block, mainly due to the internal linear power supply.
Inside there is a 6502 processor, two 6522 VIA's, 2K RAM and 16K ROM. This has a custom drive controller chip, rather than the VID video and sound chip, but otherwise not for off the spec of the VIC20 computer. The serial bus connection has a rather useful benefit, without too much work, the serial protocol can be implemented on another computer, giving full access to the drive.
This was done many years ago on the PC, and simple parallel port adapters gave access to the drives. I've build a few versions of the X cables over the years. This is quite a nice little XA1541V2 board I picked up this one on ebay a few years ago. It has transistor drivers to boost the drive capabilities. The only problem with these is the lack of a parallel port on modern computers. I have an old XP laptop I keep for this sort of task, which has built in parallel and serial ports.
I have a few disk drive projects coming up, so I wanted to get this up and running again, ideally on my main development computer, without a parallel port. I looked at various options, including a pci express parallel card which didn't work too well, it seems the older the better for this task. I also looked at USB-parallel options, then thought why not cut out the middle man and drive it direct. Turns out, this too has already been done. xum1541 is a USB to 1541 interface, and ZoomFloppy is an nice implementation of that. I don't know if these are still current, these seem to date to 2011. All the information is there, so I set about building one.
This chip used, an ATmega32U2 is the same foorprint as the chip I used on my smaller USB keyboards, so I adapted one of my ZX81 boards for this purpose. It had all the USB interface and the crystal etc, so that was the USB side sorted. The firmware was loaded using the Atmel Flip interface, as I think was the plan with xum1541.
The IEC side is similar to the output stage of the Commodore computers it was designed to talk to, so in a slight change to the design, I used a 7406 chip. The red LED is activity, I later added a green power LED on the right.
Those two sandwich together to implement something like the xum1541. The design can also include a parallel connection to the 1541 drive to speed it up, I'm not adding that at this stage as I don't mind it running a little slower. There is also the option to talk to IEE488 drives, which is something I'm going to be looking at next, I have an 8250 drive to refurbish to go with the Pet.
That all fits nicely into a small box, firmly held in place with too much hot melt glue as usual
With that complete, the 6 pin IEC cable connects to the drive and the USB side to the PC. Time to fire it up. As usual with IEC devices, best to connect everything up, then power on, drive first then computer. A good way to fry the 7406 chips is to plug the drive into a Commodore 64 when powered on. In this case, connect to the drive, power on the drive, then plug in the USB.
The software I used with the parallel cable was a collection of command line utilities, opencbm. These are still there, and still work. This is cbmctrl, which is used for sending commands to the drive such as reset, status and directory.
But things have progressed, and there is now a nice user interface which uses these programs behind these scenes. This is CBMXfer.
Very nice to use, this also ties in a number of other tools such as d64 disk image creation (disk to image and image to disk). There are also tools to view source files, with the basic tokens correctly displayed.
And integration with vice, the commodore emulator, so you can run the files you have just transferred or are about to transfer to check them out.
There are a number of elements involved in this process, and this is the work of many different people. All credit to them, and I am grateful to them all for making it available, it's going to be very useful.