MPG Handwheel - how to make it operate when linuxCNC/axis not homed

More
07 Dec 2022 23:18 #258844 by frogandspanner
I have set up and MPG handwheel based on wiki.linuxcnc.org/cgi-bin/wiki.pl?Hooking_Up_A_MPG_Pendant

It works when linuxCNC/axis (2.8.4-1) is homed, but not otherwise, which is suboptimal.

I have been trying to adopt techniques used in wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant, but all that this has done is revealed my ignorance.

What mods do I need to make for it to work when unhomed?

Here is my modified version:
# MPG-wheel.hal

# MPG Wheel for X-axis
#
# Based on wiki.linuxcnc.org/cgi-bin/wiki.pl?Hooking_Up_A_MPG_Pendant
#
# Uses //port pins 10(phase A) and 11 (phase B) as inputs from wheel.
# No other //port pins are used - so bodge by setting explicitly

 loadrt encoder num_chan=1
 loadrt mux4 names=MPGmux4

 addf encoder.capture-position servo-thread
 addf encoder.update-counters base-thread
 addf MPGmux4 servo-thread

 # for absolute mode (for every click you get a move ie,
 # if you spin the dial it may keep moving after you stop the dial)
 # default so does not need to be set
 setp axis.x.jog-vel-mode 0

 # for velocity mode (when you stop spinning the dial the axis stops)
 # must be set for each axis
 setp axis.x.jog-vel-mode 1

#TC - set axis to jog when jog-counts changes (this originally came from a //port pin)
 setp axis.x.jog-enable TRUE

 # "times 4 mode" one count per full quadrature cycle, instead of the usual one count per edge.  
 # mpg jog wheels often have a full quadrature cycle per "click". 0 for off and 1 for on.
 setp encoder.0.x4-mode 0

# The original used pin inputs to select the jog scale - just bodge a single one.
 setp MPGmux4.in0 0.1
 setp MPGmux4.in1 0.01
 setp MPGmux4.in2 0.001


 net scale1 MPGmux4.sel0
 net scale2 MPGmux4.sel1

# Temporary bodge to select MPGmux4.in0
 sets scale1 0
 sets scale2 0

 net pend-scale axis.x.jog-scale <= MPGmux4.out

 net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
 net mpg-b encoder.0.phase-B <= parport.0.pin-11-in

 net pend-counts axis.x.jog-counts <= encoder.0.counts

 

Please Log in or Create an account to join the conversation.

More
07 Dec 2022 23:53 #258848 by PCW
To jog before you have homed, you need to jog joints,
not axis. This means the joint jogging pins must connect
to the same signals as the axis jogging pins.
In addition, I believe you must enable either joint or axis
jogging via the appropriate enable pins as determined by the
home status (homed or unhomed)

"man motion" for the pin names

Please Log in or Create an account to join the conversation.

More
08 Dec 2022 01:50 #258864 by JPL

...  I believe you must enable either joint or axis
jogging via the appropriate enable pins ...
 


You can also simply enable both at the same time. This will work homed or not  (i.e. joint or teleop modes). See example here: forum.linuxcnc.org/39-pncconf/46660-mpg-...lved?start=10#249925
 

Please Log in or Create an account to join the conversation.

More
08 Dec 2022 02:21 - 08 Dec 2022 02:30 #258866 by JPL
frogandspanner: Try adding the 3 red lines shown below. I believe this would work the way you want, although I'm far from being an expert. Also, you set axis.x.jog-vel-mode to 0 then to 1 right after that. I believe this would be better to comment one of the two lines.


 loadrt encoder num_chan=1
 loadrt mux4 names=MPGmux4

 addf encoder.capture-position servo-thread
 addf encoder.update-counters base-thread
 addf MPGmux4 servo-thread

 # for absolute mode (for every click you get a move ie,
 # if you spin the dial it may keep moving after you stop the dial)
 # default so does not need to be set
 setp axis.x.jog-vel-mode 0     <---- comment this line OR the one BELOW

 # for velocity mode (when you stop spinning the dial the axis stops)
 # must be set for each axis
 setp axis.x.jog-vel-mode 1    <--- Comment this line OR the one ABOVE

#TC - set axis to jog when jog-counts changes (this originally came from a //port pin)
 setp axis.x.jog-enable TRUE
 setp joint.0.jog-enable TRUE

 
# "times 4 mode" one count per full quadrature cycle, instead of the usual one count per edge.  
 # mpg jog wheels often have a full quadrature cycle per "click". 0 for off and 1 for on.
 setp encoder.0.x4-mode 0

# The original used pin inputs to select the jog scale - just bodge a single one.
 setp MPGmux4.in0 0.1
 setp MPGmux4.in1 0.01
 setp MPGmux4.in2 0.001


 net scale1 MPGmux4.sel0
 net scale2 MPGmux4.sel1

# Temporary bodge to select MPGmux4.in0
 sets scale1 0
 sets scale2 0

 net pend-scale axis.x.jog-scale <= MPGmux4.out
 net pend-scale joint.0.jog-scale

 net mpg-a encoder.0.phase-A <= parport.0.pin-10-in
 net mpg-b encoder.0.phase-B <= parport.0.pin-11-in

 net pend-counts axis.x.jog-counts <= encoder.0.counts
 net pend-counts joint.0.jog-counts
Last edit: 08 Dec 2022 02:30 by JPL.

Please Log in or Create an account to join the conversation.

More
08 Dec 2022 10:31 #258884 by frogandspanner
Thank you all.
It turned out that my modifed version was missing

setp joint.0.jog-enable TRUE

(although the contradictory setping of axis.x.jog-vel-mode had passed me by).

I had spent ages looking at what I had already done, and the problem had been staring me in the face. The problem might have been that as I have spread out other projects at home the only table space I can get is in the local pub, and hal goes squiffy after a pint or two of Peroni.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.075 seconds
Powered by Kunena Forum