AXIS: EMC2 Blog
Blog
About AXIS
Get EMC2
Documentation
Translations
ETCH CNC
Developer Homepages:
Chris Radek
Jeff Epler
Related sites:
linuxcnc.org
linuxcnc wiki

« A few more features trickle in to CVS | Newest entries | AXIS has become a part of EMC2 »

This short Python program uses the 'hal' module, part of the development version of AXIS, to control feed override with an external jog wheel.

Place hal_feedoverride_wheel.py in your emc2 bin directory with the name hal_feedoverride_wheel (no extension). Then, load it with halcmd 'loadusr -W hal_feedoverride_wheel', and link up the 'enable' and 'count' signals.

The 'hal' module is only available when using the development versions of AXIS and EMC2.

Creating the component takes only a few lines of code:

    h = hal.component("hal_feedoverride_wheel")
    h.newpin("count", hal.HAL_S32, hal.HAL_RD)
    h.newpin("enable", hal.HAL_BIT, hal.HAL_RD)
    h.ready() 

It then drops into a loop that runs until emc2 exits:

    while 1:
        time.sleep(sleep_interval)

        enable = h.enable
        count = h.count 
followed by code to act on 'count' and 'enable'. By creating local variables from the pin values, you "latch" them. Otherwise, referring to 'h.count' several times in the loop body may give you different values because the realtime thread saw the wheel move in the meantime.

So far there are several Python HAL components I'm playing with: Included in the development tree, there is 'hal_manualtoolchange' which pops up a dialog when it's time to change tools. And there's also mousejog.py, which captures the mouse's X, Y and mouse wheel movement, intended to be hooked to the 'axis.N.jog-counts' pins.

Files currently attached to this page:

mousejog.py1.3kB
hal_feedoverride_wheel.py1.4kB



Entry first conceived on 4 August 2006, 15:28 UTC, last modified on 4 August 2006, 15:46 UTC



Copyright © 2004-2009 Jeff Epler
[æ]