神刀安全网

The void left by the parallel port

Resurrecting a dead interface

The void left by the parallel port
USB Adapter for the Super Wild Card

The parallel port used to be where you easily connected electronics to the PC, that’s not the case anymore.

I found a strange old device from back in the 90’s, a Super Wild Card backup unit. It’s an unlicensed peripheral for the Super Nintendo Entertainment System that makes it possible to backup cartridges to floppies and also play games from backups. I wanted to see if it still worked so I hooked it up. It started and displayed the menu on the screen but the floppy drive didn’t seem to work. On the back of the device there is a parallel port that lets you connect it to a PC and transfer games that way. But I don’t have a PC with a parallel port anymore. My first thought was to just buy one of those cheap USB to parallel port converters but after some research I realized that they only work with printers.

There are some special converters that could work but they would most likely be painfully slow, like ten to a hundred times slower. A transfer with a real parallel port can take more than a minute and ten times that would not be a pleasant experience, it would be even worse than loading from cassette with the Commodore 64.

The problem is not the bandwidth of USB, it’s the latency. The handshaking and polling of the parallel port requires a lot of packets to be sent back and forth over USB to write just one byte, and that takes time. A solution to the latency problem is to handle the parallel protocol on the other end of USB, in the adapter firmware.

So I thought, instead of trying to add a parallel port to a modern computer, why not add USB to the Super Wild Card instead? This approach is a good fit for the use case as transfer speed is important and the parallel protocol shouldn’t be too hard to implement in the firmware. A similar approach has been used for CNC equipment out of pure necessity as the timing of the stepping motors is too sensitive to be controlled over an emulated parallel port.

The void left by the parallel port
Prototype

I have some prior experience with the Atmega32u4 controller and the wonderful LUFA library so I naturally thought of using that. I soldered a D-Sub 25 connector to a Atmega32u4 breakout board I had laying around and connected the USB to my computer. At first I thought it would be cool to have it present itself to the host computer as a usb drive but that would require implementing something like a virtual FAT file system and that seemed like too much of a challenge. I started to experiment with the USB CDC virtual serial port demo in LUFA instead and realized the most modern operating systems have built in drivers for it. If I were able to use that, I wouldn’t have to write any low lever drivers myself which would be very practical. I experimented with different ways to send, like byte by byte or in small chunks and to set different serial speeds. After a while I realized that the speed settings did not have any effect and that big chunks were very efficient as the underlying protocol handled flow control in a really nice way. So I designed a simple serial protocol and made a firmware that has a implementation of the parallel protocol of the Super Wild Card. I could not find any complete specification on the Internet of how the protocol works but Ucon64 is an open source project that has a well tested and fully featured implementation of it. So I looked at that source code and was able to figure out how to communicate with the device.

On the computer side I made a Python command line program to communicate with the adapter over the virtual serial port. The solution is OS independent, if python is available for the OS and there are USB CDC drivers it just works! I have tested it on OS X, Windows and Linux. I also ran it on a first generation Raspberry Pi which worked but was kind of slow. A nice feature is that the program is able to auto detect what serial port to use by looking for a specific USB vendor and product id. This makes it really user friendly.

The void left by the parallel port
SWC USB Adapter without housing

My prototype worked well and there where not really any hardware features missing but I still wanted a better form factor so I made a PCB that fits into a standard D-Sub 25 connector housing with a micro USB port where the cable usually comes out. My idea is to leave the connector in the Super Wild Card and think of it as an USB upgrade for it instead of a converter for the computer. The hardware design could potentially be used for other devices with a parallel port interface but it would require a custom firmware specific for that device.

All project files for hardware and software is available from my GitHub repository: https://github.com/tltx/swc_usb

Somewhere along the way I replaced the bigger capacitors in the Super Wild Card and that actually fixed the problem with the floppy drive. I’m glad I pursued the challenge to use the parallel port as it was a fun learning experience.

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » The void left by the parallel port

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址