"basic" mpg setup

More
29 Dec 2019 16:49 - 07 Jan 2020 22:25 #153455 by polobear189
Hello fellow linux cncers

Im trying to setup an mpg on my machine, using the only mpg example on the linux cnc docs, pasted into custom.hal file. Only the bare minimum has been changed but i cannot for anything get this to work, its like the 2nd pport is not being read properly, the read and write lines for both pports exist in the main hal file

Machine is setup with the main pport (0x378) - the onboard port - as out mode, this is for all machine signals

mpg is on the pci port (0x4010) set to in mode

when running stepconf the 2nd pport has all signals set to unused, the options to set mpg-a and mpg-b etc do not exist, when starting linuxcnc and custom.hal is read, i would have assumed this would overwrite stepconf setup or do these specific inputs need to be changed here too?

i have verified the signals mpg-a and mpg-b are getting to the BOB with an oscilliscope, my mpg is putting out a quadrature signal

the mpg is receiving 5v an ground from the BOB(pc 5v and ground)

the signals to select the axis (pins 4,5,6) 4 is being held at 0v while the other 2 are at 5v, so x should be selected.

im not too sure i understand inputs on 9 and 10, but 9 is being held at 0v and 10 is at 5v, thought it was just another 3 position selector switch to select multiplication units

i have swapped the pports to verify both are working (put the machine control on 0x4010 and mpg on 0x378) machine control and signals work fine when swapped but again mpg nothing happens.

having a look in show hal config> pins> parport>1>

i can see all the relevant pins but none are changing state, but then when the BOB is powered down (loses the 5v from the pc) they do change state. so its like something in the config is not allowing the pport 2 to be read.

i have included my main hal file and ini and custom.hal

no idea what to try next hopefully someone out there can help!

many thanks!
Andy
my-mill.ini
# Generated by stepconf 1.1 at Sun Dec 29 14:55:24 2019
# If you make changes to this file, they will be
# overwritten when you run stepconf again

[EMC]
MACHINE = my-mill
DEBUG = 0

[DISPLAY]
DISPLAY = axis
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
ARCDIVISION = 64
GRIDS = 10mm 20mm 50mm 100mm 1in 2in 5in 10in
MAX_FEED_OVERRIDE = 1.2
MIN_SPINDLE_OVERRIDE = 0.5
MAX_SPINDLE_OVERRIDE = 1.2
DEFAULT_LINEAR_VELOCITY = 4.00
MIN_LINEAR_VELOCITY = 0
MAX_LINEAR_VELOCITY = 40.00
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/cnc/linuxcnc/nc_files
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python

[TASK]
TASK = milltask
CYCLE_TIME = 0.010

[RS274NGC]
PARAMETER_FILE = linuxcnc.var

