Amiga Laser Mouse (v1.2 PCB)

PCBWay have quite a simple and useful project to covert your old tank mouse into a laser mouse. I'm not a great fan of the mouse ball and no nostalgia for them, so I picked up 5 boards to have a go at a conversion.

PCBs can be found at https://www.pcbway.com/project/shareproject/Amiga_Laser_Mouse.html. There's a simple BOM list, but there could be a bit more information to explain the build. There's also no firmware supplied, which is quite odd when the board has been released for people to also build their own project. The good news is that other people have created versions of this to flash so not all bad news. The source can be obtained, along with pre-built hex files at https://github.com/gps79/Amiga-Laser-Mouse-ADNS-9800. I had issues trying to use this firmware with the V1.2 boards from PCBWay and I suspect that some pins may have been rearranged. I've forked and rebuilt the code to work with the V1.2 and you can get a built version from my github at https://github.com/AidanHolmes/Laser-Mouse-ADNS-9800.

Assembley


This is the population of BOM that I made to get a working mouse:

R9, R8, R7: 3.3KOhm 0805 (Mouser: 71-CRCW08053K30JNEAC)
C1: 470pF capacitor (I used a through hole, but Mouser or Digikey have many options in 0805)
C4, C2, C7: 0.1uF capacitor (Mouser: 581-KAF21BR71H104JM)
C5, C3, C6, C8: 1uF capacitor (Mouser: 791-0805X105M160CT)
Q1: P-Channel MOSFET (mine were slightly larger and needed the solder masking scraping to fit - Mouser: 621-DMG2305UX-7)
R1, R4: Not required
U1: PIC18F23K22 (Mouser: 579-PIC18F23K22-I/SO)
S1, S2: Switch Electronics subminature microswitch SBDT


Still some learning on the right component for the MOSFET, but it did work with the one bought from Mouser. 

The buttons can be micro switched or tactile press buttons. Microswitches are subminature. Oddly the PCB is for double throw but are connected together so you need to remove a leg from the switch to actually work with the board. I added a dab of solder mask to stop any future contact (see below)

Microswitches with leg removed

The PCB will need some modification if your laser mouse has a plastic post in the way. Alternative solution would be to remove the post, but if you prefer to not damage the casing then I suggest you drill a hole in the PCB just above the letter I in the AMIGA text. Drill out with size 8 bit to allow the post through.

There's nothing to damage in the bottom left of the board. I had to do this on my board (see below).

Mostly assembled, note the drill hole for plastic post

You will need to solder in header pins for at least R.BTN to +5V on CON1. The POTY isn't required unless you want to see UART output from debugging (not included in the firmware build I've made as not useful and slows processing). Header pins are not required for J2 as the firmware handles the configuration differently. 

A 3d printed closure will be needed to hold the lens in place. I only have a resin printer, which isn't ideal for this type of print. 


There are 2 options for the covers:
https://www.thingiverse.com/thing:7006073

The second link is the intended print for the V1.2 board, but I only found the first linked print that I used in my build. If I did another mouse, then I would try the second one as it has screw points for the V1.2 PCB and less faff filing the print down to fit properly.

The laser module itself needs buying with the lens and circuit board together. AliExpress has some cheaper options than eBay for the ADNS 9800. Solder this component in last after you've printed the holder and can insert the lens into the recess. The ADNS 9800 laser circuit board needs soldering in at the right height and distance from the main PCB, otherwise it will rock about on top of the lens or be too high and not work. 

Remove any protection stickers from the laser lens itself before the next steps. Assemble the holder into the base of the tank mouse, insert the lens, insert the PCB into the mouse base and then insert the ADNS 9800 circuit board and laser into the PCB. Ensure the clear plastic posts of the lens correctly fit through the ADNS 9800 board (if not then try rotating the lens and try again). Solder the ADNS 9800 in situ and you should have the board set to the correct height. 

Writing firmware

Once you have all the hardware assembled, the next step is to programme the PIC. I've used a Raspberry Pi as a common tool. The following guide was really useful for me and you may want to refer to this if you have any issues following my notes:

https://www.pedalpc.com/blog/program-pic-raspberry-pi

This uses the Pickle tool to programme the PIC on the PCB. It will need a download and build to get it working, but this is quick with the following steps from the shell command line:

raspberrypi:~ $ wget "https://wiki.kewl.org/_media/downloads:pickle-5.01.tgz"
raspberrypi:~ $ mv downloads\:pickle-5.01.tgz pickle-5.01.tgz
raspberrypi:~ $ tar zxf pickle-5.01.tgz
raspberrypi:~ $ cd pickle
raspberrypi:~ $ make linux
raspberrypi:~ $ sudo make linux-install

I configured it to use pins 9, 10 and 11 for the programming. To set this then create the following config file in ~/.pickle with your favorite text editor. Note that I'm using a Pi 4 and you should set the DEVICE according to your actual hardware!

DEVICE=RPI4
SLEEP=1
BITRULES=0x4F00
VPP=9
# set PGM = -1 if not used, otherwise use the correct pin number below
PGM=-1
PGC=10
PGD=11

