Friday, 21 November 2008

The Joy(stick) of Machining

I control my router with EMC2, which rocks, BTW. It's extremely versatile and extensible, while being easy to use, and has a vibrant community of contributors. I thoroughly recommend it.

The most accurate way that I have of measuring the offset between the tool and some fixed point (for example, in order to set the tool length offset) is to move the tool to that point, and see the offset in machine coordinates. At the moment I do that through the jog GUI in AXIS, which is slow and awkward, so task number one is to improve that.

I've got a USB joystick, and I'm following these instructions on the EMC Wiki. The rest of this post assumes that you have read them.

If you don't understand EMC and the HAL the instructions and the logic behind them won't make much sense, in which case I recommend reading an introduction to EMC2.

The joystick setup process is simpler than it looks: download joypad_v3.hal, tweak it, put a reference to it in your .ini file, and install joyhandle. The two snags that I hit were with getting the hal_input module to see my joystick and getting joyhandle helper module to work.

I had trouble with the hal_input for two reasons: I hadn't followed the "setting the permissions for input devices using udev" instruction closely enough, and had to mess around with the name pattern for the joystick to get one that hal_input would accept.

joyhandle is a HAL module designed to set a deadband around the center of a joystick axis, and provide power law and linear scaling for the value of that axis. There is a precompiled version on the EMC2 Wiki, but it's for a rather old RT kernel, so it doesn't work. Luckily, there's also a .comp (source) file. I installed the emc2-dev package to get comp (the HAL module compiler). After that, building and installing the module was as simple as:

$ sudo comp --install joyhandle.comp

And the man page:

$ sudo mv joyhandle.9.gz /usr/share/man/man9

Then it just worked. :-)

By itself, the addition of the joystick has made my old method of measuring tool offset or stock position quicker and easier, but the full benefits will come when I combine it with automatic offset recording for X and Y, and automatic probing to detect the tool length.

No comments: