After having been triggered by @ctdodge and @GoSmitty in this thread and @PaulAlfaro in that thread, I had a look at adapting one of the existing pendants for CNCjs, to derive something that would work with a wireless keypad AND have smooth jogging AND be compatible with using CNCjs on Windows.
Exactly as I knew would happen, the one hour experiment turned into a week-end of trying out various things, “enjoying” the fun of Node.js development under Windows (), getting prototype #1 to run, realizing this was a dead-end because Windows won’t let an app steal the control of a secondary keyboard device, and restarting from scratch with a different approach. Anyway, enough developer rambling, I ended up with a pendant that will catch specific key presses from a keyboard and send associated G-code commands to the machine via CNCjs, to jog around by steps or with smooth/continuous jogging.
I mapped it like this (illustrated with the keypad the popular kids have, but it will work with any keyboard/keypad):
- pressing the left,right,up,down,pageUp,pageDown keys will jog the machine by the FINE step size, along X/Y/Z
- holding the Alt key while pressing these jog keys will jog by the MEDIUM step size
- holding the Ctrl key while pressing these jog keys will jog by the LARGE step size
The distances for FINE, MEDIUM and LARGE can be modified in the source code, they are currently set to 0.1mm, 1mm, and 10mm.
- /!\ holding the Shift key while pressing a jog key will start a CONTINUOUS smooth jog along the selected axis (no need to hold the key). Pressing the jog key again WHILE still holding the Shift key will STOP the movement.
Here’s a quick demo:
Now, for the bad news: the way it’s implemented, the pendant needs to be started from a command line shell in Windows, and then that window needs to have the focus for the keypad presses to be taken into account. It works, but it’s a bit inconvenient because on typically has the CNCjs window/app active.
The code and detailed instructions to install and execute it are up on github, and they go like this:
CNCjs must be running (either the standalone app, or as a server)
From a shell/command window, go to cncjs-pendant-keyboardreader
directory, and run:
node bin/cncjs-pendant-keyboardreader --socket-port XXXXX --port ZZZ
To determine XXXXX value:
- On Windows, if using the CNCjs standalone app, go to the “View” menu, click “View in browser”, this should open a browser window to a URL that will look something like “http://127.0.0.1:57325/#/workspace”. The number right after the “127.0.0.1:” part is the XXXXX to be passed along.
- On Linux, if using the CNCjs server, the XXXXX value is normally 8000, unless specified otherwise.
To determine ZZZ value:
This is the name of the serial port that CNCjs uses to connect to the machine (see “Port” field in the “Connection” widget in CNCjs)
- On Windows, ZZZ will often be something like “COM5”
- On Linux, ZZZ will often be something like “/dev/ttyACM0”
If execution is successful, you should see something like this:
Connected to ws://{loooong string of characters here}
Connected to port ZZZ (Baud rate: 115200)
and then the keypad is active (provided the command window has focus)
I do realize this is all a convoluted way to having remote smooth jogging in CNCjs on Windows, while this would take zero specific effort if using CarbideMotion (due to the fact is has native smooth jogging, kudos for that, and adequate keyboard shortcuts in the first place)
Yet if someone read through all of this and wants to give it a try, I’ll be happy to provide support or modifications.