CAD Mouse MK2, a 6DoF Space Mouse Using Magnets
by salimbenbouz in Circuits > Gadgets
19484 Views, 134 Favorites, 0 Comments
CAD Mouse MK2, a 6DoF Space Mouse Using Magnets
This is the second iteration of my DIY CAD mouse, rebuilt to behave like a real 6DoF controller this time. It uses a custom PCB with three magnetic sensors, a 3D printed spring, and a redesigned enclosure that’s smaller and easier to build.
⚠️ Before building, keep in mind that as mentioned in the video, the motion processing for this project is still not fully solved and may eventually be replaced entirely. There is currently some bleed between the axes because each one is calculated independently, and the implementation also assumes the sensor readings are linear, which is not true.
Supplies
Custom PCBs
- Option 1: Fabrication files to order your own → Gerbers BOM
- Option 2: Assembled board and MCU Adapter (while supplies last) → Here
Bill of materials
- 1 × Seeed Studio XIAO RP2040 Seeed Studio
- 16 × Heat-Set Inserts M3 x 4 Amazon
- 10 × Hexagon Socket Head Cap Screw M3 x 16 Amazon
- 5 × Hexagon Socket Head Cap Screw M3 x 12 Amazon
- 1 × Hexagon Socket Head Cap Screw M2 x 4 Amazon
- 6 × Neodymium Magnets (6mm x 3mm) Amazon
- 4 × Rubber Bumper Feet Amazon
- Steel pellets or similar to add weight to the base
Tools
- 3D Printer Bambu Lab
- Soldering Station/Iron. Amazon
- Precision Screwdriver Set Amazon
- Flux, Solder
- Hotplate, Solder paste (if you're assembling the sensor board yourself)
- Flush cutters
- Tweezers, pliers
Affiliate links may be included in this list. I may receive a small commission at no additional cost to you.
Watch the Build Video
In this video, you’ll get an overview of the design, the build process, and the final assembly steps.
Enclosure (3D Printing)
The enclosure files are available in the GitHub repo, and you can also download them in the format you want from the Autodesk Fusion embed.
The 3D-printed spring can be customized using the parametric file linked here. I used Bambu Lab PETG HF because it’s widely available, easy to print, and seemed to provide decent performance for the small amount of knob deflection needed. ⚠️ That said, many of you pointed out in the video comments that it may not hold up well over extended use as a flexure. I’ll keep an eye on it, and if it ends up failing, I may redesign the knob assembly or try other materials. For now, though, replacing the spring is cheap and easy if it permanently deforms.
Other than the diffuser, which should be printed in a translucent material, I printed that part in Clear PETG and the rest in matte PLA. If you want a nice surface finish without post-processing, you can orient the knob and outer shell as shown in the video. It does require supports and isn’t the most efficient orientation, but the tradeoff is a better finish. If you’re printing in PLA, I also highly recommend using PETG support interfaces. They make the supports much easier to remove and help keep the undersides clean.
Enclosure (post-processing)
After printing the enclosure, install the 16 heat-set inserts.
As shown in the video, I ended up switching the outer shell, knob, and buttons to resin prints. ⚠️ If you do the same, the heat-set inserts will need slightly larger holes, and I epoxied them into place in those parts.
If you want to post-process the FDM prints, you can follow the same process described in the previous version linked here. You’ll also need a few extra materials for that step that I did not list here.
For the hollow base, I filled it with steel pellets to add as much weight as possible, then poured in a small amount of two-part silicone to fill the gaps and hold everything in place. Some of you suggested using candle wax instead, since it is easy to access and melt. This step is totally optional, but it does stop the pellets from rattling inside, which is a nice bonus.
I found that about 250 g is heavy enough, though more weight is better. There are also plenty of other ways to add weight to 3D prints if you would rather use a different method.
Electronics (SMD)
If you ordered the assembled sensor board, you can skip ahead to the next step.
I applied solder paste directly to the board and placed all the components by hand. All of the SMD parts are on the same side. Since not all of the components have exposed leads that can be soldered easily by hand, I recommend using a hot plate or hot air for assembly, and maybe get a stencil with your PCBs for cleaner paste application.
After reflow, make sure to fix any solder bridges or blobs before cleaning the board with isopropyl alcohol to remove the flux residue.
Electronics (TH)
There are a total of 6 through-hole headers to solder.
First, place the two 2 mm 6-pin header connectors on the back of the sensor board, as shown in the picture. The pins on these headers are a bit fragile, so take the time to straighten them if they arrive slightly bent.
I found it easiest to solder one corner pin while pressing the board and connector against a flat surface to keep it aligned. Once the two corner pins are soldered, you can finish the rest of the pins easily.
Next, insert the two 2 mm 6-pin header pins into the connectors you just soldered, then place the MCU adapter on top. ⚠️ It is very important that the MCU side warning text is visible from the side you are soldering. The small adapter is labeled on both sides, with “2 mm header” on one side and “XIAO MCU” on the other, so orientation matters here.
Using the same technique as before, solder one corner pin first while making sure the PCB stays flat and straight. Once the two opposite corners are secured, you can solder the remaining pins.
Finally, solder the XIAO using the 2.54 mm headers it came with, as shown in the picture. ⚠️ Before proceeding, make sure the 2 mm header pins soldered to the center of the adapter board are not touching the XIAO RP2040 once it is placed on top. The 2.54 mm header pins will be too long on the underside of the adapter PCB, so trim them with flush cutters once soldered to tidy up the module.
Once finished, you should have two separate pieces: the sensor board and the MCU on its adapter.
Assembly
The assembly starts with three M3 × 16 mm screws to secure the 3D-printed spring to the stem through the small spacer.
That is then inserted into the knob along with the magnet holders and secured with three M3 × 12 mm screws. You can also install the magnets at this stage, using two 6 mm × 3 mm magnets per opening. They should friction-fit or stick to the screws, so glue is not needed. It is important that they all face the same direction. I usually stack them together and press-fit them two at a time without changing orientation.
Set the knob assembly aside for now and move on to the rest of the enclosure. The translucent diffuser goes over the sensor board. ⚠️ Pay attention to the orientation: there is a small recess where the 12-pin header is located as shown in the pictures.
Next, place the two small buttons into the grooves in the outer shell. Make sure they are oriented correctly and follow the same curve as the outer shell. Then drop in the sensor board and diffuser, aligning the headers with the notch for the USB connector.
For the weighted base, place the base separator and secure it with a single M3 × 4 mm screw through the center of the base, then insert that into the top shell. At this point, you should still be able to see the sensor board headers, and it is a good idea to check that the buttons are positioned correctly and press properly.
Secure the base with four M3 × 16 mm screws from the bottom. Do not over tighten them, as this can cause the buttons to jam. If they stop clicking properly, loosen the screws slightly.
Then attach the knob assembly using three M3 × 16 mm screws from the bottom. The base separator has a small recess to locate the stem correctly. Before tightening everything down, make sure the knob is straight and centered.
To finish, cover the four bottom screw holes with rubber feet and plug the MCU and adapter into the sensor board headers.
There is also a small lid that covers the MCU and holds it in place with two M3 × 12 mm screws, but we will leave it off for now, in case you need to force bootloader mode or reset manually while flashing the firmware.
Firmware
To flash the firmware for this project, you will need Visual Studio Code with the PlatformIO IDE extension installed.
Once that is set up, clone or download the GitHub repo and open the main project folder in VS Code File > Open Folder...
- Allow PlatformIO to finish configuring the project. This may take a few minutes.
- Click the PlatformIO icon on the left to open the sidebar, then click Build. If everything is set up correctly, you should see a success message.
- Connect the device to your computer using a data-capable USB cable.
- Select the correct serial port for your board from the drop-down menu, then click Upload.
- If PlatformIO cannot automatically put the board into bootloader mode, you can do it manually using the instructions linked here, then try uploading again.
If the board flashes successfully, the LEDs should animate in blue to indicate calibration, then turn solid green once it is done. ⚠️ Try not to move the knob during calibration, since the sensor offsets are being averaged at that time.
After a period of inactivity, the light will turn off to indicate "sleep". The knob will not respond until it is woken up again by pressing either side button.
If you want to run calibration again, hold both buttons for a few seconds until the blue swirl animation appears.
For driver support, configuration, and other software details, refer to the README.md file in the firmware folder.
Done
Thank you for sticking around until the end! I'd love to hear your suggestions in the comments below.
I have other ideas and I plan on making more projects like these Follow me for more.