loadrt [KINS]KINEMATICS
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=[KINS]JOINTS
loadrt hal_parport cfg=0x378
setp parport.0.reset-time 4000
loadrt stepgen step_type=0,0,0,0
loadrt charge_pump
loadrt match8 count=1

loadrt pwmgen output_type=1
setp pwmgen.0.pwm-freq 5.0
#4000 RPM spindles (early production)
setp pwmgen.0.scale 4000
#5000 RPM spindles (late production)
#setp pwmgen.0.scale 5000
setp pwmgen.0.offset 0.0
setp pwmgen.0.min-dc 0.01
setp pwmgen.0.max-dc 0.99
setp pwmgen.0.dither-pwm true

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf charge-pump base-thread
addf pwmgen.make-pulses 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
addf pwmgen.update servo-thread
addf match8.0 servo-thread

net spindle-cmd spindle.0.speed-out pwmgen.0.value
net spindle-enable spindle.0.on pwmgen.0.enable

net coolant-flood parport.0.pin-01-out iocontrol.0.coolant-flood
net xdir parport.0.pin-02-out stepgen.0.dir
net xstep parport.0.pin-03-out stepgen.0.step
setp parport.0.pin-03-out-reset 1
net ydir parport.0.pin-04-out stepgen.1.dir
net ystep parport.0.pin-05-out stepgen.1.step
setp parport.0.pin-05-out-reset 1
net zdir parport.0.pin-06-out stepgen.2.dir
net zstep parport.0.pin-07-out stepgen.2.step
setp parport.0.pin-07-out-reset 1
net adir parport.0.pin-08-out stepgen.3.dir
net astep parport.0.pin-09-out stepgen.3.step
setp parport.0.pin-09-out-reset 1
#PMDX-110
net spindle-dir parport.0.pin-14-out spindle.0.reverse
#PMDX-131
#net spindle-dir parport.0.pin-14-out spindle.0.forward
net spindle-pwm parport.0.pin-16-out pwmgen.0.pwm
net charge-pump parport.0.pin-17-out charge-pump.out
net estop-in parport.0.pin-10-in-not iocontrol.0.emc-enable-in
net estop-out charge-pump.enable halui.machine.is-on
#PMDX-110
net run parport.0.pin-11-in-not halui.program.pause motion.feed-hold
#PMDX-131
#net run parport.0.pin-11-in halui.program.pause motion.feed-hold
#normally closed switches (late production)
net all-home parport.0.pin-12-in
#normally open switches (early production)
#net all-home parport.0.pin-12-in-not

setp stepgen.0.position-scale [JOINT_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 35000
setp stepgen.0.dirsetup 16000
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
net xpos-cmd joint.0.motor-pos-cmd stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb joint.0.motor-pos-fb
net xenable joint.0.amp-enable-out stepgen.0.enable
net all-home joint.0.home-sw-in

setp stepgen.1.position-scale [JOINT_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 35000
setp stepgen.1.dirsetup 16000
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
net ypos-cmd joint.1.motor-pos-cmd stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb joint.1.motor-pos-fb
net yenable joint.1.amp-enable-out stepgen.1.enable
net all-home joint.1.home-sw-in

setp stepgen.2.position-scale [JOINT_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 35000
setp stepgen.2.dirsetup 16000
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL
net zpos-cmd joint.2.motor-pos-cmd stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb joint.2.motor-pos-fb
net zenable joint.2.amp-enable-out stepgen.2.enable
net all-home joint.2.home-sw-in

setp stepgen.3.position-scale [JOINT_3]SCALE
setp stepgen.3.steplen 1
setp stepgen.3.stepspace 0
setp stepgen.3.dirhold 35000
setp stepgen.3.dirsetup 16000
setp stepgen.3.maxaccel [JOINT_3]STEPGEN_MAXACCEL
net apos-cmd joint.3.motor-pos-cmd stepgen.3.position-cmd
net apos-fb stepgen.3.position-fb joint.3.motor-pos-fb
net aenable joint.3.amp-enable-out stepgen.3.enable

newsig false bit
sets false FALSE
net xhoming joint.0.homing match8.0.a0
net yhoming joint.1.homing match8.0.a1
net zhoming joint.2.homing match8.0.a2
net false match8.0.b0 match8.0.b1 match8.0.b2
net all-home match8.0.in
net limit match8.0.out joint.0.neg-lim-sw-in

# These loopbacks are usually disconnected by a postgui halfile
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
net tool-prepare-loopback iocontrol.0.tool-prepare iocontrol.0.tool-prepared
