January 31, 2018

DOSPIx86: A Raspberry Pi Zero powered DOS computer inside a keyboard


Welcome to the future. Or the past. I've never been able to figure that out, which is why last fall I became obsessed with putting a Raspberry Pi Zero inside of an old keyboard. Once I first read about how small the RPi0's were going to be, I immediately thought how cool it would be to have one inside a keyboard. Sort of an all-in-one type of computer similar to the home computers of the 80's. Being me, I have most of the home computers of that era already that interest me, but I thought it'd be cool to try emulating DOS, so that became my mission for this project. I decided to call it DOSPIx86.

TRIALS AND TRIBULATIONS:

First I began looking to see what DOS emulators were available for the Raspberry Pi's. I found two available online. One is called Rpix86 and the other is a port of the well known DOSBox. The author for Rpix86 was very helpful in answering a couple of questions I had. I was curious to know if I could boot directly into the DOS prompt upon power up and also if it would work on a Zero. He wasn't sure about performance on the Zero and said he didn't know of a way to boot directly into the DOS prompt. So... going with that, I decided to go ahead and try my luck anyway. You don't know unless you try, right?

I only found 1 or maybe 2 people who had used Pi's inside keyboards who posted online and although super cool(check this out!), that was a bit much for me price wise and also described using a full sized Pi, not a Zero model. I wanted an older gray/beige type keyboard and I also thought I should try to find one with USB to avoid added trouble during the building process.

This lead me to the Keytronic E03601U1 USB Keyboard, which strangely, as of this writing, is still available on Newegg for under $20! I couldn't find any internal photos, but studying the shape and specs, it looked as though there might be room for a Pi Zero inside.

I took a chance and ordered one on eBay for maybe around $15. When I got it, I opened it up(which btw, is super easy and only uses clips to lock the shell together) and was pleasantly surprised to see a nicely organized and spacious case for modding.


I ordered the remaining parts I thought I'd need and when I received the RPi0 began checking out how I'd make it all fit. I knew I'd need a USB Hub, so that took some time figuring that out. Initially, I thought the Hubpixed would be perfect for what I was doing, but that turned into a bunk deal.

