|
Executable Block Statements - CONVERT
The new function CONVERT was added to round a double-precision number and to verify the number of decimal digits.
Syntax:
CONVERT INVAR OUTVAR NUM ;
Input: |
INVAR: |
Any variable in the EXF file (i.e.: X_CURPOS, MYVAR). |
Output: |
OUTVAR: |
Any variable in the EXF file (including the input variable). This variable is equal to INVAR, except that it is rounded to the NUMth decimal digit. |
NUM: |
Number of decimal digits as defined in the FORMAT of INVAR in the DFPOST. |
Notes:
-
All variables must appear.
-
The order of the variables must be as described above.
Usage:
Since most of the calculations in the Post should be as accurate as possible, variables should normally not be CONVERTed (e.g. rotation angles, DFPOST scale factor).
In some cases, calculations should be done on the data sent to the machine (e.g. the distance between two points).
In these cases, the variables should be CONVERTed, so their internal representation will fit their output format.
Example: - calculate the distance between two machine coordinates:
DFPOST FORMAT: 3,3,3,3,YES,YES
Before CONVERT:
TOOLPATH |
G-code |
Internal |
|
XOLD |
100.0004 |
100.000 |
100.00040.... |
XNEW |
109.9996 |
110.000 |
109.99960.... |
XNEW-XOLD |
9.9992 |
9.999 |
9.99920.... |
CONVERT XOLD XOLD N ;
CONVERT XNEW XNEW N
After CONVERT:
TOOLPATH |
G-code |
Internal |
|
XOLD |
100.0004 |
100.000 |
100.00000.... |
XNEW |
109.9996 |
110.000 |
100.00000.... |
XNEW-XOLD |
10.0000 |
10.000 |
10.00000.... |
Notes:
-
Note the difference in the internal representation.
-
The representation of OUTVAR will be according to its FORMAT. If the FORMAT of INVAR and OUTVAR is the same, OUTVAR will "look" like INVAR. Internally, however, OUTVAR will have only zeroes after the last visible digit.
Limitations:
The convert function can be used only for variables where the total number of digits (as defined in the DFPOST) does not exceed 9.
The total number of digits is: "Max integer part" + "Max fractional part".
Example:
FORMAT |
Internal representation |
NUM |
|
INVAR |
OUTVAR |
||
4,2 |
13.200000... |
13.2000... |
2 |
4,2 |
13.210000... |
13.2100... |
2 |
4,3 |
413.210060... |
413.2100... |
3 |
5,8 |
3.200000... |
--> error |
|
5,8 |
19413.213060... |
--> error |
|