CNCjs Joystick pendant


it’s ready… I have to test it, but not before next week… no time this weekend.

2 Likes

the white wire is not connected?

That’s the Z axis and the example code I showed does not read it. Easy to add afterwards.

This is what happens when I realize it’s 10pm already, I have a few minutes of shop time left but I want to get this done anyway, so I grab everything, start-up the soldering iron, solder solder solder, plug usb, load code, run, post about it, and doooooone. If I could buy time, I would. :sweat_smile:

2 Likes

we are all the same here… we work until 11pm…
I did my welding on Tuesday night :wink:

1 Like

It looks great. I will definitely try to build one myself. I already have the leonardo and the oled display. I will order the joystick and the mpg but I have tested the arduino code with a simple 2-axis joystick and a rotary encoder and I can see in the serial monitor it’s working fine. Could I get a 6 terminals mpg and connect only 4 of them or I should get a 4 terminals mpg?

I’m not familiar with the cncjs code (haven’t tested yet the pendant code) but I could help with the arduino code and I might rewrite some functions to match the hardware I have in mind.

The display will be on for both modes showing what is active. I don’t want to use the mode selector switch. I’m thinking to use the joystick button to enable joystick mode, and then use either the axis button or step button to enable mpg mode. I want to add as much buttons as my board (pro micro) allows to add more functions (home machine, zero selected axis e.t.c). Would that be possible to add functions like connecting to the machine, probe Z and other macros?

2 Likes

not sure about connecting to the machine, but anything that executes G-code (macros) does work, as the CNCjs pendant interface basically allows one to talk to the machine directly. I implemented smooth jogging that way:

1 Like

This topic was automatically closed after 29 days. New replies are no longer allowed.

FINALLY some progress, it’s alive:

I restarted from @mingle’s code (thanks! experimental as it may be, it saved me hours of effort), and customized it for my setup.

I added the management of the joystick Z-hat/button, it now acts as a safety enable for joystick movements (because eventually my joystick box will be located at the front right of the enclosure, and I wouldn’t want the machine to start moving if I hit the joystick when leaning into the enclosure)

The buttons on the right are used for X/Y/Z single step, and the top three buttons allow to select between 1mm, 0.1mm, and 0.05mm steps (which is all I ever use in the CNCjs interface anyway)

I’ll probably tune the delays and steps to smooth the speed variations (which can be heard in the somewhat funky jogging noises), but I think I’m hooked to the joystick as a jogging device. It feels much more natural to me than all keyboard-based jogging solutions I experimented with previously. And since I moved from the SO3 to the XXL, the importance of being able to jog quickly to any location matters a lot now.

Note1: the 3D-printed case for the small OLED display was only supposed to have it at an angle for better visibility, somehow it turned out looking like a mini iMac or something, which looks cool so I did not bother printing a less bulky version.

Note2: I used an Arduino Leonardo since I initially wanted to emulate a keyboard, but at the end of the day a plain old UART (that can run on any Arduino) like @mingle did is much better, as one does not have to care about window focus then, the CNCjs pendant just runs and listens to anything coming on a specific COM port, regardless of the currently active window.

Note3: still, the Leonardo will come in handy if I want to use this setup to control Carbide Motion via keyboard shortcuts emulation. Right now it’s a CNCjs-only solution.

8 Likes

I went down the USB/Keyboard emulation route, @Julien, and have a dial-based jog pendant which like yours has become indispensable in use. It will work with any Sender app that can have keyboard shortcuts, and any host OS (Pi, PC, Mac). I would argue that second only to the HDZ, the pendant has been the best addition to my 3XL. I designed a housing, mini-PCB to hold the switches and Leonardo etc., wrote the Arduino software such that I could experiment with switch de-bounce ideas (settled on integrator/numeric settling), and so I could include rotary axis control in such a way that the static axis (Y in my case) can’t be nudged in error once aligned with the chuck axis.

Using mine with UGS (so I can have the visualiser graphic, and also 5-axis numeric display) works really well, and only occasionally do I suffer from the ‘jog keyboard’ losing input focus. The Mac just beeps if this happens as I have chosen keyboard commands that can’t accidentally cause some other action if focus is lost. I might experiment with Lua Macros to see if an embedded pendant function is possible, in which case I have the best of both worlds. One for another day, I have a rotary axis to play with now :slight_smile:

6 Likes

I finished mine a few weeks ago. It’s also based on @mingle code but I have made a few modifications especially on the Arduino code.

