# standard pinout config file for 3-axis steppers
# using a parport for I/O
#
# first load the parport driver
loadrt hal_parport cfg="0x0378"
# counting the spindle encoder in software
loadrt encoder num_chan=1
# misc blocks needed to do fun things
loadrt blocks not=1
#
# next connect the parport functions to threads
# read inputs first
addf parport.0.read base-thread 1
# update encoder counter
# capture axis and spindle positions
addf encoder.capture-position servo-thread
# other misc blocks
addf not.0 servo-thread
addf encoder.update-counters base-thread
# write outputs last
addf parport.0.write base-thread -1
#
# finally connect physical pins to the signals
linksp Xstep parport.0.pin-03-out
linksp Xdir parport.0.pin-02-out
linksp Zstep parport.0.pin-05-out
linksp Zdir parport.0.pin-04-out
linksp Ystep parport.0.pin-07-out
linksp Ydir parport.0.pin-06-out
# create a signal for the estop loopback
linkpp iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool loading loopback
linkpp iocontrol.0.tool-prepare iocontrol.0.tool-prepared
linkpp iocontrol.0.tool-change iocontrol.0.tool-changed
# create a signal for "spindle on"
newsig spindle_on bit
# commented out till we resolve this issue
# connect it to the iocontroller
linksp spindle_on iocontrol.0.spindle-on
# connect it to a physical pin
linksp spindle_on parport.0.pin-09-out
#######################################################
# Beginning of threading-related stuff
#######################################################
# spindle encoder
# connect encoder signals to encoder counter
newsig spindle-phase-A bit
newsig spindle-phase-B bit
newsig spindle-phase-Z bit
linksp spindle-phase-A => encoder.0.phase-A
linksp spindle-phase-B => encoder.0.phase-B
linksp spindle-phase-Z => encoder.0.phase-Z
linkps parport.0.pin-11-in => spindle-phase-A
linkps parport.0.pin-12-in => spindle-phase-B
linkps parport.0.pin-13-in => spindle-phase-Z
# (that way thread pitches can be straightforward,
# a 20 tpi thread would multiply the encoder output
# by 1/20, etc)
setp encoder.0.position-scale 1000
# encoder reset control
# this signal is driven by the motion
# controller, TRUE for synced motion, FALSE the rest of
# the time.
#
# hook up motion controller's sync output
newsig spindle-sync bit
linkps motion.spindle-sync => spindle-sync
# needs to be inverted to connect to index enable
newsig spindle-index-en bit
linksp spindle-sync => not.0.in
linkps not.0.out => spindle-index-en
linksp spindle-index-en => encoder.0.index-enable
# report our revolution count to the motion controller
newsig spindle-pos float
linkps encoder.0.position => spindle-pos
linksp spindle-pos => motion.spindle-revs