пока получается вот что
весь процесс управляется g кодом
большую часть я его разобрал но не понятна самая нужая мне часть
M66 P0 L3 Q60 ; wait for carousel finished
O107 if [#5399 LT 0]
(abort, failed to align carousel)
O107 endif
что означают O107 и O106
Код: Выделить всё
o<toolchange> sub
M19 R0 ;align the spindle
; only unload the tool if there is a tool in the spindle
; This assumes that the carousel is already aligned correctly.
; It is important to unload the tool before shutting down the machine.
O100 IF [#<tool_in_spindle> GT 0]
G53 G0 Z -100
M64 P2 ; move arm in
M66 P2 L3 Q5 ; wait for arm-in = true
O104 if [#5399 LT 0]
(abort, failed to move arm in)
O104 endif
M64 P3 ; release tool
M66 P3 L3 Q2 ; wait for tool-released = true
O105 if [#5399 LT 0]
(abort, failed to release tool)
O105 endif
O100 ENDIF
G53 G0 Z0
O200 IF [#<selected_tool> GT 0]
M65 P1 ; unlock carousel
M66 P1 L4 Q1 ; wait for locked=false
O106 if [#5399 LT 0]
(abort, failed to unlock carousel)
O106 endif
M68 E0 Q#<selected_pocket> ;set the carousel to move to the right pocket
M64 P0 ; start carousel
G4 P2
M66 P0 L3 Q60 ; wait for carousel finished
O107 if [#5399 LT 0]
(abort, failed to align carousel)
O107 endif
M65 P0; stop carousel
M64 P1 ; lock carousel
M66 P1 L3 Q1 ; wait for locked=true
O108 if [#5399 LT 0]
(abort, failed to lock carousel)
O108 endif
M64 P2 ; move arm in (might already be in)
M66 P2 L3 Q5 ; wait for arm-in = true
O109 if [#5399 LT 0]
(abort, failed to move arm in)
O109 endif
G53 G0 Z-100 ; pick up the tool
O200 ENDIF
M65 P3 ; clamp tool
M66 P3 L4 Q2 ; wait for tool-released = false
O110 if [#5399 LT 0]
(abort, failed to clamp tool)
O110 endif
M65 P2 ; move arm back out
M66 P4 L3 Q5 ; wait for arm-out = true
O111 if [#5399 LT 0]
(abort, failed to move arm in)
O111 endif
o<toolchange> endsub [1]
M2
Код: Выделить всё
# Generated by PNCconf at Mon Jan 25 16:13:01 2016
# Все изменения в этом файле будут перезаписаны
# overwritten when you run PNCconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES num_dio=6
loadrt hostmot2
loadrt hm2_pci config=" num_encoders=6 num_pwmgens=0 num_stepgens=0 sserial_port_0=000xxx"
setp hm2_5i25.0.watchdog.timeout_ns 5000000
loadrt hal_parport cfg="0 out"
loadrt pid names=pid.x,pid.y,pid.z,pid.s
addf parport.0.read servo-thread
addf hm2_5i25.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.x.do-pid-calcs servo-thread
addf pid.y.do-pid-calcs servo-thread
addf pid.z.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf parport.0.write servo-thread
addf hm2_5i25.0.write servo-thread
#atc carousel
loadusr -W ./vmcgui
loadrt wcomp names=xlim,ylim,zlim,armsw,drawsw,locksw
loadrt mux2 names=armpos,drawpos,lockpos,mux2.0
loadrt mux4 names=cardir
loadrt sum2 names=carpos,spindlepos
loadrt limit2 names=armlim,drawlim,locklim,spindlelim
loadrt threads
loadrt carousel pockets=8 dir=2 encoding=gray num_sense=4
addf carousel.0 servo-thread
addf carpos servo-thread
addf cardir servo-thread
loadrt conv_s32_float count=3
loadrt conv_float_s32 count=3
loadrt near count=3
addf conv-float-s32.2 servo-thread # G-code analogue outputs are float-type
net car-enable motion.digital-out-00 carousel.0.enable
net car-ready carousel.0.ready motion.digital-in-00
#вращать магазин
net car-fwd carousel.0.motor-fwd hm2_5i25.0.7i77.0.0.output-05
net car-rev carousel.0.motor-rev hm2_5i25.0.7i77.0.0.output-06
net car-pos-req motion.analog-out-00 conv-float-s32.2.in
net car-pos-s32 conv-float-s32.2.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 car-lock motion.digital-out-01 #hm2_5i25.0.7i77.0.0.output-07 #hm2_5i25.0.7i77.0.0.output-08-invert
net car-locked motion.digital-in-01
net car-locked hm2_5i25.0.7i77.0.0.output-08
net car-locked hm2_5i25.0.7i77.0.0.output-07
setp hm2_5i25.0.7i77.0.0.output-08-invert true
#магазин влево вправо
net arm-act motion.digital-out-02 hm2_5i25.0.7i77.0.0.output-09
net arm-act hm2_5i25.0.7i77.0.0.output-10
setp hm2_5i25.0.7i77.0.0.output-10-invert true
net arm-in motion.digital-in-02
net arm-out motion.digital-in-04
net tool-release motion.digital-out-03
net tool-released motion.digital-in-03
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
addf xlim servo-thread
addf ylim servo-thread
addf zlim servo-thread
net x-pos xlim.in vmcgui.X
net y-pos ylim.in vmcgui.Y
net z-pos-cmd zlim.in vmcgui.Z
#net z-pos-cmd vmcgui.Z
#simulated arm
setp vmcgui.arm -20
addf armpos servo-thread
addf armlim servo-thread
addf armsw servo-thread
setp armpos.in0 -20
setp armpos.in1 5
net arm-act armpos.sel
net arm-set armpos.out armlim.in
net arm-pos armlim.out armsw.in vmcgui.arm
setp armlim.max 5
setp armlim.min -20
setp armlim.maxv 10
setp armsw.max 4
setp armsw.min -19
net arm-out armsw.under
net arm-in armsw.over
#simulated carousel with 5 Gray-coded outputs
setp cardir.in0 0
setp cardir.in1 0.001
setp cardir.in2 -0.001
setp cardir.in3 0
net car-fwd cardir.sel0
net car-rev cardir.sel1
net car-dir cardir.out carpos.in0
net car-pos carpos.out carpos.in1 vmcgui.carousel
loadrt conv_float_u32
addf conv-float-u32.0 servo-thread
net car-pos conv-float-u32.0.in
loadrt bin2gray
addf bin2gray.0 servo-thread
net sim-pocket-u conv-float-u32.0.out bin2gray.0.in
loadrt bitslice personality=5
addf bitslice.0 servo-thread
net graycode bin2gray.0.out bitslice.0.in
net bit0 hm2_5i25.0.7i77.0.0.input-03
net bit1 hm2_5i25.0.7i77.0.0.input-04
net bit2 hm2_5i25.0.7i77.0.0.input-05
net bit3 hm2_5i25.0.7i77.0.0.input-06-not
# pulse and index output variant (untidy modmaths)
# loadrt conv_s32_float count=2
# loadrt conv_float_s32 count=3
# loadrt near count=3
loadrt scale
addf conv-s32-float.0 servo-thread
addf conv-float-s32.0 servo-thread
addf conv-s32-float.1 servo-thread
addf conv-float-s32.1 servo-thread
addf scale.0 servo-thread
addf near.1 servo-thread
addf near.2 servo-thread
net car-pos conv-float-s32.0.in
net car-pos-int conv-float-s32.0.out conv-s32-float.0.in
net car-pos-float conv-s32-float.0.out near.1.in2
net car-pos near.1.in1
net pulse near.1.out
setp near.1.difference 0.01
setp scale.0.gain 0.1
setp scale.0.offset -1 # to show-off index homing
net car-pos scale.0.in
net car-pos-div10 scale.0.out conv-float-s32.1.in
net car-pos-div10-int conv-float-s32.1.out conv-s32-float.1.in
net car-pos-div10-float conv-s32-float.1.out near.2.in2
net car-pos-div10 near.2.in1
net index near.2.out
setp near.2.difference 0.009
#simulated spindle
addf spindlepos servo-thread
addf spindlelim servo-thread
setp spindlelim.max 1000
setp spindlelim.min -1000
setp spindlelim.maxv 100
net spindle-cmd spindlelim.in
net spindle-vel spindlelim.out spindlepos.in0
setp spindlepos.gain0 .00001666
setp spindlepos.in1 0
net spindle-pos spindlepos.out spindlepos.in1 vmcgui.spindle
#simulated drawbar
setp vmcgui.drawbar 5
addf drawpos servo-thread
addf drawlim servo-thread
addf drawsw servo-thread
setp drawpos.in0 5
setp drawpos.in1 0
net tool-release drawpos.sel
net draw-set drawpos.out drawlim.in
setp drawlim.max 5
setp drawlim.min 0
setp drawlim.maxv 10
net draw-pos drawlim.out drawsw.in vmcgui.drawbar
setp drawsw.max 4
setp drawsw.min 1
net tool-locked drawsw.over
net tool-released drawsw.under
#simulated carousel lock
setp vmcgui.lock 5
addf lockpos servo-thread
addf locklim servo-thread
addf locksw servo-thread
setp lockpos.in0 0
setp lockpos.in1 5
net car-lock lockpos.sel
net lock-set lockpos.out locklim.in
setp locklim.max 5
setp locklim.min 0
setp locklim.maxv 10
net lock-pos locklim.out locksw.in vmcgui.lock
setp locksw.max 4
setp locksw.min 1
net car-locked locksw.over
net car-released locksw.under
# --- MACHINE-IS-ENABLED ---
net machine-is-enabled hm2_5i25.0.7i77.0.0.output-01
# --- SPINDLE-ON ---
net spindle-on hm2_5i25.0.7i77.0.0.output-02
# --- MACHINE-IS-ENABLED ---
net machine-is-enabled hm2_5i25.0.7i77.0.0.output-03
# --- SPINDLE-ON ---
#net spindle-on hm2_5i25.0.7i77.0.0.output-04
# external input signals
# --- HOME-X ---
net home-x <= hm2_5i25.0.7i77.0.0.input-00
# --- HOME-Y ---
net home-y <= hm2_5i25.0.7i77.0.0.input-01
# --- HOME-Z ---
net home-z <= hm2_5i25.0.7i77.0.0.input-02
# --- ALL-LIMIT ---
#net all-limit <= hm2_5i25.0.7i77.0.0.input-03
#*******************
# AXIS X
#*******************
setp pid.x.Pgain [AXIS_0]P
setp pid.x.Igain [AXIS_0]I
setp pid.x.Dgain [AXIS_0]D
setp pid.x.bias [AXIS_0]BIAS
setp pid.x.FF0 [AXIS_0]FF0
setp pid.x.FF1 [AXIS_0]FF1
setp pid.x.FF2 [AXIS_0]FF2
setp pid.x.deadband [AXIS_0]DEADBAND
setp pid.x.maxoutput [AXIS_0]MAX_OUTPUT
setp pid.x.error-previous-target true
setp pid.x.maxerror .5
net x-index-enable <=> pid.x.index-enable
net x-enable => pid.x.enable
net x-pos-cmd => pid.x.command
net x-vel-cmd => pid.x.command-deriv
net x-pos-fb => pid.x.feedback
net x-output => pid.x.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout0-scalemax [AXIS_0]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout0-minlim [AXIS_0]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout0-maxlim [AXIS_0]OUTPUT_MAX_LIMIT
net x-output => hm2_5i25.0.7i77.0.1.analogout0
net x-pos-cmd axis.0.motor-pos-cmd
net x-enable axis.0.amp-enable-out
# enable _all_ sserial pwmgens
net x-enable hm2_5i25.0.7i77.0.1.analogena
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.00.counter-mode 0
setp hm2_5i25.0.encoder.00.filter 1
setp hm2_5i25.0.encoder.00.index-invert 0
setp hm2_5i25.0.encoder.00.index-mask 0
setp hm2_5i25.0.encoder.00.index-mask-invert 0
setp hm2_5i25.0.encoder.00.scale [AXIS_0]ENCODER_SCALE
net x-pos-fb <= hm2_5i25.0.encoder.00.position
net x-vel-fb <= hm2_5i25.0.encoder.00.velocity
net x-pos-fb => axis.0.motor-pos-fb
net x-index-enable axis.0.index-enable <=> hm2_5i25.0.encoder.00.index-enable
net x-pos-rawcounts <= hm2_5i25.0.encoder.00.rawcounts
# ---setup home / limit switch signals---
net home-x => axis.0.home-sw-in
net all-limit => axis.0.neg-lim-sw-in
net all-limit => axis.0.pos-lim-sw-in
#*******************
# AXIS Y
#*******************
setp pid.y.Pgain [AXIS_1]P
setp pid.y.Igain [AXIS_1]I
setp pid.y.Dgain [AXIS_1]D
setp pid.y.bias [AXIS_1]BIAS
setp pid.y.FF0 [AXIS_1]FF0
setp pid.y.FF1 [AXIS_1]FF1
setp pid.y.FF2 [AXIS_1]FF2
setp pid.y.deadband [AXIS_1]DEADBAND
setp pid.y.maxoutput [AXIS_1]MAX_OUTPUT
setp pid.y.error-previous-target true
setp pid.y.maxerror .5
net y-index-enable <=> pid.y.index-enable
net y-enable => pid.y.enable
net y-pos-cmd => pid.y.command
net y-vel-cmd => pid.y.command-deriv
net y-pos-fb => pid.y.feedback
net y-output => pid.y.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout1-scalemax [AXIS_1]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout1-minlim [AXIS_1]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout1-maxlim [AXIS_1]OUTPUT_MAX_LIMIT
net y-output => hm2_5i25.0.7i77.0.1.analogout1
net y-pos-cmd axis.1.motor-pos-cmd
net y-enable axis.1.amp-enable-out
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.01.counter-mode 0
setp hm2_5i25.0.encoder.01.filter 1
setp hm2_5i25.0.encoder.01.index-invert 0
setp hm2_5i25.0.encoder.01.index-mask 0
setp hm2_5i25.0.encoder.01.index-mask-invert 0
setp hm2_5i25.0.encoder.01.scale [AXIS_1]ENCODER_SCALE
net y-pos-fb <= hm2_5i25.0.encoder.01.position
net y-vel-fb <= hm2_5i25.0.encoder.01.velocity
net y-pos-fb => axis.1.motor-pos-fb
net y-index-enable axis.1.index-enable <=> hm2_5i25.0.encoder.01.index-enable
net y-pos-rawcounts <= hm2_5i25.0.encoder.01.rawcounts
# ---setup home / limit switch signals---
net home-y => axis.1.home-sw-in
net all-limit => axis.1.neg-lim-sw-in
net all-limit => axis.1.pos-lim-sw-in
#*******************
# AXIS Z
#*******************
setp pid.z.Pgain [AXIS_2]P
setp pid.z.Igain [AXIS_2]I
setp pid.z.Dgain [AXIS_2]D
setp pid.z.bias [AXIS_2]BIAS
setp pid.z.FF0 [AXIS_2]FF0
setp pid.z.FF1 [AXIS_2]FF1
setp pid.z.FF2 [AXIS_2]FF2
setp pid.z.deadband [AXIS_2]DEADBAND
setp pid.z.maxoutput [AXIS_2]MAX_OUTPUT
setp pid.z.error-previous-target true
setp pid.z.maxerror .5
net z-index-enable <=> pid.z.index-enable
net z-enable => pid.z.enable
net z-pos-cmd => pid.z.command
net z-vel-cmd => pid.z.command-deriv
net z-pos-fb => pid.z.feedback
net z-output => pid.z.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout2-scalemax [AXIS_2]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout2-minlim [AXIS_2]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout2-maxlim [AXIS_2]OUTPUT_MAX_LIMIT
net z-output => hm2_5i25.0.7i77.0.1.analogout2
net z-pos-cmd axis.2.motor-pos-cmd
net z-enable axis.2.amp-enable-out
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.02.counter-mode 0
setp hm2_5i25.0.encoder.02.filter 1
setp hm2_5i25.0.encoder.02.index-invert 0
setp hm2_5i25.0.encoder.02.index-mask 0
setp hm2_5i25.0.encoder.02.index-mask-invert 0
setp hm2_5i25.0.encoder.02.scale [AXIS_2]ENCODER_SCALE
net z-pos-fb <= hm2_5i25.0.encoder.02.position
net z-vel-fb <= hm2_5i25.0.encoder.02.velocity
net z-pos-fb => axis.2.motor-pos-fb
net z-index-enable axis.2.index-enable <=> hm2_5i25.0.encoder.02.index-enable
net z-pos-rawcounts <= hm2_5i25.0.encoder.02.rawcounts
# ---setup home / limit switch signals---
net home-z => axis.2.home-sw-in
net all-limit => axis.2.neg-lim-sw-in
net all-limit => axis.2.pos-lim-sw-in
#*******************
# SPINDLE S
#*******************
setp pid.s.Pgain [SPINDLE_9]P
setp pid.s.Igain [SPINDLE_9]I
setp pid.s.Dgain [SPINDLE_9]D
setp pid.s.bias [SPINDLE_9]BIAS
setp pid.s.FF0 [SPINDLE_9]FF0
setp pid.s.FF1 [SPINDLE_9]FF1
setp pid.s.FF2 [SPINDLE_9]FF2
setp pid.s.deadband [SPINDLE_9]DEADBAND
setp pid.s.maxoutput [SPINDLE_9]MAX_OUTPUT
setp pid.s.error-previous-target true
setp pid.s.maxerror .0005
net spindle-index-enable <=> pid.s.index-enable
net spindle-enable => pid.s.enable
net spindle-vel-cmd-rpm => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
net spindle-output <= pid.s.output
# ---setup spindle control signals---
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-vel-cmd-rpm <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-enable <= motion.spindle-on
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
net spindle-revs => motion.spindle-revs
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-fb-rps => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable
# ---Setup spindle at speed signals---
sets spindle-at-speed true
#******************************
# connect miscellaneous signals
#******************************
# ---HALUI signals---
net joint-select-a halui.joint.0.select
net x-is-homed halui.joint.0.is-homed
net jog-x-pos halui.jog.0.plus
net jog-x-neg halui.jog.0.minus
net jog-x-analog halui.jog.0.analog
net joint-select-b halui.joint.1.select
net y-is-homed halui.joint.1.is-homed
net jog-y-pos halui.jog.1.plus
net jog-y-neg halui.jog.1.minus
net jog-y-analog halui.jog.1.analog
net joint-select-c halui.joint.2.select
net z-is-homed halui.joint.2.is-homed
net jog-z-pos halui.jog.2.plus
net jog-z-neg halui.jog.2.minus
net jog-z-analog halui.jog.2.analog
net jog-selected-pos halui.jog.selected.plus
net jog-selected-neg halui.jog.selected.minus
net spindle-manual-cw halui.spindle.forward
net spindle-manual-ccw halui.spindle.reverse
net spindle-manual-stop halui.spindle.stop
net machine-is-on halui.machine.is-on
net jog-speed halui.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
# ---digital in / out signals---
# ---estop signals---
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
# ---manual tool change signals---
loadusr -W hal_manualtoolchange