The joystick stops transmitting data when it’s idle. That way the buttons work only when the joystick is idle.
There are 6 buttons + joystick button.
Joystick button: switches the mode from MPG to Joystick.
FN: acts as function to add alternate commands to each button when it’s kept pressed.
AXIS: switches from Joystick to MPG mode. In MPG mode it switches the selected axis between X and Y. It enables Z if FN is pressed.
DISTANCE: same with AXIS. Decreases the selected distance. Increases if FN is pressed.
ZERO: in Joystick mode it sends G10L20P1X0Y0. In MPG mode it sends G10L20P1x0 where x is the selected axis. With FN pressed if selected axis is X or Y it sends X0Y0, if it’s Z it sends Z0.1. All of these could be easily change in the Arduino code.
HOME: sends $H or G53G21X-50Y-50Z-10 with FN.
EXTRA BUTTON: not assigned to anything yet.
I have added two ws2812 LEDs which show which mode is enabled (MPG or joystick). I could add more functions to the LEDs later.

I had to experiment with joystick.js to find the best values for my machine. My machine is homemade and it’s not very fast. I was changing manually the values in this equation: step = v * dt; until I found what is the best step for my machine. Then I calculated what should be the MAX_SPEED to achieve that step and I experimented with SMOOTH_JOG_COMMAND_INTERVAL to have a smooth result. It might need a little more effort but I’m happy with the result.

If you need them I could share the edited files and my Arduino code.

11 Likes

Disapointed in myself right now for not reading this thred throughly the first time, but thanks for the video´s all of you. I´ve spent &"%#$"%$ hours browsing for backdoors into CM and UGS to find faster JOG interface than keyboard emulation. The @mingle method seems great! Now I need to test CNCjs… If anyone knows any alternative ways where motion program is still able to track position during jogging (while at the same time showing it on the screen), then please share.

As a break, I decide to put more effort into the GUI on my side for the moment as I temporarily need a break from the annoyingly slow respons in CM.

Sorry, I read that twice and I can’t tell for sure what this means, can you please elaborate ? (on the off chance I may have an option for you based on my own tests)

Repeated keystrokes from Arduion HID device into Carbid Motion is not working fluent. I still have a bit of testing to do though, but I have been autoswitching the steprate to try to make it smooth. Many buttons and especially the jog menu selection in Carbid Motion doesn´t seem to have any shortcuts. Not even an alt-shift-control-secret combination (at least I haven´t found one yet). That makes it more complicated to set up automator on mac to do specific macros. I can’t see how C3D could ever lose anything from stimulating the community to make various pendants.

UGS has the command line available on the front and I am about to test that, but any other stream interface similar to a joystick, with command line access, (input only is sufficient) would not disturb the HMI.

1 Like

I want to build another one but I don’t have any pro micro boards and it would take 1-2 months to arrive here. I built it using an Arduino nano but it doesn’t seem to work.
It works on my computer and I can see data on serial monitor but I don’t see any data using cncjs-pendant from @mingle. I changed of course the device parameter from /dev/ttyACM0 to /dev/ttUSB1 which is my arduino nano.
On cncjs I can see both ttUSB0 (grbl) and ttUSB1 (pendant). If I connect on ttUSB1 from cncjs I can see the data on the console, so my device is working.
I just don’t know how to make it to communicate with the cncjs-pendant script. The pro micro has an atmega32u4 with usb support. The nano board is using a ch340 for usb communication. Could this be the issue? How could I fix that?

I, regrettably, have not really followed this thread, so I’m offering a guess. The Pro Micro can be used a USB HID (human interface device), so your computer recognizes it as a keyboard. The nano does not do this.

Where are you located?

The code for the pendant relies on messages through serial. So I think it could work with a board like nano. I think @mingle who wrote the code could help us make it compatible with a board using CH340.

I’m in Greece. I order these from aliexpress (China) and it takes more than a month to arrive.

Hey @jaikor,

Indeed it should work with a nano, that code uses the interface as a UART, and does not pretend to be keyboard or joystick, so the built-in support for HID present in the Pro micro is not leveraged.

Since you are getting traces in the serial console from your arduino, it’s all good from that end. Chances are it’s something in the configuration of CNCjs pendant that prevents it from properly connecting to that UART port OR to the CNCjs server. When you executed the pendant, what console traces do you see?

Have you tried another off-the-shelf pendant to make sure it’s not something with the CNCjs server connection itself ? The server port in CNCjs is allocated dynamically unless it is explicitly set to a given value.

1 Like

I see these messages when I execute the script through ssh

cncjs in installed on a orange pi zero plus running armbian. Could this be relevant?
The other pendant I built with the pro micro board works fine.

Mmh. So the connection to the CNCjs server works and opening the serial port works, I would add a simple dummy trace in getPayloadData to check if it’s called or not. If it is, you may want to dump the raw content received and check its format. If it isn’t…I’m out of ideas