Following this setup, you will need to add some DuPont wires to go into the J1 header. You can solder some pins in or just press the pins against the solder points (I chose to press as I'm only doing this once to program). The pins should be connected as follows (from bottom up starting from + up to the top connector of the PCB)

  • 5v (red)
  • GND (black)
  • pin 9 (white)
  • pin 11 (yellow)
  • pin 10 (grey)



You can verify that Pickle and your pins are setup with the following command line test after attaching your cable to J1 header:
raspberrypi:~ $ p16 lvp id

To program the board you will need a built hex file. Download the prebuilt file from my github at https://github.com/AidanHolmes/Laser-Mouse-ADNS-9800 in the builds directory. If you want to build your own then continue further down to do this yourself. 

Once you have the hex file on your Raspberry Pi, then run the following command from the same directory as the hex file (assuming it's called amiga_mouse.hex, otherwise alter as necessary). Note that you should not connect the mouse to your computer whilst doing this!

raspberrypi:~ $ p16 lvp program amiga_mouse.hex

This should report success. If you get an error then verify your pins are correct and soldering is good on your board.

Final assembly requires desoldering of the shield wire off the original mouse PCB and removal of header pins from the old PCB. The mouse will work without the shield wire so it is your choice to resolder back onto the laser mouse PCB. I soldered it on just to secure it somewhere

Assembled with original wiring loom

It's very likely that the original mouse wiring doesn't follow the exact same colour you can see in the above image. Verify that the 5v power pin is the correct one going into CON1. The rest of the pins should be in the correct order, but if you have problems then you may need to check.

As a finishing touch the board should be secured down to prevent it jumping around in the case. If you use the intended lens holder then 3 screws can go into the 3 holes around the laser. If you use the other lens holder then the screw posts will need spacers or elastic bands around the posts to hold things down. It's not totally necessary but will stop rattling and ensure the lens is kept in place. 

Using the mouse

Well done, you have an assembled and programmed mouse. To configure resolution of the mouse, hold down both mouse buttons when turning on the power to the Amiga (release soon afterwards - no need to keep held). This will put the firmware into config mode. Wait for the OS to boot up and then use the left and right mouse buttons to setup the sensitivity. The mouse cursor will move up and down the screen in response to the button presses (indicating you are in config mode). To confirm the config, press both mouse buttons again and the mouse will move in a V pattern and then exit. Mouse buttons should work as normal after this. If you don't like the resolution/sensitivity then repeat the process. 

Programming a new hex

You've made it this far and still want to build the hex. This bit is a pain in Linux as tools need to match and there are a few dependencies. This is how I got it working. 
Firstly, I'm working with Debian 12 (Bookworm) on my RPi. At the time this distribution wasn't up-to-date enough to just install the tools and start building. Firstly SDCC from Debian only includes the free tools and avoids commercial conflicts by excluding Microchip PICs. 

Firstly, let's get some dependencies needed:

raspberrypi:~ $ sudo apt-get install bison flex libboost-all-dev

Download gputils from https://sourceforge.net/projects/gputils/files/gputils/1.5.0/.

You will actually want 1.5.2 as this has a required fix. 

raspberrypi:~ $ bzip2 -d gputils-1.5.2.tar.bz2
raspberrypi:~ $ tar xvf Downloads/gputils-1.5.2.tar
raspberrypi:~ $ cd gputils-1.5.2/
raspberrypi:~ $ ./configure --prefix=/usr
raspberrypi:~ $ make
raspberrypi:~ $ sudo make install

Check the install with
raspberrypi:~ $ gplink -v

It should say version 1.5.2. If it doesn't then check you ran make install with sudo and all the build worked.

Install SDCC - full version. Download from https://sourceforge.net/projects/sdcc/files/sdcc/4.5.0/.

raspberrypi:~ $ bzip2 -d sdcc-src-4.5.0.tar.bz2
raspberrypi:~ $ tar xvf sdcc-src-4.5.0.tar
raspberrypi:~ $ cd sdcc-4.5.0
raspberrypi:~ $ ./configure
raspberrypi:~ $ sudo cp -r * /usr/local

This will install SDCC with full versions of tools.

Ensure you've downloaded my fork of the repository from https://github.com/AidanHolmes/Laser-Mouse-ADNS-9800 because this has a working makefile for Linux.
Change directory to the code repository and run:

raspberrypi:~ $ make clean
raspberrypi:~ $ make

If it works then you should have an amiga_mouse.hex file in the root directory of the repository. This can be flashed to the PIC using the previous instructions.
To enable the debug then add a 
#define _DEBUG 
to the code at the top of mouse.c

Connect POTY pin to pin 15 on the RPi header. Ensure there's also a ground connection between the RPi and Amiga Laser Mouse PCB (CON1 or J1 have GND locations)

Reading debug UART output on RPi with the following:
raspberrypi:~ $ stty -F /dev/ttyS0 9600
raspberrypi:~ $ cat /dev/ttyS0




Comments