![]() |
TG Motion
version 502 - 4034/906 cnc 126
|
TG Motion uses several G-code extensions to simplify G-code programming.
There are 100 parameters (P00 - P99) which can be used instead of fixed numerical values in any G-code address. All the values are expressed as floating point values with precision of 15-17 digits (float64_t precision).
During G-code execution system uses the value stored in the parameter. Before use, the value should be defined in an assignment.
Mathematic expression can contain:
angle is in degreesangle is in degreesangle is in degreesval val address (note address must be > 0)address (note address must be > 0)arg as integer value to PLC memory at address (note address must be > 0). Note that WritePLCLong must be on the right side of an assignment. It returns the previous value in the PLC memory. arg as float64_t floating point value to PLC memory at address (note address must be > 0). Must be on the right side of an assignment.Expressions can be entered directly after the address letter:
Or as an assignment to a parameter:
Any block of G-code text can act as a subroutine. Subroutine starts with a label or line number and ends with M17 or RETURN. The label is text in the begin of G29 comment function or can be declared independently on a separate line, then it must end with colon :
Functions G25, G26 or keyword CALL can be used to call the subroutine. Subroutines must be in the same G-code file as their call(s).
The same meaning with independent label:
Using line number N:
There are two loop program constructs available: FOR loop and WHILE loop.
FOR loop syntax is:
FOR initial_value TO end_value [STEP step_value]
... loop body
END
Example:
Every FOR loop must end with keyword END.
WHILE loop syntax is:
WHILE condition
.. loop body
END
Example:
The condition could be:
| Symbol | Description |
|---|---|
| > | Greater than |
| < | Less than |
| == | Equal to |
| != | Not equal to |
| <> | Not equal to |
| <= | Less or equal to |
| >= | Greater or equal to |
Sometimes it is useful to skip some block of G-code parts depending on some condition. Conditional jumps are used for this situation.
Syntax is:
IF condition THEN
...
ELSE
...
END
If the condition after the IF keyword is met, the code till ELSE is executed, otherwise the code between ELSE and END is executed.
Example:
Conditional jumps can be used to exit from loop, exit from subroutine or continue loop on a next iteration:
IF condition BREAK - if the condition is valid, exit from the loop and continues program execution after the END keyword of the loop.IF condition RETURN - if the condition is valid, exit from subroutineIF condition CONTINUE - if the condition is valid, slip the rest of loop body and goes to the next loop iteration