errore ripartenza dalla linea gcode

Sezione dedicata a RosettaCNC
Rispondi
troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

errore ripartenza dalla linea gcode

Messaggio da troy21 » venerdì 11 giugno 2021, 18:28

ciao a tutti
perche quando fermo un lavoro e vorrei riprendere dalla stessa linea mi da questo errore?
Non hai i permessi necessari per visualizzare i file e le foto allegati in questo messaggio. Per visualizzare tali file devi registrarti ed effettuare il Login

Avatar utente
hellfire39
God
God
Messaggi: 3413
Iscritto il: domenica 16 dicembre 2012, 9:04
Località: AN

Re: errore ripartenza dalla linea gcode

Messaggio da hellfire39 » venerdì 11 giugno 2021, 19:01

te lo dice il messaggio stesso: non posso riprendere ad eseguire un comando G1 se non mi dici a quale velocità devo andare (feed rate).

troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

Re: errore ripartenza dalla linea gcode

Messaggio da troy21 » venerdì 11 giugno 2021, 22:17

Come mi devo comportare? Il feed rimane sempre uguale

Avatar utente
MauPre75
Senior
Senior
Messaggi: 2372
Iscritto il: venerdì 1 dicembre 2017, 14:43

Re: errore ripartenza dalla linea gcode

Messaggio da MauPre75 » venerdì 11 giugno 2021, 22:29

Non so se dico una cavolata, io proverei a ripartire da una linea precedente che contiene il feedrate, anche se fossero molte.

troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

Re: errore ripartenza dalla linea gcode

Messaggio da troy21 » venerdì 11 giugno 2021, 22:46

Già fatto non parte solito errore

Avatar utente
Pedro
God
God
Messaggi: 7021
Iscritto il: domenica 6 aprile 2008, 18:44
Località: Roma

Re: errore ripartenza dalla linea gcode

Messaggio da Pedro » sabato 12 giugno 2021, 6:54

un listato del g code?

non postarlo come testo ma salvalo come zip e allegalo.

anche l'M6 start, la macro del cambio utensile. Mach3 dove ti fermi e riparti comunque legge, rilegge, tutte le impostazioni dall'inizio programma

quando ridai il run from here e hai prima selezionato la riga di programma hai selezionato la check box del feed rate?
Immagine.jpg
Non hai i permessi necessari per visualizzare i file e le foto allegati in questo messaggio. Per visualizzare tali file devi registrarti ed effettuare il Login
"Ho controllato molto approfonditamente," disse il computer, "e questa è sicuramente la risposta. Ad essere sinceri, penso che il problema sia che voi non abbiate mai saputo veramente qual è la domanda."

Avatar utente
hellfire39
God
God
Messaggi: 3413
Iscritto il: domenica 16 dicembre 2012, 9:04
Località: AN

Re: errore ripartenza dalla linea gcode

Messaggio da hellfire39 » sabato 12 giugno 2021, 7:39

Mi sa che usa rosetta

qandro
Member
Member
Messaggi: 252
Iscritto il: lunedì 29 ottobre 2018, 9:54

Re: errore ripartenza dalla linea gcode

Messaggio da qandro » sabato 12 giugno 2021, 7:58

Nei parametri di configurazione del cambio utensile #6000 in poi vi é uno dei parametri relativi ai feed a valore zero.

Avatar utente
Pedro
God
God
Messaggi: 7021
Iscritto il: domenica 6 aprile 2008, 18:44
Località: Roma

Re: errore ripartenza dalla linea gcode

Messaggio da Pedro » sabato 12 giugno 2021, 9:57

hellfire39 ha scritto:
sabato 12 giugno 2021, 7:39
Mi sa che usa rosetta
opps...non lo ha scritto, e la sfera di cristallo purtroppo si è spaccata :lol:

fa nulla, mi sono sbagliato
"Ho controllato molto approfonditamente," disse il computer, "e questa è sicuramente la risposta. Ad essere sinceri, penso che il problema sia che voi non abbiate mai saputo veramente qual è la domanda."

troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

Re: errore ripartenza dalla linea gcode

Messaggio da troy21 » sabato 12 giugno 2021, 10:21

Si uso Rosetta A... Beh l ho scritto nella sezione apposita... 🤣
Lo fa con qualsiasi gcode
Non utilizzo cambio utensile nel momento di riavviare, mi è capitato di fermare per un errore se non ricordo male e quando volevo ripartire dalla stessa linea mi da questo errore..
Il gcode è generato da fusion360
Domani posto un video

troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

Re: errore ripartenza dalla linea gcode

Messaggio da troy21 » sabato 12 giugno 2021, 10:23

@qandro
Quindi se il parametro è a zero ovviamente non sa a che feed ripartire giusto? Nel caso dovrei mettere un parametro di default

qandro
Member
Member
Messaggi: 252
Iscritto il: lunedì 29 ottobre 2018, 9:54

Re: errore ripartenza dalla linea gcode

Messaggio da qandro » sabato 12 giugno 2021, 10:45

Nella riga 309 della macro tool_change.ngc ci sarà una riga con un F#qualchecosa dove #qualchecosa vale zero.

Se esegue la macro significa che nel programma c'è un cambio utensile (M6) e la macro non è stata configurata correttamente.

troy21
Senior
Senior
Messaggi: 917
Iscritto il: mercoledì 11 aprile 2012, 13:29
Località: Alghero

Re: errore ripartenza dalla linea gcode

Messaggio da troy21 » sabato 12 giugno 2021, 11:45

Io non faccio cambi utensili durante le lavorazioni, di solito lavoro con una fresa, finisce la lavorazione, e poi alla prossima lavorazione stessa musica
Non creo il gcode con cambio utensile visto che non lo. Utilizzo
Però a volte mi capita di dover fermare per qualsiasi motivo e poi dover riprendere la lavorazione da quel punto, quindi la voce cambio utensile è da escludere
Dai parametri
Mi servirebbe quindi solo se non vado errato la voce "feed"

qandro
Member
Member
Messaggi: 252
Iscritto il: lunedì 29 ottobre 2018, 9:54

Re: errore ripartenza dalla linea gcode

Messaggio da qandro » sabato 12 giugno 2021, 13:35

Il punto è un altro.

Se ti ha richiamato la macro tool_change.ngc (cartella macros della machine in uso) significa
che nel codice G che si tenta di eseguire c'è un cambio utensile (comando M06).

Ogni volta che il sistema trova un M06 nel codice andrà ad eseguire il codice contenuto in quella macro.
Se non ci sono comandi M6 nel codice NON chiamerà la macro.

Se si usa la macro va configurata impostando i parametri #6xxx nella libreria parametri come
descritto nella fase di testa della macro stessa.

Estratto di una versione del cambio utensile:

Codice: Seleziona tutto

