CNCjs Joystick pendant

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

I’m not sure how to do that. Where is getPayloadData and how could I dump the raw content?

It’s one of the functions in the file cncjs-pendant
Locate that line:

// console.log(parts);

And uncomment it (remove the // )

If anything comes in the serial port, you should see log traces in the console where you started the pendant

1 Like

@Julien You were right, getPayloadData is not called. I have no clue. I tried other boards too (UNO) which are recognized as ttyUSB1 and ttyACM0 and none of them worked.

Mmh. Since you don’t have a Pro micro on hand (of course), we can’t tell whether it would work or not with a micro. My gut feeling is that it’s unrelated, I really can’t see why the different USB chip would make any different in opening a serial port and reading raw bytes like the code here does.
Any chance you might have programmed a different baud rate in the arduino code, than the one that the CNCjs pendant code expects (115200 by default) ? Did you make any modification in the Arduino code itself?

This is the second pendant I want to build. My first one runs fine on a pro micro with the same firmware. I double checked the baud rate. It’s 115200 and I can see data using CoolTerm on Mac. I have no idea what’s going wrong.

I found the issue and now it’s working with the nano board.
Right after

const parser = port.pipe(new Readline({ delimiter: '\n' }));

I added

port.on('data', data => console.log({ port: data }))
parser.on('data', data => console.log({ parser: data }))

and I was able to see some data but not in the proper format like there was a wrong baud rate set.
I added the baud rate in const port = ... so now it’s

const port = new serialport(options.device, { autoOpen: false, baudRate:115200 })

I don’t know why and how it was working on pro micro board, but on nano it requires the baud rate in this line.
Also I corrected the delimiter from \n to \r\n.

2 Likes

excellent investigation work! I suppose the underlying serial driver (which at some lower level must differ between the Pro Micro and the Nano) had a 115200 value by default for the Pro Micro, and some other value like 9600 for the Nano. Anyway, glad to hear you fixed it!

ola amigo sou do brasil gostatia de contruir meu pendant igual ao seu gostei muito do modelo poderia postar seu codigo.ino para eu tentar montar um.
obrigado fico no aguardo de uma ajuda.obrigado a todos

ola amigo sou do brasil gostei muito do seu modelo de pendant gostaria de contruir um para minha maquina.voce poderia compartilhar os aquivos ou codigo fonte? focarei muito agradecido att adalton moura

You can find my code here

1 Like