# HAL config file for Vigilant Technologies Inc. VTI PCA board
#
# install driver (only needed if vti_motion.hal doesn't get run)
#loadrt hal_vti

# add I/O to servo thread so they will be evaluated
# every servo period
# read inputs first
addf vti.di-read servo-thread 1
# write outputs last
addf vti.do-write servo-thread -1

#uncomment following line if ADC's are needed (for example spindle-tach feedback)
#addf vti.0.read-adcs servo-thread 1

#
# Connect motion controller I/Os
#

# connect limit/home switch outputs to motion controller
#newsig Xminlim bit
#newsig Xmaxlim  bit
#newsig Xhome bit
#linksp Xminlim <= vti.in-02
#linksp Xminlim => joint.0.neg-lim-sw-in
#linksp Xmaxlim <= vti.in-01
#linksp Xmaxlim => joint.0.pos-lim-sw-in
#linksp Xhome <= vti.in-00
#linksp Xhome => joint.0.home-sw-in

#newsig Yminlim bit
#newsig Ymaxlim  bit
#newsig Yhome bit
#linksp Yminlim <= vti.in-06
#linksp Yminlim => joint.1.neg-lim-sw-in
#linksp Ymaxlim <= vti.in-05
#linksp Ymaxlim => joint.1.pos-lim-sw-in
#linksp Yhome <= vti.in-04
#linksp Yhome => joint.1.home-sw-in

#newsig Zminlim bit
#newsig Zmaxlim  bit
#newsig Zhome bit
#linksp Zminlim <= vti.in-10
#linksp Zminlim => joint.2.neg-lim-sw-in
#linksp Zmaxlim <= vti.in-09
#linksp Zmaxlim => joint.2.pos-lim-sw-in
#linksp Zhome <= vti.in-08
#linksp Zhome => joint.2.home-sw-in

#continue in the same manner for further axes (A,B,C)

# connect amp faults to motion controller
#newsig Xfault bit
#newsig Yfault  bit
#newsig Zfault bit
#linksp Xfault <= vti.in-03
#linksp Xfault => joint.0.amp-fault-in
#linksp Yfault <= vti.in-07
#linksp Yfault => joint.1.amp-fault-in
#linksp Zfault <= vti.in-11
#linksp Zfault => joint.2.amp-fault-in

# connect index pulses to motion controller
# do these when index pulsing is figured out
#newsig Xindex bit
#newsig Yindex  bit
#newsig Zindex bit
#linksp Xindex <= vti.0.enc-index
#linksp Xindex => joint.0.index-enable
#linksp Yindex <= vti.1.enc-index
#linksp Yindex => joint.1.index-enable
#linksp Zindex <= vti.2.enc-index
#linksp Zindex => joint.2.index-enable

# connect amp enables to motion controller
#linksp Xenable => vti.out-00
#linksp Yenable => vti.out-01
#linksp Zenable => vti.out-02

# connect watchdog reset to motion controller
# needs watchdo
#newsig WatchdogRst bit
#linksp WatchdogRst <= vti.watchdog-reset
#linksp WatchdogRst => motion.watchdog-reset-out


#
# Connect I/O controller I/Os
#

# connect e-stop write/sense to I/O controller
# these connections assume an external ESTOP circuitry will be used
# if it's not used, comment the next lines and uncomment the loopback
#newsig EstopSense bit
#newsig EstopWrite bit
#linksp EstopSense <= vti.in-12
#linksp EstopSense => iocontrol.0.emc-enable-in
#linksp EstopWrite <= vti.out-07
#linksp EstopWrite => iocontrol.0.user-enable-out

# ESTOP loopback, only use this for a simple machine without external ESTOP
# you really SHOULDN'T use a servo machine without proper ESTOP
#net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in

# connect spindle fwd/rev to I/O controller
#newsig SpindleFwd bit
#newsig SpindleRev bit
#linksp SpindleFwd <= vti.out-06
#linksp SpindleFwd => spindle.0.forward
#linksp SpindleRev <= vti.out-05
#linksp SpindleRev => spindle.0.reverse

# connect spindle brake to I/O controller
#newsig SpindleBrakeOn bit
#linksp SpindleBrakeOn <= vti.out-10
#linksp SpindleBrakeOn => spindle.0.brake

# connect mist/flood coolant to I/O controller
#newsig MistOn bit
#newsig FloodOn bit
#linksp MistOn <= vti.out-11
#linksp MistOn => iocontrol.0.coolant-mist
#linksp FloodOn <= vti.out-12
#linksp FloodOn => iocontrol.0.coolant-flood

# connect lube motor run to I/O controller
#newsig LubeOn bit
#linksp LubeOn <= vti.out-13
#linksp LubeOn => iocontrol.0.lube

# connect lube level to I/O controller
#newsig LubeLevel bit
#linksp LubeLevel <= vti.in-13
#linksp LubeLevel => iocontrol.0.lube_level
