Probe-in работа на разных скриптах.

Обсуждение установки, настройки и использования LinuxCNC. Вопросы по Gкоду.
Аватара пользователя
strativa
Новичок
Сообщения: 11
Зарегистрирован: 07 окт 2016, 23:36
Репутация: 0
Настоящее имя: Александр
Контактная информация:

Probe-in работа на разных скриптах.

Сообщение strativa »

Приветствую уважаемые форумчане. Прошу вашей помощи так как сам не знаю где искать.
Кратко суть проблемы такова.
Есть два скрипта на замер инструмента, так вот на одном щуп срабатывает а если заменить на другой то станок перестает реагировать на щуп.
Теперь подробнее. Оба скрипта были найдены на просторах интернета. Первый вроде брал на этом форуме, второй с какого-то забугорного.
Первый скрипт, так называемый m6.ngc при нём щуп работает но он мне как-то не очень.
(для просмотра содержимого нажмите на ссылку)

Код: Выделить всё

O<m6> sub

( 0 если датчик лежит на жертвенном столе )
#<substrate> = [0]
#<detail_hight> = [0]
#<probe_hight> = [19.2]
#<probe_x> = [0]
#<probe_y> = [300] 
#<safe_z> = [80]
 
G28.1
#<x_copy> = [#5161]
#<y_copy> = [#5162]
G53 G00 Z[#<safe_z>]
M6 T[#1]
G53 G0 X[#<probe_x>] Y[#<probe_y>]
G49
G40
G91
G38.3 Z-1 F250
o123 if[#5070 NE 0]
        G38.5 Z-80
        G38.2 Z80 F30
        #<z_new> = [#<probe_hight> - #<detail_hight> - #<substrate>]
        G92 Z[#<z_new>]
o123 else
        ( M100 P0 )
        (MSG, Ошибка!)
o123 endif
G90
G53 G0 Z[#<safe_z>]
G53 G0 X[#<x_copy>] Y[#<y_copy>]
O<m6> endsub
O<m6> CALL [100]
M2
Второй скрипт tool-change.ngc, при нём станок как будто теряет щуп.
(для просмотра содержимого нажмите на ссылку)

Код: Выделить всё

O<tool-change> SUB
( Filename: tool-change.ngc )
( LinuxCNC Manual Tool-Change Subroutines for Milling Machines version 1.1: subroutine 1/2 )
(  BEFORE USING CHANGE "CONFIGURATION PARAMETERS" BELOW FOR YOUR MACHINE! )
(  )
( In the LinuxCNC .ini config file, under the [RS274NGC] section add: )
(    # change/add/use SUBROUTINE_PATH to point to the location where these tool-change subroutines are located: )
(    SUBROUTINE_PATH = /home/linuxcnc/linuxcnc/nc_files )
(    REMAP=M6    modalgroup=6 ngc=tool-change )
(    REMAP=M600  modalgroup=6 ngc=tool-job-begin )
( and under the [EMCIO] section add: )
(    TOOL_CHANGE_AT_G30 = 0 )
( and ensure neither TOOL_CHANGE_POSITION nor TOOL_CHANGE_QUILL_UP is set. )
(  )
( In the LinuxCNC .hal config file, map some input pin to be the probe input, e.g.: )
(    net probe-z parport.0.pin-12-in => motion.probe-input )
(  )
( Usage: M6 in the g-code will invoke a manual tool change with automatic tool height adjustment. )
(        M600 is used at the beginning of the first g-code file of a job so that the next M6 will measure the tool for reference )
(             instead of caluculating a tool length offset. It can also be invoked manually through the MDI before a job starts. )
(  )
( General theory of operation: touches each tool off to the tool height sensor. The first tool is used as the reference, all )
(     subsequent tools adjust the tool offset. The tip of the tool is always placed back at the position it started in before )
(     any of the subroutines are called. It is moved away by raising Z to _TravelZ before moving towards the switch, and when )
(     moving back from the switch again moves at height _TravelZ before going straight back down to the original position. Set )
(     all necessary modes to ensure correct operation no matter what state the program is in when this is called. We eliminate )
(     almost all side effects by saving and restoring the modal state. )
(  )
( Side effects: sets G30, sets motion mode to G1. )

(------------------------------- CONFIGURATION PARAMETERS ----------------------------------------------)
#<_UseInches> =           0     ( set to 1 to use inches here, or 0 to use millimeters; should match units on tool.tbl dimensions )
#<_TravelZ> =          41.0     ( machine Z coordinate for travelling, typically near max Z to avoid ever hitting the work )
#<_TravelFeed> =     1000.0     ( feedrate used for general Z moves when avoiding G0 )
#<_ProbeX> =          145.0     ( machine X coordinate of switch/touch-off plate )
#<_ProbeY> =            0.0     ( machine Y coordinate of switch/touch-off plate )
#<_ProbeFastZ> =        5.0     ( machine Z coord to move to before starting probe, longest tool should not touch switch at this Z )
#<_ProbeMinZ> =       -37.0     ( machine Z coord to stop probe, shortest tool must touch switch at this Z, must be > min Z )
#<_ProbeRetract> =      1.5     ( small distance to retract before approaching switch/touch-off plate second time )
#<_ProbeFastFeed> =   400.0     ( feed rate for moving to _ProbeFastZ )
#<_ProbeFeed1> =       80.0     ( feed rate for touching switch/touch-off plate first time )
#<_ProbeFeed2> =       10.0     ( feed rate for touching switch/touch-off plate second time )
#<_ToolChangeX> =       0.0     ( machine X coordinate to pause at for manual tool changing )
#<_ToolChangeY> =     -50.0     ( machine Y coordinate to pause at for manual tool changing )
#<_MistOnDuringProbe> =   1     ( set to 1 for mist, or 2 for coolant, or 0 for nothing during probing, to clear switch of swarf )
(-------------------------------------------------------------------------------------------------------)

O100 IF [ EXISTS[#<_ToolDidFirst>] EQ 0 ]
        #<_ToolDidFirst> = 0
O100 ENDIF
O105 IF [ #<_ToolDidFirst> EQ 0 ]
   G49                                         ( clear tool length compensation prior to saving state if this is first time )
O105 ENDIF

M6                                             ( do the normal M6 stuff )
M70                                            ( save current modal state )

M9                                             ( turn off coolant, will be restored on return if it was on )
M5                                             ( turn off spindle, cannot be on during the probe )
G[21 - #<_UseInches>]                          ( use inches or millimeters as required here, units will be restored on return )
G30.1                                          ( save current position in #5181-#5183... )
G49                                            ( clear tool length compensation )
G90                                            ( use absolute positioning here )
G94                                            ( use feedrate in units/min )
G40                                            ( turn cutter radius compensation off here )

O200 IF [ #<_ToolDidFirst> EQ 0 ]
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( go to high travel level on Z )
  G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>]           ( to probe switch )
  G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
  G54 G1 F[#<_ProbeFeed1>] G91                 ( use relative positioning )
  O101 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
    M[7 + #<_MistOnDuringProbe> - 1]           ( turn on mist/coolant )
  O101 ENDIF
  G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>]    ( trip switch slowly )
  G0 Z[#<_ProbeRetract>]                       ( go up slightly )
  G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>]   ( trip switch very slowly )
  M9                                           ( turn off mist )
  G90                                          ( use absolute positioning )
  #<_ToolZRef> = #5063                         ( save trip point )
  #<_ToolZLast> = #<_ToolZRef>                 ( save last tool Z position )
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( return to safe level )
  G53 G0 X[#5181] Y[#5182]                     ( return to where we were in X Y)
  G53 G1 F[#<_TravelFeed>] Z[#5183]            ( return to where we were in Z )
  M72                                          ( restore modal state )
  #<_ToolDidFirst> = 1                         ( we have been in this section to set reference value already )
O200 ELSE
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( go to high travel level on Z )
  G53 G0 X[#<_ToolChangeX>] Y[#<_ToolChangeY>] ( nice place for changing tool )
  O107 IF [#<_UseInches> EQ 1 ]
    #<ToolDiamIn> = #5410
    #<ToolDiamMM> = [ #<ToolDiamIn> * 25.4 ]
  O107 ELSE
    #<ToolDiamMM> = #5410
    #<ToolDiamIn> = [ #<ToolDiamMM> / 25.4 ]
  O107 ENDIF
  O102 IF [ #<_current_tool> EQ 0 AND #<ToolDiamIn> EQ 0 ]
    (MSG, Change tool then click Resume )
  O102 ELSE
    #<ToolDiamMM> = [ #<ToolDiamIn> * 25.4 ]
    (DEBUG, Change to tool #<_current_tool> with diameter #<ToolDiamMM>mm, #<ToolDiamIn>in then click Resume )
  O102 ENDIF
  M0                                           ( pause execution )
 
  G53 G0 X[#<_ProbeX>] Y[#<_ProbeY>]           ( to high place directly over switch )
  G53 G1 F[#<_ProbeFastFeed>] Z[#<_ProbeFastZ>]( move tool closer to switch -- we shouldn't hit it )
  G54 G1 F[#<_ProbeFeed1>] G91                 ( use relative positioning )
  O103 IF [ #<_MistOnDuringProbe> EQ 1 OR #<_MistOnDuringProbe> EQ 2 ]
    M[7 + #<_MistOnDuringProbe> - 1]           ( turn on mist/coolant )
  O103 ENDIF
  G38.2 Z[#<_ProbeMinZ> - #<_ProbeFastZ>] F[#<_ProbeFeed1>]     ( trip switch slowly )
  G0 Z[#<_ProbeRetract>]                       ( go up slightly )
  G38.2 Z[#<_ProbeRetract>*-1.25] F[#<_ProbeFeed2>]   ( trip switch very slowly )
  M9                                           ( turn off mist )
  G90                                          ( use absolute positioning )
  #<_ToolZ> = #5063                            ( save new tool length )
  G43.1 Z[#<_ToolZ> - #<_ToolZRef>]            ( set new tool length Z offset, we do this now to show operator even though it has to be set again after M72 )
  G53 G1 F[#<_TravelFeed>] Z[#<_TravelZ>]      ( return to high travel level )
  G53 G0 X[#5181] Y[#5182]                     ( return to where we were in X Y)
  G53 G1 F[#<_TravelFeed>] Z[#5183 - #<_ToolZLast> + #<_ToolZ>]   ( return to where we were in Z, ajusting for tool length change )
  #<_ToolZLast> = #<_ToolZ>                    ( save last tool length )
  
  M72                                          ( restore modal state )
  G43.1 Z[#<_ToolZ> - #<_ToolZRef>]            ( set new tool length Z offset )
O200 ENDIF

O<tool-change> ENDSUB
M2
Соответственно настройку второго скрипта делал как написано в его шапке, и параметры изменял на свои. Станок начинает его отрабатывать, выходит сообщение на замену инструмента, заменили жмём ОК, станок начинает движение к заданой точке где расположен щуп, доезжает и начинает замер на заданой скорости, и так как шуп не срабатывает сами понимаете что происходит :think:
Так вот прошу вашей помощи в решении данной проблемы. Сам уже не знаю куда копнуть. Если нужна дополнительная информация буду рад предоставить.
Аватара пользователя
Сергей Саныч
Мастер
Сообщения: 9116
Зарегистрирован: 30 май 2012, 14:20
Репутация: 2857
Откуда: Тюмень
Контактная информация:

Re: Probe-in работа на разных скриптах.

Сообщение Сергей Саныч »

Какой датчик используете? Как он подключен? Есть ли какая-то индикация срабатывания датчика?
Чудес не бывает. Бывают фокусы.
Аватара пользователя
strativa
Новичок
Сообщения: 11
Зарегистрирован: 07 окт 2016, 23:36
Репутация: 0
Настоящее имя: Александр
Контактная информация:

Re: Probe-in работа на разных скриптах.

Сообщение strativa »

Датчик самый обычный с Али. https://ru.aliexpress.com/item/32866178 ... 33edriRg9u
Подключен на 13 пин LPT порта как IN. Индикации ни какой нету. Смотрел в Хал-метре, при первом и втором скрипте пин меняет значение False на True, но срабатывает только при первом скрипте.
Вот hal файл.
(для просмотра содержимого нажмите на ссылку)

Код: Выделить всё

# Generated by stepconf 1.1 at Tue Sep  3 10:32:40 2019
# Все изменения в этом файле будут перезаписаны
# при следующем запуске stepconf
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hal_parport cfg="0 out"
setp parport.0.reset-time 5000
loadrt stepgen step_type=0,0,0

addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread

addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
net spindle-cmd-rpm     <= motion.spindle-speed-out
net spindle-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-cmd-rps     <= motion.spindle-speed-out-rps
net spindle-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-at-speed    => motion.spindle-at-speed
net spindle-on <= motion.spindle-on

net probe-in => motion.probe-input

setp parport.0.pin-01-out-invert 1
net xenable         => parport.0.pin-01-out
net xstep           => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir            => parport.0.pin-03-out
net ydir            => parport.0.pin-04-out
setp parport.0.pin-05-out-invert 1
net zdir            => parport.0.pin-05-out
net astep           => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net adir            => parport.0.pin-07-out
net spindle-on      => parport.0.pin-14-out
net ystep           => parport.0.pin-16-out
setp parport.0.pin-16-out-reset 1
net zstep           => parport.0.pin-17-out
setp parport.0.pin-17-out-reset 1
net probe-in        <= parport.0.pin-13-in
net estop-ext       <= parport.0.pin-15-in

setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 70000
setp stepgen.0.dirsetup 70000
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable

setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 70000
setp stepgen.1.dirsetup 70000
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable

setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 70000
setp stepgen.2.dirsetup 70000
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable

net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in

loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
Пробовал так-же менять эти строки
net probe-in => motion.probe-input
net probe-in <= parport.0.pin-13-in
на эту из второго скрипта
net probe-z parport.0.pin-13-in => motion.probe-input
Результат тот-же, при первом скрипте срабатывает при втором нет. Я думаю эти строки описывают одно и тоже (может ошибаюсь) но на всякий попробовал.
Так-же пробовал настраивать Auto Tool Measurement https://vers.by/ru/blog/useful-articles ... easurement
Тоже перестаёт работать щуп.
Распиновка моей платы http://www.cnc-club.ru/forum/viewtopic. ... 22#p306348
lazymiller
Новичок
Сообщения: 30
Зарегистрирован: 27 дек 2011, 22:58
Репутация: 4
Контактная информация:

Re: Probe-in работа на разных скриптах.

Сообщение lazymiller »

А параметр _ProbeFastZ правильно настроен ?
Ответить

Вернуться в «LinuxCNC»