########################################################### # # CIA 402 example snippet Hal # ########################################################### ########################################################### # Setup ########################################################### loadrt [KINS]KINEMATICS loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS num_dio=12 num_aio=6 loadusr -W lcec_conf ethercat-conf.xml loadrt lcec loadrt cia402 count=2 loadrt not names=slave9-online-not,slave8-online-not,probe loadrt or2 names=slave9-fault-or,slave8-fault-or loadrt mux4 names=spindle-dir-mux loadrt scale names=spindle-scale loadusr -W mb2hal config=at20.ini loadrt message names=hyd-pressure messages="Low hydraulic pressure" loadrt and2 names=pressure-and,x-or loadrt carousel pockets=12 encoding=index num_sense=2 loadrt timedelay names=x-brake setp cia402.0.csp-mode 1 setp cia402.0.pos-scale 838860.8 setp cia402.1.csp-mode 1 setp cia402.1.pos-scale 838860.8 setp x-brake.off-delay 0 ########################################################### # Functions servo-thread ########################################################### addf slave9-fault-or servo-thread addf slave8-fault-or servo-thread addf slave8-online-not servo-thread addf slave9-online-not servo-thread addf lcec.read-all servo-thread addf cia402.0.read-all servo-thread addf cia402.1.read-all servo-thread addf spindle-dir-mux servo-thread addf spindle-scale servo-thread addf probe servo-thread addf x-brake servo-thread addf motion-command-handler servo-thread addf x-or servo-thread addf motion-controller servo-thread addf pressure-and servo-thread addf carousel.0 servo-thread addf hyd-pressure servo-thread addf cia402.0.write-all servo-thread addf cia402.1.write-all servo-thread addf lcec.write-all servo-thread ################## #setp ################# ######################################### #nets ######################################### #net x-limit => joint.0.pos-lim-sw-in joint.0.neg-lim-sw-in lcec.0.EL1008:0.din-1 net x-home-sw => joint.0.home-sw-in lcec.0.EL1008:0.din-2 # ethercat to cia402 driver - x net x-statusword lcec.0.9.cia-statusword => cia402.0.statusword net x-opmode-display lcec.0.9.opmode-display => cia402.0.opmode-display net x-drv-act-pos lcec.0.9.actual-position => cia402.0.drv-actual-position # joint signals for motion - x net x-fault-not slave8-online-not.in lcec.0.9.slave-online x-or.in0 net x-fault-or.0 slave8-fault-or.in0 slave8-online-not.out net x-fault-or.1 slave8-fault-or.in1 cia402.0.drv-fault net x-pos-cmd joint.0.motor-pos-cmd => cia402.0.pos-cmd net x-pos-fb joint.0.motor-pos-fb <= cia402.0.pos-fb net x-enable joint.0.amp-enable-out => cia402.0.enable x-or.in1 net x-amp-fault joint.0.amp-fault-in <= slave8-fault-or.out net x-brake x-brake.in x-or.out # cia402 driver to ethercat - x net x-controlword cia402.0.controlword => lcec.0.9.cia-controlword net x-modes-of-operation cia402.0.opmode => lcec.0.9.opmode net x-drv-target-pos cia402.0.drv-target-position => lcec.0.9.target-position #net x-drv-target-velo cia402.0.drv-target-velocity => lcec.0.9.target-velocity ######################################### #nets ######################################### net z-limit => joint.1.pos-lim-sw-in joint.1.neg-lim-sw-in lcec.0.EL1008:0.din-3 net z-home-sw => joint.1.home-sw-in lcec.0.EL1008:0.din-0 # ethercat to cia402 driver - z net z-fault-or.1 slave9-fault-or.in1 cia402.1.drv-fault net z-pos-cmd joint.1.motor-pos-cmd => cia402.1.pos-cmd net z-pos-fb joint.1.motor-pos-fb <= cia402.1.pos-fb net z-statusword lcec.0.8.cia-statusword => cia402.1.statusword net z-opmode-display lcec.0.8.opmode-display => cia402.1.opmode-display net z-drv-act-pos lcec.0.8.actual-position => cia402.1.drv-actual-position # joint signals for motion - z net z-fault-not slave9-online-not.in lcec.0.8.slave-online net z-fault-or.0 slave9-fault-or.in0 slave9-online-not.out net z-enable joint.1.amp-enable-out => cia402.1.enable net z-amp-fault joint.1.amp-fault-in <= slave9-fault-or.out # cia402 driver to ethercat - z net z-controlword cia402.1.controlword => lcec.0.8.cia-controlword net z-modes-of-operation cia402.1.opmode => lcec.0.8.opmode net z-drv-target-pos cia402.1.drv-target-position => lcec.0.8.target-position #net z-drv-target-velo cia402.1.drv-target-velocity => lcec.0.8.target-velocity ###################### #spindle ###################### #spindle dir signals setp spindle-dir-mux.in0 6 setp spindle-dir-mux.in1 1 setp spindle-dir-mux.in2 2 net spindle-cw spindle-dir-mux.sel0 net spindle-ccw spindle-dir-mux.sel1 net spindle-control mb2hal.setEnableout.00.float spindle-dir-mux.out #spindle rpm signal setp spindle-scale.gain 2.222 net spindle-vel-cmd-rpm-abs spindle-scale.in net spindle-output-speed mb2hal.freq.freq.float spindle-scale.out # ---setup spindle control signals--- net spindle-vel-cmd-rps <= spindle.0.speed-out-rps net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs #net spindle-vel-cmd-rpm <= spindle.0.speed-out net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs net spindle-cw <= spindle.0.forward net spindle-ccw <= spindle.0.reverse net spindle-brake <= spindle.0.brake net spindle-revs => spindle.0.revs net spindle-at-speed => spindle.0.at-speed net spindle-vel-fb-rps => spindle.0.speed-in net spindle-index-enable <=> spindle.0.index-enable #net spindle-is-oriented => spindle.0.is-oriented net spindle-orient-fault => spindle.0.orient-fault net spindle-locked <= spindle.0.locked sets spindle-at-speed true #****************************** # connect miscellaneous signals #****************************** # ---HALUI signals--- net joint-select-a halui.axis.x.select net x-is-homed halui.joint.0.is-homed net jog-x-pos halui.axis.x.plus net jog-x-neg halui.axis.x.minus net jog-x-analog halui.axis.x.analog net z-is-homed halui.joint.1.is-homed net joint-select-c halui.axis.z.select net jog-z-pos halui.axis.z.plus net jog-z-neg halui.axis.z.minus net jog-z-analog halui.axis.z.analog net jog-selected-pos halui.axis.selected.plus net jog-selected-neg halui.axis.selected.minus net spindle-manual-cw halui.spindle.0.forward net spindle-manual-ccw halui.spindle.0.reverse net spindle-manual-stop halui.spindle.0.stop net machine-is-on halui.machine.is-on net jog-speed halui.axis.jog-speed net MDI-mode halui.mode.is-mdi # ---coolant signals--- net coolant-mist <= iocontrol.0.coolant-mist net coolant-flood <= iocontrol.0.coolant-flood # ---probe signal--- net probe-in => motion.probe-input # # ---motion control signals--- net in-position <= motion.in-position net machine-is-enabled <= motion.motion-enabled net brake-out lcec.0.EL2008:1.dout-7 x-brake.out # ---digital in / out signals--- # ---estop signals--- #net machine-on lcec.0.EL1809.din-6-not iocontrol.0.user-request-enable net machine-off halui.machine.off # ---digital in / out signals--- # ---estop signals- net estop-out => iocontrol.0.emc-enable-in lcec.0.EL1809.din-1-not lcec.0.EL2008:1.dout-4 net not halui.estop.activate lcec.0.EL1809.din-1 net tool-prepare iocontrol.0.tool-prepare iocontrol.0.tool-prepared net tool-change iocontrol.0.tool-change iocontrol.0.tool-changed