XHC HB04B pendant

Hello Claudio,
As you know I’m looking to integrate the XHC HB04B manual pulse generator pendant with LW4. So far I was able to get the keys working
I’ve reviewed the code of the MPG tree and there are some chunks that are very similar to what I’ve been doing, namely separating the appSocket.on hooks into separate functions that can be called by the parseMPGPacket as well. However I took a different and very painful path when it comes to USB communications. I’m now using node-usb while I see that you are plainly using node-hid, which is much more elegant.

I can definitely put some time to make the functions more generic for HB04 and HB04B (as a side node, it’s my understanding that the wireless WHB04B shares the same protocol frames as the wired LHB04B).
Some excellent information on the HB04B can be found here:

What would it take to integrate the specifics of the MPG tree to the lw.comm-server? I would then modify the functions so they work with both HB04 and HB04B and possibly other future MPG. I did a compare and the changes are significant with lots of of new libs adaptation and firmware switch selection structures.


1 Like

There is one line in config.js to set the used pendant. Actually hb03 or hb04 are valid settings.

Then in server.js there is the include of node-hid plus some variable preparing (reading in config) on the top of the file, but the most code for the pendant is at the very end of server.js.

If there is no compatibillity issue with node-hid, it should only take about 30 minutes to copy the needed code to the master branch. I could do it the next time I am at my machine (for testing the HB04).

1 Like

Thank you @cprezzi ,
Once you have the HB03 and HB04 integrated in the main branch of lw.comm-server, I’ll add the HB04B code.


@harlock999 I have ported the MPG code to the master branch, but not much tested and not cleaned up. Basic things like Run, Pause, Stop, Reset, gotoZero, setZero, jogging axes and changing feed or spindle speed seem to work, as well as displaying the work coordinates. Only feed and spindle values are not yet displayed on the LCD.

To activate it you need to set mpgType to HB04 in config.js

1 Like

@cprezzi Thank you, I’ll have a look this week.

I’ve been working quite a bit on the integration of the HB04B. So far so good! As of today I got the display working and the step jogging seems to work.
I am not sure how the code is meant to work for the continuous jogging though. In the function doJogContinuous there were variables missing and it feels like the code was started but never finished. It also produces a GCode string but on my server instance it doesn’t do anything. I can fix it if you can confirm it was not completed.

I don’t remeber exactly, but I think I started implementing continous jogging without having jog.canel, which has not been implemented yet. :wink:

So far I made the behavior like this:
Incremental jogging: same behavior as before, each communication cycle where the jog wheel was spun counts for one step increment (or decrement if jog wheel was spun counter-clockwise). As soon as the operator stops spinning the jog wheel, the machine stops jogging if it could keep up with the speed and steps. The feed rate is rather low. As the machine can keep up, it feels very ragged or steppy with quite some vibrations at larger steps.

Continuous jogging: a bit more smooth as this time I take into account the velocity of the jog wheel, that is the number of counts every communication cycle. This time the feed rate is higher as each jog command is piling up in the queue. The good side of this is if I move the jog wheel by 50 clicks, the machine will also move exactly by 50 clicks.

Right now if I stop the jogging and the machine can’t keep up with the queue and I see it’s about to crash, I can press Stop on the MPG.

If there was to be a jog cancel, I think I’d rework the logic so it picks up a STEP or CONT button release on my HB04B. How would you send a jog cancel? I guess you’d need to flush the queue but can you do that without alarming out the control board?


Jog cancel is a realtime command in grbl, which doesn’t go into the queue, but is executed immediately after receiving. It is meant to be used in combination with Jog commands ($J=)

0x85 : Jog Cancel

  • Immediately cancels the current jog state by a feed hold and automatically flushing any remaining jog commands in the buffer.
  • Command is ignored, if not in a JOG state or if jog cancel is already invoked and in-process.
  • Grbl will return to the IDLE state or the DOOR state, if the safety door was detected as ajar during the cancel.

See Grbl v1.1 Jogging · gnea/grbl Wiki · GitHub for details on jogging.

Unfortunately only GRBL supports this type of jogging and realtime commands!

I just submitted a PR to support the HB04B. To enable, you can use either environment variable MPG_TYPE set to HB04B or modify config.js line

config.mpgType = process.env.MPG_TYPE || 'HB04B';

I didn’t go in details of the jog cancel as I’m using Smoothieware and can’t test easily with my current setup. I can use the STOP button on the pendant to halt the jogging if there are too many steps accumulated and I see it’s going to crash into something.

Overall I’m happy with the behavior. I can reset and pause, but can’t resume yet. The Stop will halt and alarm the control board.

Only drawbacks are hardcoded stepping values for continuous and step jog.

The feed rates and spindle rates aren’t showing as I couldn’t figure out how to make those work.

RESET will show when the board in in alarm, but it’s not 100% accurate, there are some instances where I wasn’t sure where to capture that state, yet it shows Alarm on the frontend.

For now there is no handling of machine coordinates, only workpiece coordinates.
Only for XYZ axis for now, couldn’t test with A axis.

FN+M-Home will cause a machine homing sequence, Z first then Y and X. Eventually I think we should revisit this as this is tied with the frontend as well. I feel it needs some coordination, single point of configuration.
FN+W-Home will zero at the workpiece

Axis selection must be set to something else than OFF for the display to work, this is a known bug with the pendant. It’s not a huge issue as the way it is programmed in lw.comm-server you need to hold down CONT or STEP in order for the jog wheel to be active, so even if you have an axis selected and you bump the jog wheel by mistake, nothing will happen.

For the step size selection, the 0.001 scale is the same as 0.01 scale. The LEAD position doesn’t do anything.

Edit: If one tries to jog while a GCode file is running, the jog commands will pile up after the GCode is done. So you won’t mistakenly wreck your work, but be aware of that jogging is going to happen eventually.

I can program other features depending on the need and my ability to reproduce the setup in my shop.


1 Like

Cool stuff. I will look at the PR as quick as possible.