;
;   RosettaCNC (c) 2016-2021
;
; Name              : tool_change.ngc
; Sub UID           : 6
; Version           : 4
; Description       : Tool change macro
; Application       : Standard CNC cycles
; Note              : This macro is called by CNC with M06 or manually with G65 P"tool_change" for optional actions.
;                   : Check the #6000 parameter description for tool change supported types.
;
; DISCLAIMER        : This macro is provided 'AS IS', without WARRANTY of any kind, express or implied.
;                   : The macro is provided as an example only.
;                   : Use this macro at your own risk.
;
; TAKE CARE         : Don't use the CNC #5132..5135 because they are valid ONLY when the macro is called with a M06.
;
; Conventions of input parameters
;
;   Xx              compulsory parameter
;   [Xx]            optional parameter
;   (Xx|Yy|Zz)?     one of compulsory paramaters
;   [Xx|Yy|Zz]*     zero or more optionals parameters
;   [Xx|Yy|Zz]+     at least one or more optionals parameters
;   M!              compulsory parameter don't take care of passed value
;   [M!]            optional parameter don't take care of passed value
;   M[1|2]?         compulsory parameter with one of listed values (e.g. M1 or M2)
;   [M[1|2]?]       optional parameter with one of listed values (e.g. None or M1 or M2)
;
; Format
;
;   M06
;
;   G65 P"tool_change" Aa Bb Cc Ii [Jj] [K!]
;
; Arguments with M6 call
;
;   Aa  #1          tool id of the tool to be loaded
;   Bb  #2          slot of the tool to be loaded
;   Cc  #3          tool id of the tool in use
;   Ii  #4          slot of the tool in use
;
; Extra arguments with G65 call
;
;   Jj  #5          optional action:
;                       #0  = the option is disabled (is the normal condition when the macro is called by a M06)
;                        0  = do not change behavior of tool-setter after a pick in M06 or direct macro call
;                        1  = do not execute tool-setter after a pick
;                        2  = force execute tool-setter after pick
;                        3  = execute only tool-setter of loaded tool
;                        4  = execute only magazine open
;                        5  = execute only magazine close
;                        6  = return magazine state in #<tc.atc.magazine_state>
;                        7  = manually cone unload/load
;   Kk  #6          optional magazine argument:
;                       #0  = the option is disabled (is the normal condition when the macro is called by a M06)
;                       any = don't close magazine, is not the last operation (PICK/PLACE/TOOL-SETTER) to do yet
;
; Protected Parameters
;
;   Param           Description
;   =====           ===========
;   #6000           TOOL_CHANGE [GEN] : Type:
;                                       0   = Dummy tool change:
;                                             This mode only notice to the PLC about the loaded tool ID.
;                                             No other actions or movments will be done.
;                                       1   = Manual Tool Change (MTC) with tool length probing:
;                                             a] Moves to tool-setter position and measures the loaded tool length.
;                                             b] Moves to tool change position and show info about tool to manually change.
;                                             c] Waits for the manual tool change by the operator which confirm that change is done.
;                                             d] Moves to tool-setter position to measures the length of the new tool.
;                                             e] Calcs the difference and uses this value as tool length compensation.
;                                       2   = Manual Tool Change (MTC) with tool length from Tools Library info:
;                                             a] Moves to tool change position and show info about tool to manually change.
;                                             b] Waits for the manual tool change by the operator which confirm that change is done.
;                                             c] If enabled applies the tool length compensation from Tools Libary info.
;                                       10  = Automatic Tool Change (ATC)
;                                             This mode manages a rack of slots using place/side & pick/top approach.
;                                             If there is a loaded tool it will be placed.
;                                             If there is a requested tool it will be picked.
;                                             If the tool length measurement/compensation are enabled they are automaticallly performed.
;                                       11  = Automatic Tool Change (ATC)
;                                             This mode manages a rack of slots using place/top & pick/top approach.
;                                             If there is a loaded tool it will be placed.
;                                             If there is a requested tool it will be picked.
;                                             If the tool length measurement/compensation are enabled they are automaticallly performed.
;   #6001           TOOL_CHANGE [GEN] : Features:
;                                       0   = Back to work position is OFF.
;                                       1   = Back to work position is ON.
;   #6002           TOOL_CHANGE [MTC] : Change position X (MCS)
;   #6003           TOOL_CHANGE [MTC] : Change position Y (MCS)
;   #6004           TOOL_CHANGE [MTC] : Change position Z (MCS)
;   #6005           TOOL_CHANGE [TLS] : Sensor safe position Z (MCS)
;   #6006           TOOL_CHANGE [TLS] : Sensor top/center position X (MCS)
;   #6007           TOOL_CHANGE [TLS] : Sensor top/center position Y (MCS)
;   #6008           TOOL_CHANGE [TLS] : Sensor top/center position Z (MCS)
;   #6009           TOOL_CHANGE [GEN] : Feed during tool change procedure
;   #6010           TOOL_CHANGE [TLS] : Z approaching sensor position (MCS, reached with feed #6011)
;   #6011           TOOL_CHANGE [TLS] : Z feed to sensor approaching (FAST)
;   #6012           TOOL_CHANGE [TLS] : Z feed to 1st probe input capture (SLOW)
;   #6013           TOOL_CHANGE [TLS] : Z feed to 2nd probe input capture (VERY SLOW)
;   #6014           TOOL_CHANGE [TLS] : Z up movement after 1st touch capture (REL)
;   #6015           TOOL_CHANGE [TLS] : Minimum tool lenght accepted
;   #6016           TOOL_CHANGE [TLS] : Enable tool length compensation (only for tool change type 1)
;   #6017           TOOL_CHANGE [TLS] : Probe cleaning output
;   #6018           TOOL_CHANGE [TLS] : Probe cleaning time
;   #6019           TOOL_CHANGE [___] : !!! RESERVED FOR FUTURE USE !!!
;   #6020           TOOL_CHANGE [ATC] : Magazine type:
;                                       0 = none magazine
;                                       1 = magazine with 2 control outputs (open and close with individual pulse output)
;   #6021           TOOL_CHANGE [ATC] : Magazine input open
;   #6022           TOOL_CHANGE [ATC] : Magazine input closed
;   #6023           TOOL_CHANGE [ATC] : Magazine input timeout
;   #6024           TOOL_CHANGE [ATC] : Magazine output time
;   #6025           TOOL_CHANGE [ATC] : Magazine output open
;   #6026           TOOL_CHANGE [ATC] : Magazine output close
;   #6027           TOOL_CHANGE [GEN] : Output for up/down of the chips aspiration cover
;   #6028           TOOL_CHANGE [ATC] : Rotative clamp position (X with axis orientation 2, Y with axis orientation 3)
;   #6029..#6035    TOOL_CHANGE [___] : !!! RESERVED FOR FUTURE USE !!!
;   #6036           TOOL_CHANGE [ATC] : Fast unload tool holder distance
;   #6037           TOOL_CHANGE [ATC] : Slow unload tool holder distance
;   #6038           TOOL_CHANGE [ATC] : Slow unload tool holder feed
;   #6039           TOOL_CHANGE [ATC] : Fast load tool holder distance
;   #6040           TOOL_CHANGE [ATC] : Medium load tool holder distance
;   #6041           TOOL_CHANGE [ATC] : Medium load tool holder feed
;   #6042           TOOL_CHANGE [ATC] : Final load tool holder feed
;   #6043           TOOL_CHANGE [ATC] : Cone load unload time (used only if "Cone load unload input" is zero)
;   #6044           TOOL_CHANGE [ATC] : Cone load unload input (used only for a NO button and detect the release. You must have a macro that start procedure)
;   #6045           TOOL_CHANGE [ATC] : Cone cleaning blow output
;   #6046           TOOL_CHANGE [ATC] : Bearing cleaning blow output
;   #6047           TOOL_CHANGE [ATC] : Cone grip output
;   #6048           TOOL_CHANGE [ATC] : Cone grip output time
;   #6049           TOOL_CHANGE [ATC] : Slots positions parameters address
;                                       If undefined (#0) or set to 0 the default address is 6061 for maximum 13 slots
;   #6050           TOOL_CHANGE [ATC] : Safe Z
;   #6051           TOOL_CHANGE [ATC] : Unlock input
;   #6052           TOOL_CHANGE [ATC] : Unlock output
;   #6053           TOOL_CHANGE [ATC] : Unlock timeout
;	#6054			TOOL_CHANGE [ATC] : Clamp position (Y with axis orientation 0 or 2, X with 1 or 3)
;   #6055           TOOL_CHANGE [ATC] : Pick distance Z
;   #6056           TOOL_CHANGE [ATC] : Enable tool-setter
;   #6057           TOOL_CHANGE [ATC] : Spindle s1 (tool-holder attached correctly)
;   #6058           TOOL_CHANGE [ATC] : Spindle s2 (collet open)
;   #6059           TOOL_CHANGE [ATC] : Slot axis orientation (0 = linear along X | 1 = linear along Y | 2 = rotative with Y approach | 3 = rotative with X approach)
;   #6060           TOOL_CHANGE [ATC] : Slots number
;   #6061..#6099    TOOL_CHANGE [ATC] : Slots positions parameters (default, with #6049 = #0 or 0, for 1 to 13 slots) (MCS)
;
O6
    ; === DISCLAIMER ===
    ;
    ; This macro is provided 'AS IS', without WARRANTY of any kind, express or implied.
    ; The macro is provided as an example only.
    ; Use this macro at your own risk.
    ;
    ; NOTE: You can comment line 157 or delete this ADVICE but anyway you will accept the macro DISCLAIMER of the original code.
    ;
    IF [EXISTS[#<tc.disclaimer.showed>] EQ 0] THEN10
        #<tc.disclaimer.showed>=1
;       M109 P"<B>DISCLAIMER</B><BR><BR>This macro is provided 'AS IS'</B>,<BR>without WARRANTY of any kind, express or implied.<BR><BR>The macro is provided as an example only.<BR><BR>Use this macro at your own risk." Q2
    END10

    ; store loaded/requested tool/slot ID
    #<tc.requested.tool_id>=#1
    #<tc.requested.slot_id>=#2
    #<tc.loaded.tool_id>=#3
    #<tc.loaded.slot_id>=#4

    ; recover macro optional action when macro is called with G65
    IF [[#5 EQ #0] OR [#5 EQ 0]] THEN10
        #<tc.macro.option>=0
    ELSE10
        #<tc.macro.option>=#5
    END10

    ; recover macro optional magazine argument available when macro called with G65
    IF [EXISTS[#<_args.K>]] THEN10
        #<tc.do_not_close_magazine>=1
    ELSE10
        #<tc.do_not_close_magazine>=0
    END10

    ; initialize ATC parameters
    CALL P"TC_INIT"

    ; store actual PLC states in local variables
    #<_saved.5001>=#5001        ; current TCP position X
    #<_saved.5002>=#5002        ; current TCP position Y
    #<_saved.5003>=#5003        ; current TCP position Z
    #<_saved.5004>=#5004        ; current position A
    #<_saved.5005>=#5005        ; current position B
    #<_saved.5006>=#5006        ; current position C
    #<_saved.5101>=#5101        ; active G-codes - group 01: G00, G01, ...
    #<_saved.5130>=#5130        ; active feed rate (F)
    #<_saved.5151>=#5151        ; active M-codes: M3, M4, M5
    #<_saved.5153>=#5153        ; active M-codes: M7, M9
    #<_saved.5154>=#5154        ; active M-codes: M8, M9
    #<_saved.5103>=#5103        ; active G-codes - group 03: G90, G91

    ; store actual PLC states in global variables
    #<saved.5136>=#5136         ; active feed override mode (P argument of M50)

    ; set absolute coordinate
    G90

    ; check if last G-codes group 01 used instruction was a G00/G01 otherwise, to prevent
    ; an error when setting G#<_saved.5101>, set it to G80 (cancel motion mode)
    IF [[#<_saved.5101> NE 0] AND [#<_saved.5101> NE 1]] THEN #<_saved.5101>=80

    ; check if required only a tool-setter procedure by ATCM macro
    IF [#<tc.macro.option> EQ 3] THEN10
        CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1
        CALL P"TC_TOUCH_PROBE_EXTERNAL_REQUEST"
        ; enable tool length compensation if enabled
        IF [#<tc.enable_tool_length_compensation> EQ 1] THEN G43 H#<tc.requested.tool_id>
        GOTO10
    ELIF [#<tc.macro.option> EQ 4] THEN10
        CALL P"TC_MAGAZINE_OPEN"
        GOTO10
    ELIF [#<tc.macro.option> EQ 5] THEN10
        #<tc.do_not_close_magazine>=0
        CALL P"TC_MAGAZINE_CLOSE"
        GOTO10
    ELIF [#<tc.macro.option> EQ 6] THEN10
        CALL P"TC_MAGAZINE_UPDATE_STATE"
        GOTO10
    ELIF [#<tc.macro.option> EQ 7] THEN10
        CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1
        CALL P"TC_TOGGLE_CONE_LOAD_UNLOAD"
        GOTO10
    END10

    ; check if tool change type = 0 then execute sub MANUAL_TOOL_CHANGE_0
    IF [#<tc.type> EQ 0] THEN10
        CALL P"MANUAL_TOOL_CHANGE_0"
        GOTO10
    END10

    ; avoid any activity if tool change type is 10 or 11 and requested tool is same of loaded tool
    IF [[#<tc.type> EQ 10] OR [#<tc.type> EQ 11]] THEN10
        IF [[#<tc.requested.tool_id> EQ 0] AND [#<tc.loaded.tool_id> EQ 0]] THEN P"TC_EXIT" E11
        IF [[#<tc.requested.tool_id> EQ #<tc.loaded.tool_id>]] THEN11
            ; enable tool length compensation if enabled
            IF [#<tc.enable_tool_length_compensation> EQ 1] THEN G43 H#<tc.requested.tool_id>
            GOTO10
        END11
    END10

    ; notice start change procedure to PLC
    M107

    ; show main procedure message for 1s
    M109 P"Tool change procedure" Q4
    G04 P1

    ; set position of axes type "rotary axes for head"
    IF [[#<cnc.a.type>] EQ #<axis.type.rotary_head>] THEN10
        G49
        G53 G01 A0 F#<tc.feed>
    END10
    IF [[#<cnc.b.type>] EQ #<axis.type.rotary_head>] THEN10
        G49
        G53 G01 B0 F#<tc.feed>
    END10
    IF [[#<cnc.c.type>] EQ #<axis.type.rotary_head>] THEN10
        G49
        G53 G01 C0 F#<tc.feed>
    END10

    ; check if Tool change type = 1 the execute sub MANUAL_TOOL_CHANGE_1
    IF [#<tc.type> EQ 1] THEN CALL P"MANUAL_TOOL_CHANGE_1"

    ; check if Tool change type = 2 the execute sub MANUAL_TOOL_CHANGE_2
    IF [#<tc.type> EQ 2] THEN CALL P"MANUAL_TOOL_CHANGE_2"

    ; check if Tool change type = 10 the execute sub AUTOMATIC_TOOL_CHANGE_10
    IF [#<tc.type> EQ 10] THEN CALL P"AUTOMATIC_TOOL_CHANGE_10"

    ; check if Tool change type = 10 the execute sub AUTOMATIC_TOOL_CHANGE_10
    IF [#<tc.type> EQ 11] THEN CALL P"AUTOMATIC_TOOL_CHANGE_11"

    ; move back to saved work position
    IF [#<tc.features> EQ 1] THEN10
        G01 X#<_saved.5001> Y#<_saved.5002>
        G01 Z#<_saved.5003>
        IF [[#<cnc.a.type>] EQ #<axis.type.rotary_head>] THEN G01 A#<_saved.5004>
        IF [[#<cnc.b.type>] EQ #<axis.type.rotary_head>] THEN G01 B#<_saved.5005>
        IF [[#<cnc.c.type>] EQ #<axis.type.rotary_head>] THEN G01 C#<_saved.5005>
    END10

    ( restore saved states )
    
N10
    ; move down chips aspiration cover
    CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A0

    ; restore spindle & coolants states
    IF [#<_saved.5151> EQ 3] THEN M03
    IF [#<_saved.5151> EQ 4] THEN M04
    IF [#<_saved.5153> EQ 7] THEN M07
    IF [#<_saved.5154> EQ 8] THEN M08

    ; restore save feed
    F#<_saved.5130>

    ; restore g-code group 03 state
    G#<_saved.5103>

    ; restore g-code group 01 state
    G#<_saved.5101>

    ; reset HUD message
    M109 P"" Q4

    ; notice end change procedure to PLC
    M108

M99

; TOOL CHANGE EXIT
;
; Inputs:
;
;   Ee  #8          Exit code
;   Aa  #1          Undefined compulsory protected parameter
;
SUB "TC_EXIT"

    ; check for error code
    IF [#<_args.e> EQ 0] THEN M99

    ; reset HUD message
    IF [#<tc.enable_hud> EQ 1] THEN M109 P"" Q4

    ; notice end change procedure to PLC
    M108

    ; move down chips aspiration cover
    CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A0

    ; show message error
    IF [#<_args.e> EQ  1] THEN M109 P"compulsory protected parameter ##<_args.a> is undefined!" Q-1
    IF [#<_args.e> EQ  2] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was found already tripped before to start approach movements to probe!</B><BR>" Q1
    IF [#<_args.e> EQ  3] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was tripped during approach movements to probe!</B><BR>" Q1
    IF [#<_args.e> EQ  4] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was found already tripped before to start 1st touch movements!</B><BR>" Q1
    IF [#<_args.e> EQ  5] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was not found during 1st touch movements!</B><BR>" Q1
    IF [#<_args.e> EQ  6] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was found already tripped before to start 2nd touch movements!</B><BR>" Q1
    IF [#<_args.e> EQ  7] THEN M109 P"<B>Error during measure of tool length</B><BR><BR>Sensor was not found during 2nd touch movements!</B><BR>" Q1
    IF [#<_args.e> EQ  8] THEN M109 P"compulsory protected parameter ##<_args.a> has a wrong value!" Q-1
    IF [#<_args.e> EQ  9] THEN M109 P"tool change require a PLACE slot number not in range (1..#<tc.atc.slots>)" Q-1
    IF [#<_args.e> EQ 10] THEN M109 P"tool change require a PICK slot number not in range (1..#<tc.atc.slots>)" Q-1
    IF [#<_args.e> EQ 11] THEN M109 P"tool change require a PICK or PLACE or PLACE/PICK action" Q-1
    IF [#<_args.e> EQ 12] THEN M109 P"<B>TOOL T#<tc.requested.tool_id> PICK ERROR</B><BR><BR>Collet Unlock Input is LOW<BR>" Q1
    IF [#<_args.e> EQ 13] THEN M109 P"<B>TOOL T#<tc.requested.tool_id> PICK ERROR</B><BR><BR>Cone present Input is LOW<BR>" Q1
    IF [#<_args.e> EQ 14] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PLACE ERROR</B><BR><BR>Spindle S1 is HIGH<BR>" Q1
    IF [#<_args.e> EQ 15] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PLACE ERROR</B><BR><BR>Spindle S2 is LOW<BR>" Q1
    IF [#<_args.e> EQ 16] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PICK ERROR</B><BR><BR>Spindle S1 is LOW<BR>" Q1
    IF [#<_args.e> EQ 17] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PICK ERROR</B><BR><BR>Spindle S2 is HIGH<BR>" Q1
    IF [#<_args.e> EQ 18] THEN M109 P"<B>TOOL T#<tc.requested.tool_id> PICK ERROR</B><BR><BR>Collet Unlock Input is LOW<BR>" Q1
    IF [#<_args.e> EQ 19] THEN M109 P"<B>TOOL T#<tc.requested.tool_id> PLACE ERROR</B><BR><BR>Collet Unlock Input is HIGH<BR>" Q1
    IF [#<_args.e> EQ 20] THEN M109 P"Error in magazine input recovering states" Q1
    IF [#<_args.e> EQ 21] THEN M109 P"Magazine not reached open state<BR>in the specified time" Q1
    IF [#<_args.e> EQ 22] THEN M109 P"Magazine in wrong state<BR><BR>Opened/Closed inputs are HIGH" Q1
    IF [#<_args.e> EQ 23] THEN M109 P"Magazine not reached closed state<BR>in the specified time" Q1
    IF [#<_args.e> EQ 24] THEN M109 P"Magazine in wrong state<BR><BR>Opened/Closed inputs are HIGH" Q1
    IF [#<_args.e> EQ 25] THEN M109 P"Unable to get cone load/unload input state" Q1
    
    M109 P"<B>Generic Error<BR><BR>Unknown error #<_args.e>!</B>" Q1

ENDSUB

; MANUAL TOOL CHANGE TYPE 0
;
; This mode only notice to the PLC about the loaded tool ID.
; No other actions or movments will be done.
;
SUB "MANUAL_TOOL_CHANGE_0"

    ; notice to PLC the loaded tool ID
    M61 Q#<tc.requested.tool_id>

ENDSUB

; MANUAL TOOL CHANGE TYPE 1
;
; Manual Tool Change (MTC) with tool length probing:
;   a] Moves to tool-setter position and measures the loaded tool length.
;   b] Moves to tool change position and show info about tool to manually change.
;   c] Waits for the manual tool change by the operator which confirm that change is done.
;   d] Moves to tool-setter position to measures the length of the new tool.
;   e] Calcs the difference and uses this value as tool length compensation.
;
SUB "MANUAL_TOOL_CHANGE_1"

    ; disable spindle, flood & mist
    M05 M09

    ; move up chips aspiration cover
    CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1

    ; initialize local variabiles
    #<_measure1_>=0     ; measured tool offset Z

	; save current z corrector
	#<_current_z_corrector_>=#5422

    ; disable tool length compensation to avoid software limits error
    G49

    ; measure of tool to unload : approaching to probe
    IF [#<tc.enable_hud> EQ 1] THEN M109 P"Measure of tool to unload : approacing to probe..." Q4

    ; call touch probe procedure
    CALL P"TC_TOUCH_PROBE" A#<tc.tls.top_center_position.z> B#<tc.tls.1st_capture_feed> C#<tc.tls.up_movement_after_1st_touch> D#<tc.tls.minimum_tool_lenght_accepted> E#<tc.tls.2nd_capture_feed>

    ; calculate the tool length offset as the difference between when the sensor was tripped and the sensor Z position.
    #<_measure1_> = [#5713 - #<tc.tls.top_center_position.z>]

    ; move to sensor safe position Z
    G53 G01 Z#<tc.tls.safe_position.z> F#<tc.feed>

    ; move to tool change position
    G53 G01 Z#<tc.mtc.change_position.z> F#<tc.feed>
    G53 G01 X#<tc.mtc.change_position.x> Y#<tc.mtc.change_position.y>

    ; show to the user info about required tool and wait for change resume to confirm change
    M109 P"<BR>Insert tool <B>T#<tc.requested.tool_id></B><BR><@TI=#<tc.requested.tool_id>><BR>" Q2
    G04 P1

    ; notice to PLC the loaded tool ID
    M61 Q#<tc.requested.tool_id>

    ; measure of loaded tool : approaching to probe
    IF [#<tc.enable_hud> EQ 1] THEN M109 P"Measure of loaded tool : approacing to probe..." Q4

    ; call touch probe procedure
    CALL P"TC_TOUCH_PROBE" A#<tc.tls.top_center_position.z> B#<tc.tls.1st_capture_feed> C#<tc.tls.up_movement_after_1st_touch> D#<tc.tls.minimum_tool_lenght_accepted> E#<tc.tls.2nd_capture_feed>

    ; calculate the tool length offset as the difference between when the sensor was tripped and the sensor Z position.
    #<_measure2_> = [#5713 - #<tc.tls.top_center_position.z>]

    ; move to sensor safe position Z
    G53 G01 Z#<tc.tls.safe_position.z> F#<tc.feed>

    ; calc compensation to do
    #<_toll_length_difference_>=[#<_measure2_>-#<_measure1_>+#<_current_z_corrector_>]

	; avoid preventive calculation of the tool lenght difference bypassing it till the 2nd touch was made
    IF [#5700 NE #<math.nan>] THEN10

        ; enable dynamic tool length compensation (without use of tools library)
        G43.1 Z#<_toll_length_difference_>

    END10

ENDSUB

; MANUAL TOOL CHANGE TYPE 2
;
; Manual Tool Change (MTC) with tool length from Tools Library info:
;   a] Moves to tool change position and show info about tool to manually change.
;   b] Waits for the manual tool change by the operator which confirm that change is done.
;   c] If enabled applies the tool length compensation from Tools Libary info.
;
SUB "MANUAL_TOOL_CHANGE_2"

    ; check if a different tool should be inserted.
    IF [#<tc.requested.tool_id> NE #<tc.loaded.tool_id>] THEN10

        ; disable spindle, flood & mist
        M05 M09

        ; move up chips aspiration cover
        CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1

        ; disable tool length compensation to avoid software limits error
        G49

        ; move to tool change position
        G53 G01 Z#<tc.mtc.change_position.z> F#<tc.feed>
        G53 G01 X#<tc.mtc.change_position.x> Y#<tc.mtc.change_position.y>

        ; A different tool should be inserted. Display the message to the user.
        M109 P"<BR>Insert tool <B>T#<tc.requested.tool_id></B><BR><@TI=#<tc.requested.tool_id>><BR>" Q2
        G04 P1

        ; notice to PLC the loaded tool ID
        M61 Q#<tc.requested.tool_id>

        ; enable tool length compensation if enabled
        IF [#<tc.enable_tool_length_compensation> EQ 1] THEN G43 H#<tc.requested.tool_id>

    END10

ENDSUB

; AUTOMATIC TOOL CHANGE TYPE 10
;
; This mode manages a rack of slots using place/side & pick/top approach.
; If there is a loaded tool it will be placed.
; If there is a requested tool it will be picked.
; If the tool length measurement/compensation are enabled they are automaticallly performed.
;
SUB "AUTOMATIC_TOOL_CHANGE_10"

    ; checks if slots for the PICK and PLACE actions are valid
    ;
    ; this happen if G-code require a T with a slot higher than available slots to keep it
    IF [[#<tc.loaded.slot_id> LT 0] OR [#<tc.loaded.slot_id> GT #<tc.atc.slots>]] THEN CALL P"TC_EXIT" E9
    IF [[#<tc.requested.slot_id> LT 0] OR [#<tc.requested.slot_id> GT #<tc.atc.slots>]] THEN CALL P"TC_EXIT" E10

    ; move up chips aspiration cover
    CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1

    ; disable tool length compensation to avoid errors in software limits checking
    G49

    ; check actions to do
    #<_has.place>=[#<tc.loaded.tool_id> NE 0]       ; evaluate if tool change has place action
    #<_has.pick>=[#<tc.requested.tool_id> NE 0]     ; evaluate if tool change has pick action

    ( loaded tool placing )

    ; check if necessary to place the loaded tool
    IF [#<_has.place>] THEN10

        ; show place info
        IF [#<tc.enable_hud> EQ 1] THEN M109 P"Tool Changing: PLACE of T#<tc.loaded.tool_id>" Q4

        ; move Z to safe position
        G53 G00 Z#<tc.atc.safe.z>

        ; disable spindle, flood & mist
        M05 M09

        ; open magazine
        CALL P"TC_MAGAZINE_OPEN"

        ; move XY to clamp zone slot of loaded tool to place it
        CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M0

        ; move Z to tool drop position
        G53 G00 Z#<tc.atc.slots[#<tc.loaded.slot_id>].z>

        ; move XY into tool place
		CALL P"TC_MOVE_XY_TO_CHANGE_ZONE_SLOT" M0 Q1

        ; unload tool-holder
        CALL P"TC_TOOLHOLDER_UNLOAD"

        ; inform the PLC that the tool has been dropped
        M61 Q0

        ; move Z to safe position
        G53 G00 Z#<tc.atc.safe.z>

        ; turn OFF tool unlock output
        IF [#<tc.atc.unlock.output> GT 0 ] THEN M63 P#<tc.atc.unlock.output>

        ; check if there is not a pick action
        IF [#<_has.pick> EQ 0] THEN11
            ; move XY to clamp zone slot of just now unloaded tool
            CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M0
        END11

    END10

    ( requested tool picking )

    ; check if necessary to pick the requested tool
    IF [#<_has.pick>] THEN10

        ; show pick info
        IF [#<tc.enable_hud> EQ 1] THEN M109 P"Tool Changing: PICK of T#<tc.requested.tool_id>" Q4

        ; check if place action is enabled
        IF [#<_has.place> EQ 0] THEN11

            ; move Z to safe position
            G53 G00 Z#<tc.atc.safe.z>

            ; disable spindle, flood & mist
            M05 M09

            ; open magazine
            CALL P"TC_MAGAZINE_OPEN"

            ; move XY to outer of tool place position
			CALL P"TC_MOVE_XY_TO_CHANGE_ZONE_SLOT" M1 Q0

            ; enable bearing and cone cleaning blow
            CALL P"TC_BEARING_CONE_CLEANING_BLOW" E1
            
        ELSE11
            ; move Z to safe position
            G53 G00 Z#<tc.atc.safe.z>

            ; move XY to outer of tool place position
			CALL P"TC_MOVE_XY_TO_CHANGE_ZONE_SLOT" M1 Q0
        END11

        ; turn ON tool unlock output and wait 1s
        IF [#<tc.atc.unlock.output> GT 0 ] THEN M62 P#<tc.atc.unlock.output>
        G04 P1.0

        ; enable bearing and cone cleaning blow
        CALL P"TC_BEARING_CONE_CLEANING_BLOW" E1

        ; move Z to tool pick position
        #<change.pick.z>=[#<tc.atc.slots[#<tc.requested.slot_id>].z> + #<tc.atc.pick_distance.z>]
        G53 G01 Z#<change.pick.z> F#<tc.feed>

        ; load tool-holder
        CALL P"TC_TOOLHOLDER_LOAD"

        ; disable bearing and cone cleaning blow
        CALL P"TC_BEARING_CONE_CLEANING_BLOW" E0

        ; inform PLC that requested tool has been picked
        M61 Q#<tc.requested.tool_id>

        ; move X or Y to outer of tool place position depending by slot axis orientation
        IF [[#<tc.atc.slot.axis.orientation> EQ 0] OR [#<tc.atc.slot.axis.orientation> EQ 2]] THEN11
			#<change.outer.y> = #<tc.atc.clamp_position>
            G53 G00 Y#<change.outer.y>
        ELSE11
			#<change.outer.x> = #<tc.atc.clamp_position>
            G53 G00 X#<change.outer.x>
        END11

        ; move Z to safe position
        G53 G00 Z#<tc.atc.safe.z>
    END10

    ( new loaded tool measuring and compensation )

    ; check if there was a pick action so a new tool should be in the spindle
    IF [#<_has.pick>] THEN10
    
        ; check if necessary to measure loaded tool
        IF [[[#<tc.atc.enable_tool_setter> EQ 1] AND [#<tc.macro.option> EQ 0]] OR [#<tc.macro.option> EQ 2]] THEN11
            CALL P"TC_TOUCH_PROBE"
        END11

        ; enable tool length compensation if enabled
        IF [#<tc.enable_tool_length_compensation> EQ 1] THEN G43 H#<tc.requested.tool_id>
        
    END10

    ; close magazine
    CALL P"TC_MAGAZINE_CLOSE"

ENDSUB

; AUTOMATIC TOOL CHANGE TYPE 11
;
; This mode manages a rack of slots using place/top & pick/top approach.
; If there is a loaded tool it will be placed.
; If there is a requested tool it will be picked.
; If the tool length measurement/compensation are enabled they are automaticallly performed.
;
SUB "AUTOMATIC_TOOL_CHANGE_11"

    ; checks if slots for the PICK and PLACE actions are valid
    ;
    ; this happen if G-code require a T with a slot higher than available slots to keep it
    IF [[#<tc.loaded.slot_id> LT 0] OR [#<tc.loaded.slot_id> GT #<tc.atc.slots>]] THEN CALL P"TC_EXIT" E9
    IF [[#<tc.requested.slot_id> LT 0] OR [#<tc.requested.slot_id> GT #<tc.atc.slots>]] THEN CALL P"TC_EXIT" E10

    ; move up chips aspiration cover
    CALL P"TC_CHIPS_ASPIRATION_COVER_UP_DW" A1

    ; disable tool length compensation to avoid errors in software limits checking
    G49

    ; check actions to do
    #<_has.place>=[#<tc.loaded.tool_id> NE 0]       ; evaluate if tool change has place action
    #<_has.pick>=[#<tc.requested.tool_id> NE 0]     ; evaluate if tool change has pick action

    ( loaded tool placing )

    ; check if necessary to place the loaded tool
    IF [#<_has.place>] THEN10

        ; show place info
        IF [#<tc.enable_hud> EQ 1] THEN M109 P"Tool Changing: PLACE of T#<tc.loaded.tool_id>" Q4

        ; move Z to safe position
        G53 G00 Z#<tc.atc.safe.z>

        ; disable spindle, flood & mist
        M05 M09

        ; open magazine
        CALL P"TC_MAGAZINE_OPEN"

        ; move XY to clamp zone slot of loaded tool to place it
        CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M0

        ; move XY into tool place
		CALL P"TC_MOVE_XY_TO_CHANGE_ZONE_SLOT" M0 Q1

        ; aproach to tool-holder drop zone
        G53 G01 Z[#<tc.atc.slots[#<tc.loaded.slot_id>].z> + #<tc.atc.fast.unload.tool.holder.distance>] F#<tc.feed>
        G53 G01 Z[#<tc.atc.slots[#<tc.loaded.slot_id>].z> + #<tc.atc.slow.unload.tool.holder.distance>] F#<tc.atc.slow.unload.tool.holder.feed>

        ; unload tool-holder
        CALL P"TC_TOOLHOLDER_UNLOAD"

        ; inform the PLC that the tool has been dropped
        M61 Q0

        ; move Z to safe position
        G53 G00 Z#<tc.atc.safe.z>

        ; turn OFF tool unlock output
        IF [#<tc.atc.unlock.output> GT 0 ] THEN M63 P#<tc.atc.unlock.output>

        ; check if there is not a pick action
        IF [#<_has.pick> EQ 0] THEN11
            ; move XY to clamp zone slot of just now unloaded tool
            CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M0
        END11

    END10

    ( requested tool picking )

    ; check if necessary to pick the requested tool
    IF [#<_has.pick>] THEN10

        ; show pick info
        IF [#<tc.enable_hud> EQ 1] THEN M109 P"Tool Changing: PICK of T#<tc.requested.tool_id>" Q4

        ; check if place action is enabled
        IF [#<_has.place> EQ 0] THEN11

            ; move Z to safe position
            G53 G00 Z#<tc.atc.safe.z>

            ; disable spindle, flood & mist
            M05 M09

            ; open magazine
            CALL P"TC_MAGAZINE_OPEN"

            ; move XY to clamp zone slot of requested tool to pick it
            CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M1

            ; move XY into tool place
			CALL P"TC_MOVE_XY_TO_CHANGE_ZONE_SLOT" M1 Q1
        ELSE11
            ; move XY to outer of tool place position
            G53 G00 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.slots[#<tc.requested.slot_id>].y>
        END11

        ( BEGIN UNLOAD TOOL-HOLDER )

        ; aproach to tool-holder drop zone
        G53 G01 Z[#<tc.atc.slots[#<tc.requested.slot_id>].z> + #<tc.atc.fast.load.tool.holder.distance>] F#<tc.feed>

        ; turn ON tool unlock output
        IF [#<tc.atc.unlock.output> GT 0 ] THEN M62 P#<tc.atc.unlock.output>

        ; enable bearing and cone cleaning blow
        CALL P"TC_BEARING_CONE_CLEANING_BLOW" E1

        ; check if required unlock output feedback
        IF [#<tc.atc.unlock.input> GT 0] THEN11
            ; wait and check for tool unlock input signal with timeout
            M66 P#<tc.atc.unlock.input> L#<wait_input.high> Q#<tc.atc.unlock.timeout>
            IF [#5722 EQ #<wait_input.failure>] THEN M109 P"<B>TOOL T#<tc.requested.tool_id> PICK ERROR</B><BR><BR>Collet Unlock Input is LOW<BR>" Q1
        END11

		; wait and check spindle S1/S2 for S1 LOW & S2 HIGH (tool-holder is released check)
		CALL P"TC_WAIT_AND_CHECK_SPINDLE_S1_S2_FOR_LH"

        ; aproach to tool-holder drop zone
        G53 G01 Z[#<tc.atc.slots[#<tc.requested.slot_id>].z> + #<tc.atc.medium.load.tool.holder.distance>] F#<tc.atc.medium.load.tool.holder.feed>

        ; disable bearing and cone cleaning blow
        CALL P"TC_BEARING_CONE_CLEANING_BLOW" E0

        ; move Z to tool pick position
        G53 G01 Z#<tc.atc.slots[#<tc.requested.slot_id>].z> F#<tc.atc.final.load.tool.holder.feed>

        ; turn OFF tool unlock output and wait 1s
        IF [#<tc.atc.unlock.output> GT 0 ] THEN M63 P#<tc.atc.unlock.output>

        ; check if required unlock output feedback
        IF [#<tc.atc.unlock.input> GT 0] THEN11

            ; wait settle time for P5 input stabilizatin
            G04 P1.0

            ; wait and check for tool unlock input signal with timeout
            M66 P#<tc.atc.unlock.input> L#<wait_input.high> Q#<tc.atc.unlock.timeout>
            IF [#5722 EQ #<wait_input.failure>] THEN12
                M109 P"<B>TOOL T#<tc.requested.tool_id> PICK ERROR</B><BR><BR>Cone present Input is LOW<BR>" Q1
            END12
        END11

        ; cone grip pulse management
        CALL P"TC_CONE_GRIP_PULSE"

        ; inform PLC that requested tool has been picked
        M61 Q#<tc.requested.tool_id>

        ; move Z to safe position
        G53 G01 Z#<tc.atc.safe.z> F#<tc.feed>

        ; move XY to clamp zone slot of requested tool just now loaded
        CALL P"TC_MOVE_XY_TO_CLAMP_ZONE_SLOT" M1

    END10

    ( new loaded tool measuring and compensation )

    ; check if there was a pick action so a new tool should be in the spindle
    IF [#<_has.pick>] THEN10
    
        ; check if necessary to measure loaded tool
        IF [[[#<tc.atc.enable_tool_setter> EQ 1] AND [#<tc.macro.option> EQ 0]] OR [#<tc.macro.option> EQ 2]] THEN11
            CALL P"TC_TOUCH_PROBE"
        END11

        ; enable tool length compensation if enabled
        IF [#<tc.enable_tool_length_compensation> EQ 1] THEN G43 H#<tc.requested.tool_id>
        
    END10

    ; close magazine
    CALL P"TC_MAGAZINE_CLOSE"

ENDSUB

;   TOOL CHANGE CONE GRIP PULSE
;
SUB "TC_CONE_GRIP_PULSE"

    ; check if required cone grip pulse
    IF [#<tc.atc.cone.grip.output> GT 0] THEN10
        G04 P#<tc.atc.cone.grip.output.time>
        M62 P#<tc.atc.cone.grip.output>
        G04 P#<tc.atc.cone.grip.output.time>
        M63 P#<tc.atc.cone.grip.output>
    END10

ENDSUB

;   TOOL CHANGE BEARING/CONE CLEANING BLOW
;
;   Arguments
;       E0  #8      Enabled state: OFF
;       E1  #8      Enabled state: ON
;
SUB "TC_BEARING_CONE_CLEANING_BLOW"

    ; evaluate enabled state
    IF [#8 EQ 0] THEN10

        ; check if required cone clearing blow and put it OFF
        IF [#<tc.atc.cone.cleaning.blow.output> GT 0] THEN11
            M63 P#<tc.atc.cone.cleaning.blow.output>
        END11
        
        ; check if required bearing cleaning blow and put it OFF
        IF [#<tc.atc.bearing.cleaning.blow.output> GT 0] THEN11
            M63 P#<tc.atc.bearing.cleaning.blow.output>
        END11
    
    ELSE10

        ; check if required cone clearing blow and put it ON
        IF [#<tc.atc.cone.cleaning.blow.output> GT 0] THEN11
            M62 P#<tc.atc.cone.cleaning.blow.output>
        END11

        ; check if required bearing cleaning blow and put it ON
        IF [#<tc.atc.bearing.cleaning.blow.output> GT 0] THEN11
            M62 P#<tc.atc.bearing.cleaning.blow.output>
        END11
    
    END10

ENDSUB

;   TOOL CHANGE WAIT AND CHECK SPINDLE S1/S2 FOR S1 LOW & S2 HIGH 
;
SUB "TC_WAIT_AND_CHECK_SPINDLE_S1_S2_FOR_LH"

    ; check if required spindle S1/S2 management
    IF [[#<tc.atc.spindle.s1> GT 0] AND [#<tc.atc.spindle.s2> GT 0]] THEN10
        ; wait and check for spindle S1/S2 management
        M66 P#<tc.atc.spindle.s1> L#<wait_input.low> Q#<tc.atc.unlock.timeout>
        IF [#5722 EQ #<wait_input.failure>] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PLACE ERROR</B><BR><BR>Spindle S1 is HIGH<BR>" Q1
        M66 P#<tc.atc.spindle.s2> L#<wait_input.high> Q#<tc.atc.unlock.timeout>
        IF [#5722 EQ #<wait_input.failure>] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PLACE ERROR</B><BR><BR>Spindle S2 is LOW<BR>" Q1
    END10

ENDSUB

;   TOOL CHANGE WAIT AND CHECK SPINDLE S1/S2 FOR S1 HIGH & S2 LOW
;
SUB "TC_WAIT_AND_CHECK_SPINDLE_S1_S2_FOR_HL"

    ; check if required spindle S1/S2 management
    IF [[#<tc.atc.spindle.s1> GT 0] AND [#<tc.atc.spindle.s2> GT 0]] THEN10
        ; wait and check for spindle S1/S2 management
        M66 P#<tc.atc.spindle.s1> L#<wait_input.high> Q#<tc.atc.unlock.timeout>
        IF [#5722 EQ #<wait_input.failure>] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PICK ERROR</B><BR><BR>Spindle S1 is LOW<BR>" Q1
        M66 P#<tc.atc.spindle.s2> L#<wait_input.low> Q#<tc.atc.unlock.timeout>
        IF [#5722 EQ #<wait_input.failure>] THEN M109 P"<B>TOOL T#<tc.loaded.tool_id> PICK ERROR</B><BR><BR>Spindle S2 is HIGH<BR>" Q1
    END10

ENDSUB

;   TOOL CHANGE MOVE XY TO CLAMP ZONE SLOT FOR LOADED OR SELECTED TOOL
;
;   Arguments
;       M0  #13     Required position: for the loaded tool
;       M1  #13     Required position: for the requested tool
;
SUB "TC_MOVE_XY_TO_CLAMP_ZONE_SLOT"

    ; evaluate required position
    IF [#13 EQ 0] THEN10
    
        ; move XY to outer of tool place position depending by slot axis orientation
        IF [#<tc.atc.slot.axis.orientation> EQ 0] THEN11
			; linear along X
			G53 G00 Y#<tc.atc.clamp_position>
            G53 G00 X#<tc.atc.slots[#<tc.loaded.slot_id>].x>
        END11
		IF [#<tc.atc.slot.axis.orientation> EQ 1] THEN11
			; linear along Y
			G53 G00 X#<tc.atc.clamp_position>
            G53 G00 Y#<tc.atc.slots[#<tc.loaded.slot_id>].y>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 2] THEN11
			; rotative with Y approach
			G53 G00 Y#<tc.atc.clamp_position> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].x>
        END11
		IF [#<tc.atc.slot.axis.orientation> EQ 3] THEN11
			; rotative with X approach
			G53 G00 X#<tc.atc.clamp_position> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].y>
        END11
    ELSE10

        ; move XY to outer of tool place position depending by slot axis orientation
        IF [#<tc.atc.slot.axis.orientation> EQ 0] THEN11
			; linear along X
			G53 G00 Y#<tc.atc.clamp_position>
            G53 G00 X#<tc.atc.slots[#<tc.requested.slot_id>].x>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 1] THEN11
			; linear along Y
			G53 G00 X#<tc.atc.clamp_position>
            G53 G00 Y#<tc.atc.slots[#<tc.requested.slot_id>].y>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 2] THEN11
			; rotative with Y approach
			G53 G00 Y#<tc.atc.clamp_position> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].x>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 3] THEN11
			; rotative with X approach
			G53 G00 X#<tc.atc.clamp_position> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].y>
        END11
    END10

ENDSUB

;   TOOL CHANGE MOVE XY TO CHANGE ZONE SLOT FOR LOADED OR SELECTED TOOL
;
;   Arguments
;       M0  #13     Required position: for the loaded tool
;       M1  #13     Required position: for the requested tool
;       Q0  #17     Use G0
;       Q1  #17     Use G1 and #<tc.feed> value
SUB "TC_MOVE_XY_TO_CHANGE_ZONE_SLOT"

    ; evaluate required position
    IF [#13 EQ 0] THEN10
        ; move XY to outer of tool place position depending by slot axis orientation
        IF [#<tc.atc.slot.axis.orientation> EQ 0] THEN11
			; linear along X
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.slots[#<tc.loaded.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.slots[#<tc.loaded.slot_id>].y>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 1] THEN11
			; linear along Y
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.slots[#<tc.loaded.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.slots[#<tc.loaded.slot_id>].y>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 2] THEN11
			; rotative with Y approach
			IF [#17 NE 0] THEN12
				G53 G1 Y#<tc.atc.slots[#<tc.loaded.slot_id>].y> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].x> F#<tc.feed>
			ELSE12
				G53 G0 Y#<tc.atc.slots[#<tc.loaded.slot_id>].y> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].x>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 3] THEN11
			; rotative with X approach
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.loaded.slot_id>].x> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.loaded.slot_id>].y>
			END12
        END11
    ELSE10
        ; move XY to outer of tool place position depending by slot axis orientation
        IF [#<tc.atc.slot.axis.orientation> EQ 0] THEN11
			; linear along X
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.slots[#<tc.requested.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.slots[#<tc.requested.slot_id>].y>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 1] THEN11
			; linear along Y
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.slots[#<tc.requested.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.slots[#<tc.requested.slot_id>].y>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 2] THEN11
			; rotative with Y approach
			IF [#17 NE 0] THEN12
				G53 G1 Y#<tc.atc.slots[#<tc.requested.slot_id>].y> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].x> F#<tc.feed>
			ELSE12
				G53 G0 Y#<tc.atc.slots[#<tc.requested.slot_id>].y> X#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].x>
			END12
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 3] THEN11
			; rotative with X approach
			IF [#17 NE 0] THEN12
				G53 G1 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].y> F#<tc.feed>
			ELSE12
				G53 G0 X#<tc.atc.slots[#<tc.requested.slot_id>].x> Y#<tc.atc.rotative_clamp_position> A#<tc.atc.slots[#<tc.requested.slot_id>].y>
			END12
        END11
	END10

ENDSUB
;   TOOL CHANGE MOVE TO SAFE Z CLAMP ZONE TOOL-SETTER
;
SUB "TC_MOVE_TO_SAFE_Z_CLAMP_ZONE_TOOLSETTER"

    ; move Z to safe position
    G53 G00 Z#<tc.tls.safe_position.z>

	; check mode type
    IF [[#<tc.type> EQ 10] OR [#<tc.type> EQ 11]] THEN10

        ; move XY to outer of tool-setter position depending by slot axis orientation
        IF [#<tc.atc.slot.axis.orientation> EQ 0] THEN11
			G53 G00 Y#<tc.atc.clamp_position>
            G53 G00 X#<tc.tls.top_center_position.x>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 1] THEN11
			G53 G00 X#<tc.atc.clamp_position>
            G53 G00 Y#<tc.tls.top_center_position.y>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 2] THEN11
			G53 G00 Y#<tc.atc.clamp_position> X#<tc.atc.rotative_clamp_position>
        END11
        IF [#<tc.atc.slot.axis.orientation> EQ 3] THEN11
			G53 G00 X#<tc.atc.clamp_position> Y#<tc.atc.rotative_clamp_position>
        END11
    END10

ENDSUB

....
La macro di cambio utensile di rosettacnc supporta MTC, ATC rotatori e lineari, gestione carters, gestione aspiratori, etc.etc
E' molto completa ma se non si parametrizzano i suoi dati di input e non si configura come deve lavorare darà sicuramente
errore.

A questo punto se non hai nessun tipo di cambio utensile meglio andare nei parametri scheda CNC,
cartella Cambio Utensile ed impostare Tipo su Nessuno.

Avatar utente
arm
Senior
Senior
Messaggi: 2619
Iscritto il: venerdì 18 maggio 2007, 13:21
Località: arborea (OR) e firenze
Contatta:

Re: errore ripartenza dalla linea gcode

Messaggio da arm » sabato 12 giugno 2021, 15:27

Quando crei il gcode con Fusion, verifica se hai la possibilità di inibire "Use M6" nell'elenco "property" quando si apre la finestra del postprocessore. COn il prostprocessore di mach3 c'è questa possibilità e non ti inserisce la riga di codice M6 nel gcode
Non hai i permessi necessari per visualizzare i file e le foto allegati in questo messaggio. Per visualizzare tali file devi registrarti ed effettuare il Login
L'arte è l'espressione di piacere che l'uomo prova nel lavoro. (William Morris artigiano - architetto 1834-1896)
Cnc 3 assi per alluminio, 600x350, ponte fisso
Cnc 3 assi+1, 1200x800, doppia vite
Fresatrice verticale per acciaio

Rispondi

Torna a “RosettaCNC”