MPG2 Jog Pendant

For Christmas 2009, Kelly bought me a MPG2 Jog Pendant and C22 adapter board for my CNC Router.  I finished integrating it into my EMC2 setup, and it’s working great!  There is some documentation on the web for hooking these up, but the guides I’ve seen have all stopped with 3 axis support, and didn’t do anything with the neat little LED built into it, so I broke out the HAL docs to get it all working.  I imagine I’m not the only one that would like to use these with 4-axis setups, so I’ll share my integration experience here.

My starting point was this excellent guide on the EMC2 wiki: http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Hooking_Up_A_MPG_Pendant

Using the HAL example from above the scale multiplier was backwards, the 4th axis didn’t work, and the LED didn’t do anything, but it was a great starting point because the X,Y, and Z axis jogging worked great.  Modifying the HAL like my custom config below below solves the 4th axis, LED, and multiplier problems assuming you’re also using the MPG2/C22 combination I am.  But, similar configurations should be easy to adapt by substituting the appropriate pins where appropriate.

Critical to getting this working smoothly for me was to add a multiplier for my A axis.  Using the default jog scale would be far too slow in degrees, so I added a multiplier HAL component to get the Z to jog at an appropriate rate.  I also wanted finer control on the X, Y, and Z, so the end result was setting my X, Y, and Z rates at .01″, .001″, and .0001″, and adding a x100 multiplier for A, giving me rates of 1°, .1°, and .01°.

Finally, to get the LED to work I used the LUT5 HAL component configured as an OR gate hooked into the X, Y, Z, and A axis enable signals.  The output of the LUT5 then gets tied to the LED output.  Now, when I have an axis selected and I push the enable button, the LED lights up.  Yay!

So, without further ado, here’s my custom.hal:

# Jog Pendant
loadrt encoder num_chan=1
loadrt mux4 count=1
loadrt mult2 count=1
loadrt lut5 count=1

addf encoder.capture-position servo-thread
addf encoder.update-counters base-thread
addf mux4.0 servo-thread
addf mult2.0 servo-thread
addf lut5.0 servo-thread

# If your MPG outputs a quadture signal per click set x4 to 1
# If your MPG puts out 1 pulse per click set x4 to 0
setp encoder.0.x4-mode 0

# For velocity mode, set n to 1
# In velocity mode the axis stops when dial is stopped even if that means
# the commanded motion is not completed,
# For position mode (the default), set n to 0
# In position mode the axis will move exactly jog-scale
# units for each count, regardless of how long that might take,
# This must be set for each axis you want to behave other than default
setp axis.0.jog-vel-mode 0
setp axis.1.jog-vel-mode 0
setp axis.2.jog-vel-mode 0
setp axis.3.jog-vel-mode 0
setp mux4.0.in0 0.01
setp mux4.0.in1 0.001
setp mux4.0.in2 0.0001
setp mult2.0.in0 100
net scale1 mux4.0.sel0 <= parport.1.pin-09-in
net scale2 mux4.0.sel1 <= parport.1.pin-08-in
net pend-scale axis.0.jog-scale <= mux4.0.out
net pend-scale axis.1.jog-scale
net pend-scale axis.2.jog-scale
net pend-scale mult2.0.in1
net rot-scale axis.3.jog-scale <= mult2.0.out
net mpg-a encoder.0.phase-A <= parport.1.pin-02-in
net mpg-b encoder.0.phase-B <= parport.1.pin-03-in
net mpg-x axis.0.jog-enable <= parport.1.pin-04-in
net mpg-y axis.1.jog-enable <= parport.1.pin-05-in
net mpg-z axis.2.jog-enable <= parport.1.pin-06-in
net mpg-4 axis.3.jog-enable <= parport.1.pin-07-in
net pend-counts axis.0.jog-counts <= encoder.0.counts
net pend-counts axis.1.jog-counts
net pend-counts axis.2.jog-counts
net pend-counts axis.3.jog-counts

# Turn on the jog led if any jog axis is enabled
setp lut5.0.function 0x116
net mpg-x lut5.0.in-0
net mpg-y lut5.0.in-1
net mpg-z lut5.0.in-2
net mpg-4 lut5.0.in-3
setp lut5.0.in-4 0
net jog-on parport.1.pin-01-out <= lut5.0.out

Print This Page Print This Page

3 Comments

  1. MPG2 Pendant Integrated! | chembal.com says:

    [...] new MPG2 Jog Pendant! Some of the EMC2 HAL integration work took a little thinking, so I made a new MPG2 Jog Pendant page to get other similarly inclined EMC2 users up and running with all 4 axes. Now, if I could [...]

  2. EMC + Pendant - CNCzone.com-The Largest Machinist Community on the net! says:

    [...] because I only have a two axis machine, X and Z) and cut and pasted into the custom.hal file: MPG2 Jog Pendant | chembal.com [...]

  3. adding 2nd pport - CNCzone.com-The Largest Machinist Community on the net! says:

    [...] par port for a pendant or a fourth axis? LinuxCNC Documentation Wiki: Hooking Up A MPG Pendant MPG2 Jog Pendant | chembal.com function hidestatus(){ window.status='' return true } if (document.layers) [...]

Leave a Reply

reCAPTCHA-uitdagingsafbeelding
Een nieuwe uitdaging proberen Een audio-uitdaging proberenEen visuele uitdaging proberen Help