Home Arduino / Raspberry Pi DIY 3D Mouse – Arduino++

DIY 3D Mouse – Arduino++

by technova
0 comments


I have been doing quite a lot of CAD work recently and so decided to acquire a second hand 3D mouse on eBay, the now obsolete 3DConnextion SpaceExplorer.

Soon after that the TeachingTech YouTube Channel published a video about a DIY 3D Mouse that was made from commonly available parts and 3D printed plastic components.

I decided to make one and compare it to the commercial product.


What is a 3D Mouse?

A standard mouse used as with Windows or other screen GUI is operates in 2 dimensions (2D) as it moves a cursor up/down and left/right on the screen (X and Y cartesian coordinates).

A 3D mouse includes control of movement along the axis in/out (Z coordinates) from the screenoften using a rotating cylinder on a base that can be raised and lowered, as well as rotated to allow control of rotation about the X, Y and Z axes.

This type of mouse is used for movement in virtual 3D space, often in conjunction with Computer Aided Design (CAD) and 3D modelling software. It facilitates intuitive movement and model manipulation that gives the user the feeling of holding the 3D object in their hand.

Making the DIY 3D Mouse

The build is documented as a Printables project, so I won’t be repeating most of the information here.

The heart of the project is a great idea to use standard “PS2” analog joystick hardware modules (shown at right) to build the device.

Four joystick modules are arranged around a central control knob, as shown on the left, and the movements inferred from the combination of values returned read from the joysticks.

The hardware connections are shown below (copied from the Teaching Tech article).

Another clever trick is to configure the to control software to look like a 3DConnexion SpaceMouse, recognized by the 3DConnextion software driver, so that it works with all 3D CAD packages.

Calculating Movement from 4 Joysticks

The heart of the control software is working out what the combined movements of the internal joysticks mean. It wasn’t clear to me from the code, or the scant explanation at by the original code author, how this worked so I decided to work it out.

The 4 joysticks used in this project are labelled A, B, C and D. We can work out from the cable exit point in the 3D printed body that joystick C is at the front (forward position) of the 3D Mouse, with B, A and D in the Left, Reverse and Right positions, as shown in the diagram below.

The joysticks are oriented in a circular fashion on the side of the case. This means that the the joysticks on opposite sides will feed back opposite values (ie, one positive and one negative) when moved in the same direction horizontally but the same values when moved vertically (see the V and H axes in the diagram above.

The 3D Mouse movements axes are shown at the top of the mouse manipulation knob (xyz axes).

The simplest case is a translation in the z direction. The mouse knob is pushed up of down. The values read from all the joysticks be the same (or very similar) in the vertical direction, so the combined reading will be the sum of all values divided by the number of joysticks to bring the value back into the correct range
ie, z = (AV + BV + CV + DV) / 4.

For a translation movement in the y direction (shifting the knob left/right, we are interested in the deflection of the A and C joysticks in the horizontal direction but need to reverse the sign of one of these ie, y = (AH – CH) / 2. Similar logic applies for translation in the x direction with joysticks B and D being involved.

Rotating the knob about the z axis creates the same (or similar) readings in all the joysticks in the horizontal direction. So the rotation ‘amount’ is determined as
rz = (AH + BH + CH + DH) / 4.

Similarly rotating the knob about the x and y axes is the combined output of A/C and B/D in the vertical direction.

For completeness, here are all the formulas derived:

  • z = (AV + BV + CV + DV) / 4
  • y = (AH – CH) / 2
  • x = (BH – DH) / 2
  • rz = (AH + BH + CH + DH) / 4
  • rx = (AV – CV) / 2
  • ry = (BV – DV) / 2

Depending on the actual output read from the the joystick V/H axes, the calculated 3D xyz directions may need to be reversed.

Software

I extensively modified reworked published software to make it more maintainable and added switches to the 3D mouse interface (my derived code is available in my code repository)

The software is split into three main parts:

  1. Read the 4 joysticks and combine the readings as outlined above.
  2. If the switches are enabled, read the state of the switches.
  3. Report all the readings through a HID USB interface.

A special boards.txt file is used as a trick to make the project look like a 3DConnexion device. I found the instructions provided in the original article to be incorrect if you are using Arduino IDE v2.0 or greater.

  • The location of the board families has changed to /Users//AppData/Local/Arduino15/packages
  • The boards.txt file has changed. The correct boards.txt can be found at my code repository in the docs folder.

Testing & Conclusion

The idea has merit, but it does not work as well as the commercial version. I guess no surprises here, as you are paying many multiples more for the commercial product.

From a software perspective, it works well.

However, the mouse movements feel really mushy compared to a SpaceMouse. The small version is still a lot bulkier than my now relatively large SpaceExlorer (photos below), making it uncomfortable to use for extended periods.



Source link

You may also like

Welcome to Technova Pulse – Your Gateway to Technology & Innovation

At Technova Pulse, we dive into the fast-moving world of technology and innovation.

Subscribe

Subscribe my Newsletter for new blog posts, tips & new photos. Let's stay updated!

© 2010-2025 Mahasun.site. All rights reserved.