loadrt carousel pockets=10 dir=1 encoding=gray num_sense=4
loadrt conv_float_s32
addf carousel.0 servo-thread
addf conv-float-s32.0 servo-thread # G-code analogue outputs are float-type
# Two sequences, one to unload a tool, one to load.
# (because if there is no tool in the spindle, unload is a crash)
loadrt sequencer sequence="d100m:w10t0:r1f1:w60s2t2:w10s1t1:s3t3:s4t4:s0t0:r0 "
addf sequencer.0 servo-thread
# sequence 1, unload a tool
# d100 : a delay to allow the Z movement to start
# w10t0 : 10 second timeout, wait for motion.in-pos
# r1f1 : release the carousel lock, wait for unlocked
# w60s2t2 : start the carousel rotation, 60sec timeout
# w10s1t1 : lock the carousel
# s3t3 : set the arm-in, wait for the arm-on switch
# s4t4 : set the tool release, wait for tool released
# s0t0 : request Z to top, wait for motion.in-pos
# r0 : toggle motion request
net car-enable sequencer.0.out-2 carousel.0.enable
net car-ready carousel.0.ready sequencer.0.in-2
net car-fwd carousel.0.motor-fwd
#net car-rev carousel.0.motor-rev
net car-pos-req motion.analog-out-00 conv-float-s32.0.in
net car-pos-s32 conv-float-s32.0.out carousel.0.pocket-number
net bit0 carousel.0.sense-0
net bit1 carousel.0.sense-1
net bit2 carousel.0.sense-2
net bit3 carousel.0.sense-3
net toolchange-error sequencer.0.error halui.abort
net start-unload motion.digital-out-00 sequencer.0.enable
net motion-done motion.in-position sequencer.0.in-0
net car-lock sequencer.0.out-1
net car-locked sequencer.0.in-1
net arm-act sequencer.0.out-3
net arm-in sequencer.0.in-3
net tool-release sequencer.0.out-4
net tool-released sequencer.0.in-4
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared