manual toolchange in linuxcnc

LinuxCNC kan hier besproken worden

Moderator: Moderators

Plaats reactie
rba
Berichten: 109
Lid geworden op: 22 feb 2015 11:57
Contacteer:

manual toolchange in linuxcnc

Bericht door rba »

Graag wil ik een toolprobe gebruiken om na het wisselen van een frees het verschil in toollengte te meten.
Elke keer als er een toolchange in het programma staat (M6) dan moet de frees naar een bepaalde positie gaan. Na het wisselen moet de toollengte ingemeten worden. Hoe krijg ik deze handelingen automatisch in linuxcnc telkens als commando M6 voorbij kom?
Gebruikersavatar
DaBit
Donateur
Berichten: 11017
Lid geworden op: 05 dec 2012 13:48
Locatie: Oss

Re: manual toolchange in linuxcnc

Bericht door DaBit »

Dit doe ik:

In je INI file onder de [RS274NGC] sectie een REMAP toevoegen:

Code: Selecteer alles

[RS274NGC]
REMAP =                         M6 modalgroup=6 prolog=change_prolog ngc=change epilog=change_epilog
Dan nog een [TOOLSENSOR] kopje toevoegen in de INI file. Waarden aanpassen naar smaak; X en Y zijn de machine-coordinaten van de toolsensor, maxprobe is maximale afstand, ZABS_(DN|UP)MOVE zijn de triggerpunten van de switch in machine-coordinaten:

Code: Selecteer alles

[TOOLSENSOR]
X = -515.17
Y = 7.60
MAXPROBE = -40
# trigger point from spindle nose in absolute coordinates, F50
ZABS_DNMOVE = -157.08
ZABS_UPMOVE = -156.98
SEARCHVEL = 600
PROBEVEL = 50
Verder heb je een 'change.ngc' nodig die ergens in een vindbare directory staat, zoals bijvoorbeeld ~/linuxcnc/ngc_lib met de volgende inhoud:

Code: Selecteer alles

o<change> sub
;(debug, in change tool_in_spindle=#<tool_in_spindle> current_pocket=#<current_pocket>)
;(debug, selected_tool=#<selected_tool> selected_pocket=#<selected_pocket>)

;otherwise after the M6 this information is gone!
#<tool> = #<selected_tool>
#<pocket> = #<selected_pocket>
#<CurrX>=#5420
#<CurrY>=#5421
#<CurrZ>=#5422

; we must execute this only in the milltask interpreter
; or preview will break, so test for '#<_task>' which is 1 for
; the milltask interpreter and 0 in the UI's
o<chktask> if [#<_task> EQ 0]
o<chktask>     return [999]
o<chktask> endif

; Check if the requested tool number is 5000 or above. If it is, do not execute the measurement moves
o<chktoolnum> if [[#<tool> GE 4999.9] OR [#<tool> LT 0.5]]
                M6
                G43 H[ROUND[#<tool>]]
                G0 X[#<CurrX>] Y[#<CurrY>]
                o<change> return [1]
o<chktoolnum> endif




;first go up
G53 G0 Z[#<_ini[AXIS_2]MAX_LIMIT>-0.1]
; then move to change position
G53 G0 X[#<_ini[CHANGE_POSITION]X>-0.1] Y[#<_ini[CHANGE_POSITION]Y>-0.1]
G53 G0 Z[#<_ini[CHANGE_POSITION]Z>-0.1]

; cancel tool offset
G49

; using the code being remapped here means 'use builtin behaviour'.
; In the manual change case, this displays the 'insert 6mm 2-flute endmill' dialog box.
M6

; Save state and run a few checks
M70
o<svchk> if [#<_ini[TOOLSENSOR]SEARCHVEL> LE 0]
          M72
          o<change> return [-1] ; indicate searchvel <= 0
o<svchk> endif
o<pvchk> if [#<_ini[TOOLSENSOR]PROBEVEL> LE 0]
          M72
          o<change> return [-2] ; indicate probevel <= 0
o<pvchk> endif

G53 G0 X[#<_ini[TOOLSENSOR]X>] Y[#<_ini[TOOLSENSOR]Y>]
; load compensation parameters
G43 H[ROUND[#<tool>]]
#<toollen> = #5403
;(DEBUG, length from tooltable: #<toollen>)
G49

; Tool length shorter than 10mm is probably an error in the tooltable; the collet nut is already higher
; Adjust working set of variables to accomodate this situation
#<maxprobe> = #<_ini[TOOLSENSOR]MAXPROBE>
o<toollenchk> if [#<toollen> LT 10]
                #<Zstart> = #<_ini[AXIS_2]MAX_LIMIT>
                #<maxprobe> = [[#<_ini[AXIS_2]MAX_LIMIT> - #<_ini[TOOLSENSOR]ZABS_DNMOVE>]*-1.0]
o<toollenchk> else
                #<Zstart> = [#<toollen> + #<_ini[TOOLSENSOR]ZABS_DNMOVE> - #<maxprobe>]
                #<maxprobe> = [#<maxprobe>-[#<toollen>*0.7]]
o<toollenchk> endif
; Adjust extra probe safety distance if we run out of Z travel, then move Z down
o<lenadjust> if [#<Zstart> GT #<_ini[AXIS_2]MAX_LIMIT>]
  #<Zstart> = [#<_ini[AXIS_2]MAX_LIMIT>-0.2]
o<lenadjust> endif
;(DEBUG, Zstart after adjustment: #<Zstart>)
G53 G0 Z[#<Zstart>]

; Probe the toolsensor
F[#<_ini[TOOLSENSOR]SEARCHVEL>]
G91
;M62 P1 (toolsetter on)
G1 Z-1
G38.2 Z[#<maxprobe>] (probe in Z- direction until switch is activated)
o<probefail1> if [#5070 EQ 0]
              (DEBUG, Probing in Z- failed)
              ;M63 P1 (toolsetter off)
              M72
              o<change> return [-3] ; indicate probe contact failure to epilog
o<probefail1> endif
F[#<_ini[TOOLSENSOR]PROBEVEL>]
G38.4 Z2 (probe in Z+ direction for loss of contact)
o<probefail2> if [#5070 EQ 0]
              (DEBUG, Probing in Z+ failed)
              ;M63 P1 (toolsetter off)
              M72
              o<change> return [-3] ; indicate probe contact failure to epilog
o<probefail2> endif
;M63 P1 (toolsetter off)

G90
G53 G0 Z[#<_ini[AXIS_2]MAX_LIMIT>-0.2]

; Calculate toollen
#<toollen> = [#5063 + #[5203+20*#5220] - #<_ini[TOOLSENSOR]ZABS_UPMOVE>]
;(DEBUG, #<toollen>)

; Store new length in tooltable and activate length compensation
M72
G10 L1 P#<tool> Z[#<toollen>]
G43 H[ROUND[#<tool>]]
; move back to XY location before tool change
;(DEBUG, #<CurrX> #<CurrY> #<CurrZ>)
G0 X[#<CurrX>] Y[#<CurrY>]

o<change> endsub [1]
M2
En dat zou de truuk moeten doen.
De belangrijkste wet in de wetenschap: 'hoe minder efficient en hoe meer herrie, hoe leuker het is'
rba
Berichten: 109
Lid geworden op: 22 feb 2015 11:57
Contacteer:

Re: manual toolchange in linuxcnc

Bericht door rba »

Heb het vandaag pas geprobeerd, maar het werkt niet. Kan nu geen ngc bestanden meer laden. Krijg dan melding dat er iets met remap niet goed gaat. Mist er nog wat?
Plaats reactie