Why a digital mouse? While not being a true proportional mouse implantation, it is a path taken by at least one 8bit computer, the Commodore 64 and it's 1351 Mouse back in the 1980s. As an added bonus this also means the mouse interface should work on all 8bit systems that support the Atari protocol. At the end of the day it's smarter to build on an existing solid and supported base such as Charlie Robsons' ZXpand with its digital joystick implementation, than it is to implement a non supported (by existing software) standalone proportional mouse interface; at least for now.
So now it's down to how to get this thing to work, and my prototyping weapon of choice is an Arduino UNO armed with a USB host shield. The USB host shield really is the key to the project, it comes with an extensive Arduino / C++ library ready to plug in, leaving the casual developer or hobbiest free to solve other non-USB related hardware and software puzzles.
Stage 1: Getting a Test up and Running
|Testing a 4006 IC vs a Diode|
Option 1: Use Some Diodes. Diodes can be placed with the cathode to Arduino output pins, and anodes to the joystick port lines. Our Arduino can then set the input to 0v when we wish to trigger a simulated push button action, and there will be no possibility of feeding +5v back to the ZXpand / ZX81.
Option 2: Use a 4066 IC bilateral Switch. This is the slightly more complicated method, though not by much. A bilateral switch can be used to act as Joystick buttons. Power is applied to the IC switch and 2 connected lines are switched on, much in the same way a relay works. There is an easy to follow tutorial to be found on the subject at Brainy Bits. Th e main downside to this method is that in order to trigger the 5 required buttons on the joystick port (up, down, left, right and fire), we would need 2 ICs and all that extra routing on a PCB that that would require.
I wired up the 4066 IC switch for one input and implemented the diode method on an other, needles to say both of the above variations worked, producing the same results of simulting a button press / movement on the ZXpand Joystick port. I decided to go with the diode method for ease of implementation. If however we were in a position were we might be dealing with different voltage levels, such as a Teensy or Pro Micro with 3.3volts and the ZX81 with 5volts, the switch would be the better option here.
Stage 2: A DIY Cut-down Arduino Clone
If one of the aims of this project is to make something a little more permanent, then using a Uno for the end solution is not the ideal. I could just design a simple shield for the UNO, however the USB host shield will still be required, and with the addition of an extra shield on top, would leave the whole project a little unwieldy for what it actually achieves.
It seems apt to mention here before proceeding, there is such a beast as a Adruino UNO and USB host in one easy to use package. Freetronics makes the USBDroid, this could be a perfect solution for proof of concept stages, however to use this in a semi-permanent ZX81 mouse interface seems a bit of a waste.
|Bare-bones Breadboard Arduino (and shiny lights)|
There are a number of Arduino pins that must be connected to the USB shield, INT, SS, SCK, MOSI, MISO and RESET. Also required are a 5v power source (which we will eventually tap from the ZXpands joystick port) and a 3.3v input. To generate the 3.3v a down voltage regulator circuit needs to be added to the end design.
For full details on the USB Host Shield, there is an extensive manual and resources available on the Circuits at Home website. I can't recommend that highly enough.
Stage 3: Build a Prototype Mouse Interface PCB
|Mouse PCB. Note the USB Host Shield Mounts on Top.|
I wanted the end PCB to be easily producible and assemblable at home. As such I designed the board to be primarily one sided, any tracks that had to be placed on the topside are straight. The final (or ongoing) Fritzing files will be available for download. if anybody plans to make the PCB at home, only the bottom layer needs to be etched and copper wire strands can be used for the linking via's. If preferred, the boards can be fully double sided for usage by PCB fabrication houses or the DIY experts.
I've covered the home PCB making process I use in a previous article way back when I first started this blog. If you're interested refer to Creating A PCB For Mounting The Keyboard Controller.
Next Time: Software and Other Bits
Coming up in Part 2, I'll look into the software side of the project, post the schematics, code and parts list for building the ZX81 USB mouse interface. For now feel free to have one or more views of the teaser video on You Tube.