***BUYER BEWARE!*** The creator of  Hubpixed "Vikas Shukla" (http://referencedesigner.com) offers to sell these at his site and on Amazon, but after a few weeks of never receiving mine or responding to multiple emails, I had to file a claim on PayPal(for which I was successful!). Total BS and a waste of time for $15. Screw you man! ***BUYER BEWARE!***

I instead went with the Zero4U USB Hub available through Adafruit. Has the same form factor as the RPi0, since it's designed to stack back-to-back, so it fit nicely inside this case. I also tried the CJMCU-204, which I thought could be sorta cool, but it was too big.

While I was laying everything out, trying to decide how to fit everything inside the confines of the Keytronic keyboard, I looked at my options...

For USB the Raspberry Pi Zero has 1 Micro USB port for power and 1 Micro USB OTG port for external peripherals. I wanted to keep all the wiring inside the keyboard other than the power cable and HDMI cable. But I also wanted extra USB ports for a Mouse, Gamepad, etc., so I started looking into running wire from the test pads on the underside of the RPi0 to the USB Hub.

Underside of the Raspberry Pi Zero: Voltage and USB Test Pads

My thoughts on this were... I'll run the keyboard over to the USB Hub and the power the Hub via the test pads on the underside of the RPi0. Well, the theory of this is sound, but this set me back another month in fact.

I started reading about people who were having USB input dropouts and such with these stacking hubs that use the test pads for connection. I guess the wireless signal from the Zero W's(which is the model of Pi I was using) can interfere with the pogo pins that connect the Pi's test pads to the Hub. As a workaround, they include small Ferrite rings with each Zero4U Hub that wrap around the pogo pins, which didn't help me in my case. Since I wasn't using this as a stackable hub and since I was running almost a foot of wire from the Pi to the Hub, there was a big chance of getting dropouts.

Sure enough, after I had already spaced everything out in my head where the Hub, Pi and wiring needed to be and pretty much putting it all together, my keyboard input would drop out from the Hub. I tried disabling the wireless signals in the Zero W, which seemed to work at first, then started giving me problems again. Then I ordered an older Pi0 without Wireless/Bluetooth... Same issues!!!

At this point I was pretty bummed out. I got an awesome keyboard, fit everything inside, did all my wiring and still had issues running from the soldered test pads.

I did some tests and learned that I didn't have dropouts when I ran a direct USB cable from the USB OTG port on the Pi over to the Hub(with or without wireless enabled). So my next challenge became finding a way to keep my design, but keeping the wires behind the shell of the keyboard.

Sheesh. Writing this sounds like a nightmare. I'll be surprised if this keeps anyone's interest by this point! Lol!

So... Since the placement of the USB OTG Port on the Pi was so tight inside the keyboard, I needed to find a super small Micro USB Connector. The smallest profile Male Micro USB Connector I could find was the USB3150 available from Newark.

The super low profile USB3150 Male Micro USB Connector

I had never ordered anything from Newark, but was very happy with their CSR rep Leslie's help. I ordered some other things from them, such as a Pi3 and some soldering accessories and somehow the order got lost/damaged in the mail during transit(I know, what else can go wrong with this project at this point!). But Leslie was super friendly and had my item replacements sent out immediately and I got them the following day!

Once I had the super small USB3150's, I wired it up and... wait for it... it worked! No dropouts!

So... Now that all that long-windedness is out of the way... Here are some photos of how the project looks, was put together and turned out!

THE BUILDING PROCESS:

Figuring out how to fit the Pi inside

Mounting the Zero4U USB Hub with screws

Here I am testing LED's and Resistors for brightness and activity. I used 2K for the Power and 330ohm for Activity

Prepping my LED's and Power Button for easy installation/Removal

Installed and ready to plug into the RPi0

I cut the keyboard USB cable down to about a foot to run inside and under the circuit board to the USB hub

I replaced the Ferrite ring before installation

Making sure I know which wires connect to which solder point before removing

After trimming the USB cable down to size, I ran it under the circuit board and re-soldered

Trimmed down USB cable re-soldered and running over and under to the USB hub

Marking notches for HDMI and USB Power before using my Dremel

I used a Dremel tool to cut these notches out before smoothing them down with a small hand file

Testing to see if my updated plan will work: Running a USB directly from the USB OTG port to Zero4U hub

This wasn't my first choice, but after having input dropout, using the low profile USB3150 connector saved my design!

I added some 2-pin headers for the LED's and Power Switch: This allows me to open my case if I need to

Zero4U USB hub all in place with the notch cut out and Keyboard/Pi connected

While I was at it, I shaved off a bit of plastic here to allow removal of the SD Card

Everything in place: Notice both the Pi USB and Keyboard USB wiring is under the circuit board

Almost there!

Underside of the keyboard: Notice the small silver screws? Those are mounting the Pi and Hub in place

The Power LED stays on while it's powered up and the Activity LED flickers when the SD card is accessed

All put together!

An old Sierra classic!

BUILD NOTES:

DOS emulation on the Pi's isn't perfect and you can feel that with the RPi0's. They aren't as powerful as their larger counterparts. I was only aiming to run a computer ~286 era, so for me, it works out pretty well. Rpix86 is my choice for this setup. I can run it directly from the Raspbian console and it feels on time with the games I tested. DOSBox didn't perform too well for me with the different configurations I attempted.

For Rpix86 I had to add permissions, so that games could be saved/restored and it also helped load some games I couldn't get working after the initial install. Patrick Aalto the author of Rpix86 covers some of this in his helpful FAQ here. Also, in order for the audio to output to HDMI, I needed to use an -a0 command when loading the emulator.

The LED's are really handy for this setup and I am happy I spent the time installing them. I tend to use the Raspbian desktop for transferring the DOS files. The 3 available USB ports work great for flash drive/mouse and the power switch works great too. I looked into running a custom shutdown/startup script for the power button, but it didn't feel like I really needed it. If the unit is shutdown with a Sudo Halt command, I can simply press the power switch to turn it back on.

To use the Activity LED, I had to add a couple lines of code into the config.txt file in Raspbian:

dtparam=act_led_gpio=23
enable_uart=1

PARTS:

Keytronic E03601U1 USB Keyboard 
Raspberry Pi Zero W
Zero4U USB Hub
3 x 2-Pin Header Sockets/Plugs
1 Green, 1 Blue 3MM LED's
1 Pushbutton Switch



FINAL THOUGHTS:

Well, I hope this post can help someone out there that might be interested in doing something similar with an RPi0 and keyboard. I think this is pretty cool and I'm proud of what I was able to put together with a bit of work. It goes to show that with perseverance you can overcome a lot of obstacles.

I chose to focus on running DOS, but this setup could be used for all sorts of things you can dream up. I think it'd be great for running an Atari 8-Bit Computer, Commodore 64, ZX Spectrum, etc.

One idea out there are keyboard stickers that you can stick onto keys to mimic the keys of older systems. You could use this design with some stickers and have a dedicated Commodore 64 emulator running, etc.

I've seen stickers like these available for different systems
HELPFUL LINKS:

Adafruit: My main source for Raspberry Pi parts
Rpix86 Emulator
Rpix86 - Forum
Raspberry Pi Power LED guide


3 comments:

  1. A question.
    Why don't you use a MicroSD extension to bring your SD card out so you can easily change cards. You can get them in micro to micro or better yet Micro to full SD card. I have a Raspberry Pi Media center that uses this

    ReplyDelete
    Replies
    1. Hi, I actually considered this when I was putting everything together, but eventually decided it wasn't necessary for what I was doing. The only time I'd need to access the SD card is if it became corrupt and I needed to re-flash it or if I wanted to change the system completely. For transferring files, I just use a USB flash drive in the USB slots. It's just a personal preference really.

      Delete
  2. This is pretty slick, good work! From the pics it looks like it's a tight fit with just the pi zero, but do you think there is any way to fit a raspberry pi 2 or 3 in the E03601U1 case? Thanks!

    ReplyDelete

Thank you for your comment!