Interpretation of G code?

  • chen1234
  • chen1234's Avatar Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
22 Nov 2021 05:38 #227269 by chen1234
Interpretation of G code? was created by chen1234
I have an NC code, it may not be suitable for cnc code.

This code may be different from cnc when it is interpreted.

There will be two threads working at the same time during execution, the "parameter assignment thread" and the "G code execution thread".

This NC code contains an M code (M100), its function is to synchronize two threads, so that the G code is executed in line order.
For example, when it is executed (#963=0), it will execute the "parameter assignment thread".
Then execute the "G code execution thread" to run the G code, until the next occurrence (#963=1) will continue to execute the "parameter assignment thread".

I saw on the website that the cnc interpreter executes G code line by line. Does it need this feature (M100)?
Below is the code:
;M100  Synchronous thread

N1
    IF [#800==1]GOTO10        ;(The processing flow jumps to the processing program)
    END_IF
    IF[#801==1]    ;(If not, the processing flow jumps to_ ERR1)
        GOTO2000
    END_IF
    G4X0.5        
GOTO1                                                                                                                                                                                        
;*******************Machining code*********************
N10    M100
    ;#963    ;Floor alarm flag setting
    #733=-550;Z-axis safety coordinate
    #950=8    ;(DEP)
    #970=#750+#752
    #971=#750+#752+#754                                
    #972=#750+#752+#754+#756
    #973=#750+#752+#754+#756+#758
    #740=#750*#751+#752*#753+#754*#755+#756*#757+#758*#759
 ;******************Machining master program*******************
    @9999=5503    ;("End of processing flow!")
    @9998=0 
    IF [#702>#733]GOTO1010         ;(Z axis is greater than safety coordinate, jump to_ ERR2)
    END_IF
    G53 G90 G01  Z#733 F3000        ;Z axis reaches safety coordinate

N300    ;(_ALM:)
    IF[#740<#950] GOTO310    ;(STA)
    ELSE
    GOTO1020        ;Machining depth exceeds
    END_IF
N310    M143    ;(STA)
    M100
    #749=1(The layer counter is set to 1)
    #963=0 ;The number of floors alarm flag is set to 0
     G90 G01 Z=#733 F3000
    IF [#820==1]         ;Determine whether it is a galvanometer light path
        GOTO 400        
    END_IF
    IF[#822==0]         ;If the machining head is in internal mode, skip to_ NBMS
         GOTO 600     
    END_IF
    GOTO330
    ;******************************************
    ;**********************************************
    ;****************************************
    ;********Machining head internal mode part*******

N600            ;NBM
    WAIT PX15.07 V1
    G90 G01X#700 Y#701   F3000;    M140    M100
        G90 G01 A#703 B#704 C#705 F3000    
G90 G01    Z#702    F3000
    M135
    M120    ;(STARTBLOW)
    M141    ;(opening the light)
    M125    ;(M60 Turn on the wear detection function)
    G4X0.5
     WAIT PX13.07 V0 ;Wait for the hole making status to be set to 0
        M145            ;Turn off hole making signal
    GOTO640
N635    M100
    #963=1 ;The number of floors alarm flag is set to 1
    
N640    M100     ;Wait for the allowable feed signal M88
    #749=1    ;(R69=1
    M126
    M142
    M121    ;(M11)
    
    IF [#963==0] 
        GOTO700
    ELSE
    @9999=5501    ;("Note: when the number of layers to be processed ends, press cycle start to continue")
    @9998=1        ;(PLS INPUT ROW QTY)
    ;M0
    #963=0
    END_IF
    
N700    M100
    M132    ;(M82Current process completion signal)
    ;@9999=5502    ;("Current hole machining completed")
    ;@9998=1    ;(PLS INPUT ROW QTY)    
    ;M0
    G4X1
    ;WAIT PX0.03 V1
    IF [#815==1]
    WAIT PX0.03 V1
        GOTO310    ;Process end signal
        ELSE
    GOTO1710
;N735 M0()
    ;@9999=5502    ;("Current hole machining completed")
    ;@9998=0    ;(PLS INPUT ROW QTY)    
    END_IF

N1010    ;_ERR2:    
    @9999=2203    ;("#2 Z_SafePos The variable setting is too small !")
    @9998=1 ;(PLS INPUT ROW QTY)
    GOTO1750
N1020    
    @9999=2201    ("If the machining depth exceeds, please check the parameter setting")
    @9998=1        ;(PLS INPUT ROW QTY)
    GOTO300        ;
N1710    ;END2
    @9999=5503    ;("End of processing flow!")
    @9998=1     ;(PLS INPUT ROW QTY)
    GOTO1750
N1750    ;END
    M100
    M143
    M144
    ;G90G01Z#733F3000
     ;MSG("")
    ;M99
    M30        

Please Log in or Create an account to join the conversation.

More
22 Nov 2021 23:35 #227338 by andypugh
Replied by andypugh on topic Interpretation of G code?
I am not clear what you are trying to do, but G-code is basically a poor fit for multi-threading.

You might be able to do what you want by running a G-code loop and also a Python userspace function or HAL realtime thread in parallel.

(LinuxCNC already does this, for example halui runs in parallel to the motion control in userspace, as do the GUIs.)
The following user(s) said Thank You: chen1234

Please Log in or Create an account to join the conversation.

More
24 Nov 2021 09:20 #227488 by okmarts2
Replied by okmarts2 on topic Interpretation of G code?
I think that G-code is basically a poor fit for multi-threading.ABB HMI CP430B I hope that people can understand this.

Please Log in or Create an account to join the conversation.

More
24 Nov 2021 09:28 #227489 by tommylight
Replied by tommylight on topic Interpretation of G code?
Okmarts2, stop doing that or you get the boot.

Please Log in or Create an account to join the conversation.

Time to create page: 0.059 seconds
Powered by Kunena Forum