Tuesday, December 22, 2009

Hooking up a machanical joystick and Start/Stop buttons to work with Mach3 CNC Software

Here is an easy way to hook up a mechanical joystick to Mach3 CNC software.
There are two ways to go about hooking up a mechanical joystick to Mach3
1. Via the Pc parallel port - this way will work, but you are using 4 input pins that can be used for
limit switches or other inputs
2. Hook up the mechanical to a USB gamepad (some modifications needed)

I will show here how I modified a USB game pad to run Mach3 software

The reason I needed to use a Joystick is I wanted to control my hot wire cnc foam cutter with a
large, robust manual joystick - just like the one in the picture below.

Here is where I purchased this joystick

The next step is to get a USB gamepad, and take it apart. There will be many different gamepads available - choose a cheap one and make sure it works before you take it apart.

Please not that this blog describes what I did, I take no responsibility for any damage or any injury resulting from following these steps.

I used a $15 gamepad - but you can find them for less then $10
Remove the cover
We will use the following buttons - but you can remove and add as much as 14 buttons/functions

The two Joysticks and the two sets of two buttons shown on both ends of the bard will not be used. To make it simple - I removed the two switches at the edge of the board and left the
joysticks in place (although they willnot be used)

The gamepad switches are hooked up in a simple way - one side of a switch is common (ground), and the other is connected to the other side of the USB chip (the brain of the gamepad)
We would replace the switches that used by the gamepad with our own switches.
In this example I will be using the up/down/left/right keys in Mach3 as well as Start, Stop, Feed UP and Feed Down.

The first step is to remove the original switches that we will replace, these are the two on the right and the left on the picture above. If you look closely you will notice that one line is common to all the switches - this line is the ground line.
This step is a bit tricky - you will need to find which of the 3 lines is the ground.
One way to do that would be to use a continuity meter. place the meter between two of the pins and press a button - if you see a short, then you found two of the leads for a specific switch.
Do the same for the other switch.
Another way, is to hook up the gamepad and then take a short wire and short two of the pins.
If you shorted one of the pins to ground, then you found the ground and the switch, if you shorted two of the switches - nothing will happen.
Please keep in mind you are doing this on your own risk !!!

Another way is to simply follow the line that goes to all the switches - this line will be the ground line.
In the picture above pin 3 is ground, and pins 1 and 2 are the switches.
Next step is to solder extension wires from pins 1 and 2 to the large Joystick
It is not really important which pin goes to which switch since we will set up the Mach3 key grabber at the last step.

At this point I will stop working on this Gamepad and move on to a different one I purchased today at a local electronics store.
This gamepad is made by a company called AlienWare. The modifications are much easier.

So once again, open the cover and you will see the board as shown below
On the right side you will see where the 4 switches used to be and on the left the other 4.
There are total of 20 switches on this board all can be programmed to work with Mach3.
The next step is to solder wires from where the switches used to be to your joystick
If you follow the traces on the board you will notice that there is a line that goes to all the switches, this line is the ground line and it is the common line to all the switches.

The other side of the switches will connect to your Joystick (these are circled in the picture above)
Here is another picture will all the "un important" features removed

Next step is to hook up the joystick, The joystick has 4 switches, we would connect them where one wire will go to all the common connectors and another 4 wires will go to the other side of the switch. Make sure to connect them to the N.O connector and not the N.C
N.O - Normally Open
N.C - Normally Closed


The picture above shows the yellow wires are the common and the black wire is soldered to 4 yellow wires - this will go to the ground pad on the gamepad
To make things clearer, here is a video that shows the joystick hookup


The next step is to connect the other side of each switch to the 4 remaining wires
Shown in the video below. Use a bit of hot glue to keep the wires from pulling off

and some pictures


Now solder the 4 wires from the Joystick onto the board. In the picture below, the black wire is the common (the Ground). Place some hot glue to hold the wires in place
Now do the same for the other side - and add as many lines as you like - on this gamepad you can use up to 20 inputs.
The picture above shows the two joysticks and another button that can be used as the stop button.
Now - testing.
In the mach3 directory, you will find the executable file named "Keygrabber" run this file and
make sure that your gamepad shows up (you will have to enable it - since by default is is not enabled)
Now test the joystick - you should be able to see a value for each switch pressed.