[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 42500
SERVO_PERIOD = 1000000

[HAL]
HALFILE = my-mill.hal
HALFILE = custom.hal
POSTGUI_HALFILE = custom_postgui.hal

[TRAJ]
AXES = 3
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 4.00
MAX_VELOCITY = 40.00

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

[AXIS_0]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 27.9411764706
MAX_ACCELERATION = 250.0
STEPGEN_MAXACCEL = 312.5
SCALE = 400.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -500.0
MAX_LIMIT = 500.0
HOME_OFFSET = 0.0

[AXIS_1]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 34.9264705882
MAX_ACCELERATION = 250.0
STEPGEN_MAXACCEL = 312.5
SCALE = 320.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -400.0
MAX_LIMIT = 400.0
HOME_OFFSET = 0.0

[AXIS_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 34.9264705882
MAX_ACCELERATION = 250.0
STEPGEN_MAXACCEL = 312.5
SCALE = 320.0
FERROR = 1
MIN_FERROR = .25
MIN_LIMIT = -300.0
MAX_LIMIT = 300.0
HOME_OFFSET = 0.0
my-mill.hal
# Generated by stepconf 1.1 at Sun Dec 29 14:55:24 2019
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hal_parport cfg="0x378 0x4010 in"
loadrt stepgen step_type=0,0,0

addf parport.0.read base-thread
addf parport.1.read base-thread
addf stepgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.1.write base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
net spindle-cmd-rpm     <= motion.spindle-speed-out
net spindle-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-cmd-rps     <= motion.spindle-speed-out-rps
net spindle-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-at-speed    => motion.spindle-at-speed

net estop-out       => parport.0.pin-01-out
net xstep           => parport.0.pin-02-out
net xdir            => parport.0.pin-03-out
setp parport.0.pin-04-out-invert 1
net ystep           => parport.0.pin-04-out
setp parport.0.pin-05-out-invert 1
net ydir            => parport.0.pin-05-out
net zstep           => parport.0.pin-06-out
net zdir            => parport.0.pin-07-out


net estop-ext       <= parport.0.pin-13-in-not
net all-limit       <= parport.0.pin-15-in



setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 1
setp stepgen.0.dirhold 37500
setp stepgen.0.dirsetup 37500
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable
net all-limit => axis.0.neg-lim-sw-in
net all-limit => axis.0.pos-lim-sw-in

setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 1
setp stepgen.1.dirhold 37500
setp stepgen.1.dirsetup 37500
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable
net all-limit => axis.1.neg-lim-sw-in
net all-limit => axis.1.pos-lim-sw-in

setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 1
setp stepgen.2.dirhold 37500
setp stepgen.2.dirsetup 37500
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable
net all-limit => axis.2.neg-lim-sw-in
net all-limit => axis.2.pos-lim-sw-in

net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared

custom.hal
# Include your customized HAL commands here
# This file will not be overwritten when you run stepconf again
    # Jog Pendant 
loadrt encoder num_chan=1 
loadrt mux4 count=1 
addf encoder.capture-position servo-thread 
addf encoder.update-counters base-thread 
addf mux4.0 servo-thread

# If your MPG outputs a quadrature 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 to 1
# In velocity mode the axis stops when the dial is stopped
# even if that means the commanded motion is not completed,
# For position mode (the default), set to 0
# In position mode the axis will move exactly jog-scale
# units for each count, regardless of how long that might take,
setp axis.0.jog-vel-mode 0
setp axis.1.jog-vel-mode 0
setp axis.2.jog-vel-mode 0

# This sets the scale that will be used based on the input to the mux4
setp mux4.0.in0 0.1
setp mux4.0.in1 0.01
setp mux4.0.in2 0.001

# The inputs to the mux4 component
net scale1 mux4.0.sel0 <= parport.1.pin-09-in
net scale2 mux4.0.sel1 <= parport.1.pin-10-in

# The output from the mux4 is sent to each axis jog scale
net mpg-scale <= mux4.0.out
net mpg-scale => axis.0.jog-scale
net mpg-scale => axis.1.jog-scale
net mpg-scale => axis.2.jog-scale

# The MPG inputs
net mpg-a encoder.0.phase-A <= parport.1.pin-02-in
net mpg-b encoder.0.phase-B <= parport.1.pin-03-in

# The Axis select inputs
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

# The encoder output counts to the axis. Only the selected axis will move.
net encoder-counts  <= encoder.0.counts
net encoder-counts => axis.0.jog-counts
net encoder-counts => axis.1.jog-counts
net encoder-counts => axis.2.jog-counts
Last edit: 07 Jan 2020 22:25 by andypugh.

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

More
29 Dec 2019 17:03 #153458 by Clive S
Replied by Clive S on topic "basic" mpg setup
I think you have the mpg's connected to outputs. Inputs are 10-13 +15

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

More
29 Dec 2019 17:18 #153461 by polobear189
Replied by polobear189 on topic "basic" mpg setup
Do you mean the pport? Pport 2 is set to IN mode

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

More
29 Dec 2019 17:44 #153464 by Clive S
Replied by Clive S on topic "basic" mpg setup

Do you mean the pport? Pport 2 is set to IN mode


Yes sorry I missed that in the hal file . But not all PP's can do that !!

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

More
29 Dec 2019 21:49 #153513 by polobear189
Replied by polobear189 on topic "basic" mpg setup
Thanks for the suggestion, seems to make sense because there is only changing inputs on pin 10 (which is the only valid input in OUT mode) none of the other pins change state. So I will change both cards to OUT mode.

Does anyone know if the mpg inputs can be spread across two pports in OUT mode? Not enough inputs!

Seems like my Bob has 3 separate grounds, 24v, pc gnd and signal gnd in to the optos. So maybe the mpg needs the signal ground instead of pc ground?

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

More
29 Dec 2019 22:57 #153524 by tommylight
Replied by tommylight on topic "basic" mpg setup
Use the built in port for inputs, the add on for outputs.
All add on cards do output, not all of them will do inputs or X mode.

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

More
29 Dec 2019 23:15 #153527 by Clive S
Replied by Clive S on topic "basic" mpg setup

Does anyone know if the mpg inputs can be spread across two pports in OUT mode? Not enough inputs!


Yes. I have done it in the past with mpg's just using A + B one mpg on each Pport.
The following user(s) said Thank You: polobear189

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

More
12 Jan 2020 23:55 #154730 by polobear189
Replied by polobear189 on topic "basic" mpg setup
There were two problems

Multiple isolated grounds on the pport breakout board - pcgnd, signal to drivers gnd,24v gnd

MPG signal verified with oscilliscope at the input was giving a quadrature signal but it had no reference to the signal ground, couldnt see the signal in Linux cnc diagnostics windows either

I have spread the inputs across 2 pports set to OUT mode, i think the MOSCHIP pport card i have can be set to IN mode but make sure your BOB can support this!

Now to get M30 counters and cycle timers working...

Thanks for all the help!
:silly:

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

Time to create page: 0.158 seconds
Powered by Kunena Forum