loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]TRAJ_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[KINS]JOINTS
loadrt stepgen step_type=0,0,0
loadrt match8 count=1
# Used to filter out spurious limit switch signals
# THIS IS VERY BAD & SHOULD BE FIXED IN HARDWARE!!!
loadrt debounce cfg=1
setp debounce.0.delay 2
loadrt hal_parport cfg="0x378"

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

addf stepgen.capture-position servo-thread
addf match8.0 servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread

net Xpos-cmd joint.0.motor-pos-cmd stepgen.0.position-cmd
net Ypos-cmd joint.1.motor-pos-cmd stepgen.1.position-cmd
net Zpos-cmd joint.2.motor-pos-cmd stepgen.2.position-cmd

net Xpos-fb stepgen.0.position-fb joint.0.motor-pos-fb
net Ypos-fb stepgen.1.position-fb joint.1.motor-pos-fb
net Zpos-fb stepgen.2.position-fb joint.2.motor-pos-fb

net Xen <= joint.0.amp-enable-out stepgen.0.enable
net Yen <= joint.1.amp-enable-out stepgen.1.enable
net Zen <= joint.2.amp-enable-out stepgen.2.enable

net Xstep stepgen.0.step parport.0.pin-03-out
net Xdir stepgen.0.dir parport.0.pin-02-out
net Ystep stepgen.1.step parport.0.pin-05-out
net Ydir stepgen.1.dir parport.0.pin-04-out
net Zstep stepgen.2.step parport.0.pin-07-out
net Zdir stepgen.2.dir parport.0.pin-06-out

setp stepgen.0.position-scale [JOINT_0]SCALE
setp stepgen.1.position-scale [JOINT_1]SCALE
setp stepgen.2.position-scale [JOINT_2]SCALE
setp stepgen.0.maxvel [JOINT_0]STEPGEN_MAXVEL
setp stepgen.1.maxvel [JOINT_1]STEPGEN_MAXVEL
setp stepgen.2.maxvel [JOINT_2]STEPGEN_MAXVEL
setp stepgen.0.maxaccel [JOINT_0]STEPGEN_MAXACCEL
setp stepgen.1.maxaccel [JOINT_1]STEPGEN_MAXACCEL
setp stepgen.2.maxaccel [JOINT_2]STEPGEN_MAXACCEL

# three axis motion allows 6 other outputs on pins 8,9,1,14,16,17
# five additional input pins are available 10,11,12,13,15

setp parport.0.pin-01-out-invert true
net estop iocontrol.0.user-enable-out parport.0.pin-01-out iocontrol.0.emc-enable-in

setp parport.0.pin-14-out-invert true
net flood iocontrol.0.coolant-flood parport.0.pin-14-out

setp parport.0.pin-17-out-invert true
net forward spindle.0.forward parport.0.pin-16-out
net reverse spindle.0.reverse parport.0.pin-17-out

# 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

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 home-raw parport.0.pin-15-in-not debounce.0.0.in
net home-filtered debounce.0.0.out joint.0.home-sw-in joint.1.home-sw-in joint.2.home-sw-in match8.0.in
net limit match8.0.out joint.0.neg-lim-sw-in

