KX3.INI configuration file |
Sample KX3.INI configuration file |
INTRO_TIME = 5 |
INTRO_TIME = 2 |
BASE_PERIOD = 29000 SERVO_PERIOD = 1000000 |
BASE_PERIOD = 30000 SERVO_PERIOD = 600000 |
MAX_ACCELERATION = 200.0 STEPGEN_MAXACCEL = 250.0 |
MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 |
HOME_SEARCH_VEL = -30.000000 HOME_LATCH_VEL = 1.000000 |
HOME_SEARCH_VEL = -50.000000 HOME_LATCH_VEL = 5.000000 |
MAX_ACCELERATION = 200.0 STEPGEN_MAXACCEL = 250.0 |
MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 |
HOME_SEARCH_VEL = -30.000000 HOME_LATCH_VEL = 1.000000 |
HOME_SEARCH_VEL = -50.000000 HOME_LATCH_VEL = 5.000000 |
MAX_ACCELERATION = 200.0 STEPGEN_MAXACCEL = 250.0 |
MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 |
HOME_SEARCH_VEL = 40.000000 HOME_LATCH_VEL = -1.000000 |
HOME_SEARCH_VEL = 50.000000 HOME_LATCH_VEL = -5.000000 |
|
KX3.HAL configuration file |
Sample KX3.HAL configuration file |
* This file was originally created using STEPCONF, and then modified to resolve the ESTOP issue. * Todo: I am currently cheating, and tricking the KX3 mill to run with a PWM spindle config (which works). The proper way is to add a 5th step generator for the spindle. |
* This file was originally created using STEPCONF, and then modified to resolve the ESTOP issue and to add a 5th stepper generator controlling the spindle. |
|
loadrt stepgen step_type=0,0,0 |
loadrt stepgen step_type=0,0,0,0,0 ctrl_type=p,p,p,p,v |
net estop-out iocontrol.0.user-enable-out |
loadrt scale net estop-out iocontrol.0.user-enable-out #Charge pump must not be connected to ESTOP! |
loadrt pwmgen output_type=0 |
|
addf pwmgen.make-pulses base-thread |
addf pwmgen.update servo-thread |
net spindle-cmd <= motion.spindle-speed-out => pwmgen.0.value net spindle-enable <= motion.spindle-on => pwmgen.0.enable net spindle-pwm <= pwmgen.0.pwm setp pwmgen.0.pwm-freq 500.0 setp pwmgen.0.scale 47500.0 setp pwmgen.0.offset 0.00789473684211 setp pwmgen.0.dither-pwm true net spindle-cw <= motion.spindle-forward |
setp scale.0.in 0 # adjust spindle speed here if required setp scale.0.gain 0.9 # The suggested gain was not scientifically tested, but based on the motor speed maxing out at approx S3500, which is the theoretical maximum for a KX3. setp scale.0.offset -50 # A negative offset appears to yield the best results for low speeds allowing for approx 60 rpm at S60. addf scale.0 servo-thread setp stepgen.4.position-scale 1 setp stepgen.4.maxvel 3500 # maximum for standard KX3 setp stepgen.4.steplen 1 setp stepgen.4.stepspace 0 setp stepgen.4.dirhold 20000 setp stepgen.4.dirsetup 20000 setp stepgen.4.maxaccel 2000 net spindle-enable <= motion.spindle-on => stepgen.4.enable net spindle-cmd motion.spindle-speed-out => scale.0.in net spindle-freq <= scale.0.out => stepgen.4.velocity-cmd net spindle-out <= stepgen.4.step => parport.0.pin-14-out net spindle-cw => parport.0.pin-16-out |
setp parport.0.pin-01-out-invert 1 net spindle-cw => parport.0.pin-01-out |
net spindle-pwm => parport.0.pin-14-out |
|
The KX3 is a relatively common mini-mill available through several distributors, including Arc Eurotrade [1] and Harbor Freight [2]
The purpose of this howto is to provide sufficient information to allow KX3 owners to control their mill using EMC2. This howto is not complete, and should be considered guidance only.
[EMC] MACHINE = KX3 NML_FILE = emc.nml DEBUG = 0 [DISPLAY] DISPLAY = axis EDITOR = gedit POSITION_OFFSET = RELATIVE POSITION_FEEDBACK = ACTUAL MAX_FEED_OVERRIDE = 1.2 INTRO_GRAPHIC = emc2.gif INTRO_TIME = 2 PROGRAM_PREFIX = /home/USERNAME/emc2/nc_files INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm PYVCP = panel.xml [TASK] TASK = milltask CYCLE_TIME = 0.010 [RS274NGC] PARAMETER_FILE = emc.var [EMCMOT] EMCMOT = motmod SHMEM_KEY = 111 COMM_TIMEOUT = 1.0 COMM_WAIT = 0.010 BASE_PERIOD = 30000 SERVO_PERIOD = 600000 [HAL] HALFILE = KX3.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 = 7.00 MAX_LINEAR_VELOCITY = 70.00 [EMCIO] EMCIO = io CYCLE_TIME = 0.100 TOOL_TABLE = tool.tbl [AXIS_0] TYPE = LINEAR HOME = 0.0 MAX_VELOCITY = 65.5172413793 MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 SCALE = 500.0 FERROR = 1 MIN_FERROR = .25 MIN_LIMIT = -2.5 MAX_LIMIT = 280.0 HOME_OFFSET = -3.000000 HOME_SEARCH_VEL = -50.000000 HOME_LATCH_VEL = 5.000000 HOME_IGNORE_LIMITS = YES HOME_SEQUENCE = 1 [AXIS_1] TYPE = LINEAR HOME = 0.0 MAX_VELOCITY = 65.5172413793 MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 SCALE = 500.0 FERROR = 1 MIN_FERROR = .25 MIN_LIMIT = -2.5 MAX_LIMIT = 110.0 HOME_OFFSET = -3.000000 HOME_SEARCH_VEL = -50.000000 HOME_LATCH_VEL = 5.000000 HOME_IGNORE_LIMITS = YES HOME_SEQUENCE = 2 [AXIS_2] TYPE = LINEAR HOME = 275.0 MAX_VELOCITY = 65.5172413793 MAX_ACCELERATION = 400.0 STEPGEN_MAXACCEL = 500.0 SCALE = 500.0 FERROR = 1 MIN_FERROR = .25 MIN_LIMIT = 0.0 MAX_LIMIT = 275.001 HOME_OFFSET = 275.000000 HOME_SEARCH_VEL = 50.000000 HOME_LATCH_VEL = -5.000000 HOME_IGNORE_LIMITS = YES HOME_SEQUENCE = 0
loadrt trivkins loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES loadrt probe_parport loadrt hal_parport cfg=0x378 setp parport.0.reset-time 3000 loadrt stepgen step_type=0,0,0,0,0 ctrl_type=p,p,p,p,v loadrt charge_pump loadrt scale net estop-out iocontrol.0.user-enable-out #Charge pump must not be connected to ESTOP! net charge-pump <= charge-pump.out addf parport.0.read base-thread addf stepgen.make-pulses base-thread addf charge-pump base-thread addf parport.0.write base-thread addf parport.0.reset 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 setp scale.0.in 0 # adjust spindle speed here if required setp scale.0.gain 0.9 # The suggested gain was not scientifically tested, but based on the motor speed maxing out at approx S3500, which is the theoretical maximum for a KX3. setp scale.0.offset -50 # A negative offset appears to yield the best results for low speeds allowing for approx 60 rpm at S60. addf scale.0 servo-thread setp stepgen.4.position-scale 1 setp stepgen.4.maxvel 3500 # maximum for standard KX3 setp stepgen.4.steplen 1 setp stepgen.4.stepspace 0 setp stepgen.4.dirhold 20000 setp stepgen.4.dirsetup 20000 setp stepgen.4.maxaccel 2000 net spindle-enable <= motion.spindle-on => stepgen.4.enable net spindle-cmd motion.spindle-speed-out => scale.0.in net spindle-freq <= scale.0.out => stepgen.4.velocity-cmd net spindle-out <= stepgen.4.step => parport.0.pin-14-out net spindle-cw => parport.0.pin-16-out net xstep => parport.0.pin-02-out setp parport.0.pin-02-out-reset 1 net xdir => parport.0.pin-03-out net ystep => parport.0.pin-04-out setp parport.0.pin-04-out-reset 1 net ydir => parport.0.pin-05-out net zstep => parport.0.pin-06-out setp parport.0.pin-06-out-reset 1 net zdir => parport.0.pin-07-out net astep => parport.0.pin-08-out setp parport.0.pin-08-out-reset 1 net adir => parport.0.pin-09-out setp parport.0.pin-14-out-invert 1 net charge-pump => parport.0.pin-17-out net estop-ext <= parport.0.pin-10-in net both-home-x <= parport.0.pin-11-in-not net both-home-y <= parport.0.pin-12-in-not net both-home-z <= parport.0.pin-13-in-not setp stepgen.0.position-scale [AXIS_0]SCALE setp stepgen.0.steplen 1 setp stepgen.0.stepspace 0 setp stepgen.0.dirhold 40000 setp stepgen.0.dirsetup 21000 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 both-home-x => axis.0.home-sw-in net both-home-x => axis.0.neg-lim-sw-in net both-home-x => axis.0.pos-lim-sw-in setp stepgen.1.position-scale [AXIS_1]SCALE setp stepgen.1.steplen 1 setp stepgen.1.stepspace 0 setp stepgen.1.dirhold 40000 setp stepgen.1.dirsetup 21000 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 both-home-y => axis.1.home-sw-in net both-home-y => axis.1.neg-lim-sw-in net both-home-y => axis.1.pos-lim-sw-in setp stepgen.2.position-scale [AXIS_2]SCALE setp stepgen.2.steplen 1 setp stepgen.2.stepspace 0 setp stepgen.2.dirhold 40000 setp stepgen.2.dirsetup 21000 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 both-home-z => axis.2.home-sw-in net both-home-z => axis.2.neg-lim-sw-in net both-home-z => 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
That's it! You should now have basic control of the three axes and the spindle from EMC2. It is advisable to do all initial testing with a "safe" Z-axis height, and with one hand close to the emergency stop.
This page was originally written by Thorium?. Feel free to improve the content, or contact me if you would like to discuss.