From 5fc7c5e959427d61038ca4cfcc4475ff5f0108ac Mon Sep 17 00:00:00 2001 From: John Morris Date: Fri, 16 Oct 2015 17:32:35 -0500 Subject: [PATCH] Implement G52 offsets This implementation of `G52` is intended to be compatible with Fanuc, including sharing offset registers with `G92`. LinuxCNC rs274ngc persists `G92` offsets across machine startup, M02 and M30, but Fanuc does not. Because users familiar with Fanuc may expect the offset to be volatile, and be surprised (perhaps badly) when the offset persists, this patch adds a `.ini` file option to disable it. Other implementation details: - `G52` shares registers with `G92`, `#5210` (flag) and `#5211` through `#5219` (9 axis offsets) - `G52` offsets are applied in the same way as `G92`, after workpiece coordinate offsets and rotation. - `G52` and `G92`/`G92.n` may be freely mixed, and in the light of the shared registers, interactions behave as expected. - `G52 X0 Y0` zeros the offsets, but does not reset the `#5210` flag. This is not expected to cause unexpected behavior; the flag apparently exists only to implement `G92.2` and `G92.3`. - `G52` and `G92` share DRO readouts and preview offset display. - `G92` offset persistence may be disabled by setting `PERSISTENT_G92_OFFSET = false` in the `[RS274NGC]` section of the `.ini` file. By default, `G92` is persistent. Signed-off-by: John Morris --- docs/src/gcode/coordinates.txt | 189 ++++++++++++++---- docs/src/gcode/g-code.txt | 13 +- docs/src/gcode/gcode_fr.txt | 8 +- docs/src/gcode/overview.txt | 17 +- docs/src/gcode/overview_fr.txt | 9 +- scripts/runtests | 10 +- src/emc/rs274ngc/interp_array.cc | 10 +- src/emc/rs274ngc/interp_check.cc | 1 + src/emc/rs274ngc/interp_convert.cc | 169 ++++++++++------ src/emc/rs274ngc/interp_internal.cc | 13 +- src/emc/rs274ngc/interp_internal.hh | 3 + src/emc/rs274ngc/interp_setup.cc | 1 + src/emc/rs274ngc/rs274ngc_pre.cc | 26 +++ src/emc/rs274ngc/rs274ngc_return.hh | 8 +- tests/.gitignore | 2 + tests/interp/g52/g52-g92-interaction/expected | 41 ++++ .../g52-g92-interaction.ngc | 39 ++++ tests/interp/g52/g52-g92-interaction/test.sh | 3 + .../g52/g92-offset-persistence/expected | 51 +++++ .../g92-offset-persistence/g92_offsets.ngc | 7 + .../g92_offsets.var.template | 10 + .../persistent_g92_offset_false.ini | 2 + .../persistent_g92_offset_true.ini | 2 + .../interp/g52/g92-offset-persistence/test.sh | 25 +++ 24 files changed, 528 insertions(+), 131 deletions(-) create mode 100644 tests/interp/g52/g52-g92-interaction/expected create mode 100644 tests/interp/g52/g52-g92-interaction/g52-g92-interaction.ngc create mode 100644 tests/interp/g52/g52-g92-interaction/test.sh create mode 100644 tests/interp/g52/g92-offset-persistence/expected create mode 100644 tests/interp/g52/g92-offset-persistence/g92_offsets.ngc create mode 100644 tests/interp/g52/g92-offset-persistence/g92_offsets.var.template create mode 100644 tests/interp/g52/g92-offset-persistence/persistent_g92_offset_false.ini create mode 100644 tests/interp/g52/g92-offset-persistence/persistent_g92_offset_true.ini create mode 100644 tests/interp/g52/g92-offset-persistence/test.sh diff --git a/docs/src/gcode/coordinates.txt b/docs/src/gcode/coordinates.txt index 70bc3f02363..08e3f080dfc 100644 --- a/docs/src/gcode/coordinates.txt +++ b/docs/src/gcode/coordinates.txt @@ -9,7 +9,7 @@ These include: * Machine Coordinates (G53) * Nine Coordinate System Offsets (G54-G59.3) -* Global Offsets (G92) +* Global Offsets (G92) and Local Offsets (G52) == Machine Coordinate System @@ -56,11 +56,11 @@ In the VAR file scheme, the first variable number stores the X offset, the second the Y offset and so on for all six axes. There are numbered sets like this for each of the coordinate system offsets. -Each of the graphical interfaces has a way to set values for these offsets. -You can also set these values by editing the VAR file itself and then -restart LinuxCNC so that the LinuxCNC reads the new values however this is -not the recommended way. Using G10, G92, G28.1, etc are better ways to -set the variables. +Each of the graphical interfaces has a way to set values for these +offsets. You can also set these values by editing the VAR file itself +and then restart LinuxCNC so that the LinuxCNC reads the new values +however this is not the recommended way. Using G10, G52, G92, G28.1, +etc are better ways to set the variables. .Example of G55 parameters [width="40%",cols="^,^,^",options="header"] @@ -133,11 +133,59 @@ The G10 L2x command can be used to set coordinate system offsets: * 'G10 L20 P(1-9)' - Set offset(s) so current position becomes a value. (see <> for details) -== Global Offsets[[sec:g92-offsets]] +== Local and Global Offsets[[sec:g52-and-g92-offsets]] -=== The G92 Commands +=== The G52 command[[sec:g52]] -This set of commands include; +'G52' is used in a part program as a temporary "local coordinate +system offset" within the workpiece coordinate system. An example use +case is when machining several identical features at different +locations on a part. For each feature, 'G52' programs a local +reference point within workpiece coordinates, and a subprogram is +called to machine the feature relative to that point. + +'G52' axis offsets are programmed relative to workpiece coordinate +offsets 'G54' through 'G59.3'. As a local offset, 'G52' is applied +after the workpiece offset, including rotation. Thus, a part feature +will be machined identically on each part regardless of the part's +orientation on the pallet. + +[CAUTION] + +As a temporary offset, set and unset within the localized scope of a +part program, in other g-code interpreters 'G52' does not persist +after machine reset, 'M02' or 'M30'. In LinuxCNC, 'G52' shares +parameters with 'G92', which, for historical reasons, *does* persist +these parameters. See <> below. + +[CAUTION] + +'G52' and 'G92' share the same offset registers. Therefore, setting +'G52' will override any earlier 'G92' setting, and 'G52' will persist +across machine reset when 'G92' persistence is enabled. These +interactions may result in unexpected offsets. See +<> +below. + +Programming 'G52 X1 Y2' offsets the current workpiece coordinate +system X axis by 1 and Y axis by 2. Accordingly, on the DRO, the +current tool position's X and Y coordinates will be reduced by 1 and +2, respectively. Axes unset in the command, such as Z in the previous +example, will be unaffected: any previous 'G52' Z offset will remain +in effect, and otherwise the Z offset will be zero. + +The temporary local offset may be canceled with 'G52 X0 Y0'. Any axes +not explicitly zeroed will retain the previous offset. + +'G52' shares the same offset registers as the legacy 'G92', and thus +'G52' is visible on the DRO and preview labeled with 'G92'. + +=== The G92 commands[[sec:g92-commands]] + +'G92' is typically used in two conceptually different ways: as a +"global coordinate system offset" or as a "local coordinate system +offset". The 'G92' set of commands includes: * 'G92' - This command, when used with axis names, sets values to offset variables. @@ -149,25 +197,61 @@ This set of commands include; * 'G92.3' - This command applies offset values that have been suspended. -When the commands are used as described above, they will work pretty -much as you would expect. - -To make the current point, what ever it is, -have the coordinates X0, Y0, and Z0 you would use G92 X0 Y0 Z0. -G92 *does not* work from absolute machine coordinates. -It works from *current location*. - -G92 also works from current location as modified by any other offsets -that are in effect when the G92 command is invoked. While testing for -differences between work offsets and actual offsets it was found that a -G54 offset could cancel out a G92 and thus give the appearance that no -offsets were in effect. However, the G92 was still in effect for all -coordinates and did produce expected work offsets for the other -coordinate systems. - -It is a good practice to clear the G92 offsets at the end of their -use with G92.1 or G92.2. When starting up LinuxCNC if any offsets are -in the G92 variables they will be applied when an axis is homed. +As a global offset, 'G92' is used to shift all workpiece coordinate +systems 'G54' through 'G59.3'. An example use case is when machining +several identical parts in fixtures with known locations on a pallet, +but the pallet location may change between runs or between machines. +Each fixture location offset, relative to a reference point on the +pallet, is preset in one of the workpiece coordinate systems, 'G54' +through 'G59.3', and 'G92' is used to "touch off" on the pallet +reference point. Then, for each part, the corresponding workpiece +coordinate system is selected and the part program is executed. + +[NOTE] +'G10 R-' workpiece coordinate system rotation is specific to the +'rs274ngc' interpreter, and the 'G92' offset is applied 'after' +rotation. When using 'G92' as a global offset, workpiece coordinate +system rotations may have unexpected results. + +As a local coordinate system, 'G92' is used as a temporary offset +within the workpiece coordinate system. An example use case is when +machining a part with several identical features at different +locations. For each feature, 'G92' is used to set a local reference +point, and a subprogram is called to machine the feature starting at +that point. + +[NOTE] +The use of 'G92' is discouraged for programming with local coordinate +systems in a part program. Instead, see <>, a local +coordinate system offset more intuitive when desired offset relative +to the workpiece is known but current tool location may not be known. + +Programming 'G92 X0 Y0 Z0' sets the current tool location to the +coordinates X0, Y0, and Z0, without motion. G92 *does not* work from +absolute machine coordinates. It works from *current location*. + +'G92' also works from current location as modified by any other +offsets that are in effect when the 'G92' command is invoked. While +testing for differences between work offsets and actual offsets it was +found that a 'G54' offset could cancel out a 'G92' and thus give the +appearance that no offsets were in effect. However, the 'G92' was +still in effect for all coordinates and did produce expected work +offsets for the other coordinate systems. + +By default, 'G92' offsets are cleared after the machine is started and +after a 'M02' or 'M30'. Programmers that often use 'G92' as a global +offset and do not use 'G92' or 'G52' for local coordinate systems may +wish for the offset to persist between machine resets. Enable 'G92' +persistence by setting 'PERSISTENT_G92_OFFSET = true' in the +'[RS274NGC]' section of the '.ini' file. + +[NOTE] + +Especially when enabling 'G92' offset persistence, it is good practice +to clear the 'G92' offsets at the end of their use with 'G92.1' or +'G92.2'. When starting up LinuxCNC with 'G92' persistence enabled, any +offsets in the 'G92' variables will be applied when an axis is homed. +See <> below. === Setting G92 Values @@ -181,8 +265,16 @@ zero. A 'G92 X2' will set an offset of 0.0000 and the displayed position will not change. A 'G92 X5.0000' will set an offset of 3.0000 so that the current displayed position becomes 5.0000. +=== G92 Persistence Cautions[[sec:g92-persistence-cautions]] + +By default, the values of a 'G92' offset will remain in the VAR file. +This may happen unintentionally when a program is aborted while 'G92' +offsets are in effect. In this case, the saved 'G92' offsets will be +restored after a machine reset or startup. + The G92 parameters are: +* 5210 - Enable/disable flag (1.0/0.0) * 5211 - X Axis Offset * 5212 - Y Axis Offset * 5213 - Z Axis Offset @@ -193,9 +285,11 @@ The G92 parameters are: * 5218 - V Axis Offset * 5219 - W Axis Offset -If you are seeing unexpected positions as the result of a commanded move, as a -result of storing an offset in a previous program and not clearing them at the -end then issue a G92.1 in the MDI window to clear the stored offsets. +where 5210 is the 'G92' enable flag (1 for enabled, 0 for disabled) +and 5211 are the axis offsets. If you are seeing unexpected positions +as the result of a commanded move, as a result of storing an offset in +a previous program and not clearing them at the end then issue a G92.1 +in the MDI window to clear the stored offsets. If G92 values exist in the VAR file when LinuxCNC starts up, the G92 values in the var file will be applied to the values of the current @@ -209,16 +303,31 @@ G92 was applied to the machine origin. If you issue a G92.1 and the DRO now reads all zeros then you had a G92 offset in effect when you last ran LinuxCNC. -Unless your intention is to use the same G92 offsets in the next -program, the best practice is to issue a G92.1 at the end of any G Code -files where you use G92 offsets. +When 'G92' offset persistence is enabled, unless your intention is to +use the same G92 offsets in the next program, the best practice is to +issue a G92.1 at the end of any G Code files where you use G92 +offsets. -[CAUTION] -When a file is aborted during processing that has G92 offsets in effect a -startup will cause them to become active again. Always have your preamble -to set the environment as you expect it. +When a file is aborted during processing that has 'G92' offsets in +effect a startup will cause them to become active again. As a +safeguard, always have your preamble to set the environment as you +expect it. Additionally, 'G92' persistence may be disabled by setting +'PERSISTENT_G92_OFFSET = false' in the '[RS274NGC]' section of the +'.ini' file. + +=== G92 and G52 Interaction Cautions[[sec:g92-g52-interaction-cautions]] + +'G52' and 'G92' share the same offset registers. When 'G92' +persistence is enabled in the '.ini' file (see <>), 'G52' offsets will also persist after machine reset, +'M02' or 'M30'. When 'G92' persistence is enabled, beware that a +'G52' offset in effect during a program abort may result in unintended +offsets when the next program is run. See <> above. + +== Sample Programs Using Offsets -== Sample Program Using Offsets +=== Sample Program Using Workpiece Coordinate Offsets This sample engraving project mills a set of four .1 radius circles in roughly a star shape around a center circle. We can setup the @@ -293,4 +402,6 @@ run after this one will also use that G92 offset. Furthermore it would save the G92 values when you shut down the LinuxCNC and they will be recalled when you start up again. +=== Sample Program Using G52 Offsets +(To be written) diff --git a/docs/src/gcode/g-code.txt b/docs/src/gcode/g-code.txt index 4ccafc97f9a..2abf1fac11b 100644 --- a/docs/src/gcode/g-code.txt +++ b/docs/src/gcode/g-code.txt @@ -705,8 +705,10 @@ Important Concepts: you have to use G54-59.3 to select a coordinate system. * When a rotation is in effect jogging an axis will only move that axis in a positive or negative direction and not along the rotated axis. -* If a 'G92' origin offset was in effect before 'G10 L2', - it will continue to be in effect afterwards. +* If a 'G52' local offset or 'G92' origin offset was in effect before + 'G10 L2', it will continue to be in effect afterwards. +* When programming a coordinate system with R, any 'G52' or 'G92' will + be applied *after* the rotation. * The coordinate system whose origin is set by a 'G10' command may be active or inactive at the time the 'G10' is executed. If it is currently active, the new coordinates take effect immediately. @@ -752,7 +754,7 @@ G10 L10 P- axes G10 L10 changes the tool table entry for tool P so that if the tool offset is reloaded, with the machine in its current position -and with the current G5x and G92 offsets active, the current coordinates +and with the current G5x and G52/G92 offsets active, the current coordinates for the given axes will become the given values. The axes that are not specified in the G10 L10 command will not be changed. This could be useful with a probe move as described in the <> section. @@ -791,7 +793,7 @@ G10 L11 is just like G10 L10 except that instead of setting the entry according to the current offsets, it is set so that the current coordinates would become the given value if the new tool offset is reloaded and the machine is placed in the G59.3 coordinate -system without any G92 offset active. +system without any G52/G92 offset active. This allows the user to set the G59.3 coordinate system according to a fixed point on the machine, and then use that fixture to measure tools @@ -2205,7 +2207,8 @@ program a G92.2 (to remove them - they are still stored). See the <> Section for an overview of coordinate systems. -See the <> Section for more information. +See the <> Section for more +information. See the <> Section for more information. diff --git a/docs/src/gcode/gcode_fr.txt b/docs/src/gcode/gcode_fr.txt index bdbc07b7d86..280036771bc 100644 --- a/docs/src/gcode/gcode_fr.txt +++ b/docs/src/gcode/gcode_fr.txt @@ -742,8 +742,8 @@ coordonnées. * Quand un mouvement de rotation est en cours, jogger un axe, déplacera celui-ci seulement dans le sens négatif ou positif et non pas le long de l'axe de rotation. -* Si un décalage d'origine créé avec 'G92' est actif avant la commande 'G10 L2', -il reste actif après. +* Si un décalage d'origine créé avec 'G92' ou 'G92' est actif avant la +commande 'G10 L2', il reste actif après. * Le système de coordonnées dont l'origine est définie par la commande 'G10' peut être actif ou non au moment de l'exécution de 'G10'. Si il est actif à ce moment là, les nouvelles coordonnées prennent effet immédiatement. @@ -789,7 +789,7 @@ G10 L10 P- axes G10 L10 modifie les valeurs de l'outil 'P' dans la table d'outils, de sorte que si la compensation d'outil est rechargée, avec la machine à la position -courante et avec les G5x et G92 actifs, les coordonnées courantes pour +courante et avec les G5x et G52/G92 actifs, les coordonnées courantes pour l'axe spécifié deviendront les coordonnées spécifiées. Les axes non spécifiés dans la commande G10 L10 ne seront pas modifiés. @@ -826,7 +826,7 @@ G10 L11 est identique à G10 L10 excepté qu'au lieux de fixer les valeurs par rapport aux décalages de coordonnées courants, il les fixe de sorte que les coordonnées courantes deviennent celles spécifiées par les paramètres si la nouvelle compensation d'outil est rechargée et que la machine est placée dans -le système de coordonnées G59.3, système sans aucun décalage G92 actif. +le système de coordonnées G59.3, système sans aucun décalage G52/G92 actif. Ceci permet à l'utilisateur de fixer le système de coordonnées G59.3 à un point fixe de la machine et d'utiliser cet emplacement pour mesurer diff --git a/docs/src/gcode/overview.txt b/docs/src/gcode/overview.txt index 5bf2ba56cab..c7563d53133 100644 --- a/docs/src/gcode/overview.txt +++ b/docs/src/gcode/overview.txt @@ -284,11 +284,14 @@ example '##2' means the value of the parameter whose index is the * '5181-5189' - "G30" Home for X, Y, Z, A, B, C, U, V & W. Persistent. -* '5211-5219' - "G92" offset for X, Y, Z, A, B, C, U, V & W. Persistent. +* '5210' - 1 if "G52" or "G92" offset is currently applied, 0 + otherwise. Volatile by default; persistent if + 'PERSISTENT_G92_OFFSET = true' in the '[RS274NGC]' section of the + '.ini' file. -* '5210' - 1 if "G92" offset is currently applied, 0 otherwise. Persistent. - -* '5211-5219' - 'G92' offset (X Y Z A B C U V W). +* '5211-5219' - Shared "G52" and "G92" offset for X, Y, Z, A, B, C, U, + V & W. Volatile by default; persistent if 'PERSISTENT_G92_OFFSET = + true' in the '[RS274NGC]' section of the '.ini' file. * '5220' - Coordinate System number 1 - 9 for G54 - G59.3. Persistent. @@ -947,7 +950,7 @@ being in effect. The modal groups are shown in the following Table. [width="80%", cols="4,6", options="header"] |==== |Modal Group Meaning | Member Words -|Non-modal codes (Group 0) | G4, G10 G28, G30, G53 G92, G92.1, G92.2, G92.3, +|Non-modal codes (Group 0) | G4, G10 G28, G30, G52, G53, G92, G92.1, G92.2, G92.3, .2+|Motion (Group 1) | G0, G1, G2, G3, G33, G38.x, G73, G76, G80, G81 | G82, G83, G84, G85, G86, G87, G88, G89 |Plane selection (Group 2) | G17, G18, G19, G17.1, G18.1, G19.1 @@ -994,7 +997,7 @@ G-code from group 1 is implicitly in effect on a line (by having been activated on an earlier line), and a group 0 G-code that uses axis words appears on the line, the activity of the group 1 G-code is suspended for that line. The axis word-using G-codes from group 0 are -G10, G28, G30, and G92. +G10, G28, G30, G52 and G92. It is an error to include any unrelated words on a line with 'O-' flow control. @@ -1171,7 +1174,7 @@ position of each item on the line, but by the following list: * Set distance mode (G90, G91). * Set retract mode (G98, G99). * Go to reference location (G28, G30) or change coordinate system - data (G10) or set axis offsets (G92, G92.1, G92.2, G94). + data (G10) or set axis offsets (G52, G92, G92.1, G92.2, G94). * Perform motion (G0 to G3, G33, G38.x, G73, G76, G80 to G89), as modified (possibly) by G53. * Stop (M0, M1, M2, M30, M60). diff --git a/docs/src/gcode/overview_fr.txt b/docs/src/gcode/overview_fr.txt index 94092f4b06c..6f27a860f92 100644 --- a/docs/src/gcode/overview_fr.txt +++ b/docs/src/gcode/overview_fr.txt @@ -295,7 +295,7 @@ dont le numéro est égal à la valeur entière trouvée dans le paramètre 2. 5181 à 5189:: Origine 'G30' pour X Y Z A B C U V W. Persistant. 5211 à 5219:: - Offset 'G92' pour X Y Z A B C U V W. Persistant. + Offset 'G52' et 'G92' pour X Y Z A B C U V W. Persistant. 5220:: Système de coordonnées 1 à 9 pour G54 à G59.3. Persistant. 5221 à 5229:: @@ -844,7 +844,7 @@ visibles dans le tableau <>. [width="100%", cols="4,6", options="header"] |========================================================== |Signification du groupe modal | Mots G -|Codes non modaux ('Groupe 0')| G4, G10, G28, G30, G53, G92, G92.1, G92.2, G92.3 +|Codes non modaux ('Groupe 0')| G4, G10, G28, G30, G53, G52, G92, G92.1, G92.2, G92.3 .2+|Mouvements ('Groupe 1') | G0, G1, G2, G3, G33, G38.x, G73, G80, G81, | G82, G83, G84, G85, G86, G87, G88, G89 |Choix du plan de travail ('Groupe 2')| G17, G18, G19, G17.1, G18.1, G19.1 @@ -894,7 +894,7 @@ la ligne (en ayant été activé sur une ancienne ligne) et qu'un G-code du groupe 0 utilisant des mots d'axes apparaît sur la même ligne, l'activité du G-code du groupe 1 est révoquée pour le reste de la ligne. Les mots d'axes utilisant des G-codes du groupe 0 sont G10, G28, -G30 et G92. +G30, G52 et G92. C'est une erreur d'inclure des mots sans rapport sur une ligne avec le contrôle de flux 'O'. @@ -1083,7 +1083,8 @@ mot n'est permis sur la même ligne. * Réglage du mode de déplacement (G90, G91). * Réglage du mode de retrait (G98, G99). * Prise d'origine (G28, G30) ou établissement du système de - coordonnées (G10) ou encore, réglage des décalages d'axes (G92, G92.1, G92.2, G94). + coordonnées (G10) ou encore, réglage des décalages d'axes (G52, + G92, G92.1, G92.2, G94). * Effectuer un mouvement (G0 à G3, G33, G80 à G89), tel que modifié (éventuellement) par G53. * Arrêt (M0, M1, M2, M30, M60). diff --git a/scripts/runtests b/scripts/runtests index 81e815d8456..e55d8a9e3b9 100755 --- a/scripts/runtests +++ b/scripts/runtests @@ -28,7 +28,9 @@ XFAIL=0 VERBOSE=0 clean () { - find $* \( -name "stderr" -or -name "result" \) -print0 | xargs -0 rm -f + find $* \( -name "stderr" -or -name "result" \ + -or -name "*.var" -or -name "*.var.bak" \) \ + -print0 | xargs -0 rm -f } run_shell_script () { @@ -138,7 +140,8 @@ run_tests () { XFAIL=$(($XFAIL+1)) echo "*** $testdir: XFAIL: $reason" if [ $NOCLEAN -eq 0 ]; then - rm -f $testdir/stderr $testdir/result + rm -f $testdir/stderr $testdir/result \ + $testdir/*.var $testdir/*.var.bak fi else FAIL=$(($FAIL+1)) @@ -151,7 +154,8 @@ run_tests () { echo "*** $testdir: XPASS: Passed, but was expected to fail" else if [ $NOCLEAN -eq 0 ]; then - rm -f $testdir/stderr $testdir/result + rm -f $testdir/stderr $testdir/result \ + $testdir/*.var $testdir/*.var.bak fi fi fi diff --git a/src/emc/rs274ngc/interp_array.cc b/src/emc/rs274ngc/interp_array.cc index 12ddbeb72e4..d7426f47684 100644 --- a/src/emc/rs274ngc/interp_array.cc +++ b/src/emc/rs274ngc/interp_array.cc @@ -52,10 +52,12 @@ the same line as those in group 1. A total of 52 G-codes are implemented. The groups are: -group 0 = {g4,g10,g28,g30,g53,g92,g92.1,g92.2,g92.3} - NON-MODAL +group 0 = {g4,g10,g28,g30,g52,g53,g92,g92.1,g92.2,g92.3} - NON-MODAL dwell, setup, return to ref1, return to ref2, - motion in machine coordinates, set and unset axis offsets -group 1 = {g0,g1,g2,g3,g33,g33.1,g38.2,g38.3,g38.4,g38.5,g73,g76,g80,g81,g82,g83,g84,g85,g86,g87,g88,g89} - motion + local coordinate system, motion in machine coordinates, + set and unset axis offsets +group 1 = {g0,g1,g2,g3,g33,g33.1,g38.2,g38.3,g38.4,g38.5,g73,g76,g80, + g81,g82,g83,g84,g85,g86,g87,g88,g89} - motion group 2 = {g17,g17.1,g18,g18.1,g19,g19.1} - plane selection group 3 = {g90,g91} - distance mode group 4 = {g90.1,g91.1} - arc IJK distance mode @@ -99,7 +101,7 @@ const int Interp::_gees[] = { /* 460 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 480 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 8,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 500 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, -/* 520 */ -1,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, +/* 520 */ 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 540 */ 12,-1,-1,-1,-1,-1,-1,-1,-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 560 */ 12,-1,-1,-1,-1,-1,-1,-1,-1,-1,12,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 580 */ 12,-1,-1,-1,-1,-1,-1,-1,-1,-1,12,12,12,12,-1,-1,-1,-1,-1,-1, diff --git a/src/emc/rs274ngc/interp_check.cc b/src/emc/rs274ngc/interp_check.cc index b15cd11887c..fbccffd8780 100644 --- a/src/emc/rs274ngc/interp_check.cc +++ b/src/emc/rs274ngc/interp_check.cc @@ -99,6 +99,7 @@ int Interp::check_g_codes(block_pointer block, //!< pointer to a block to be c CHKS(((mode1 != G_5_2) && (mode1 != -1)), _("Between G5.2 and G5.3 codes, only additional G5.2 codes are allowed.")); } else if (mode1 == G_5_2){ } else if (mode0 == G_28_1 || mode0 == G_30_1) { + } else if (mode0 == G_52) { } else if (mode0 == G_53) { CHKS(((block->motion_to_be != G_0) && (block->motion_to_be != G_1)), NCE_MUST_USE_G0_OR_G1_WITH_G53); diff --git a/src/emc/rs274ngc/interp_convert.cc b/src/emc/rs274ngc/interp_convert.cc index c930832fc17..d0531d44f28 100644 --- a/src/emc/rs274ngc/interp_convert.cc +++ b/src/emc/rs274ngc/interp_convert.cc @@ -983,8 +983,8 @@ Returned Value: int Otherwise, it returns INTERP_OK. 1. The function is called when cutter radius compensation is on: NCE_CANNOT_CHANGE_AXIS_OFFSETS_WITH_CUTTER_RADIUS_COMP - 2. The g_code argument is not G_92, G_92_1, G_92_2, or G_92_3 - NCE_BUG_CODE_NOT_IN_G92_SERIES + 2. The g_code argument is not G_52, G_92, G_92_1, G_92_2, or G_92_3 + NCE_BUG_CODE_NOT_IN_G52_G92_SERIES Side effects: SET_G92_OFFSET is called, and the coordinate @@ -1019,7 +1019,8 @@ Since a non-zero offset may be already be in effect when the G92 is called, that must be taken into account. In addition to causing the axis offset values in the _setup model to be -set, G92 sets parameters 5211 to 5216 to the x,y,z,a,b,c axis offsets. +set, G52 and G92 set parameters 5211 to 5216 to the x,y,z,a,b,c axis +offsets. The action of G92.2 is described in [NCMS, page 12]. There is no equivalent command in [Fanuc]. G92.2 resets axis offsets to zero. @@ -1054,55 +1055,98 @@ int Interp::convert_axis_offsets(int g_code, //!< g_code being executed (mus (_("Invalid absolute position %5.2f for wrapped rotary axis %c")), block->c_number, 'C'); pars = settings->parameters; - if (g_code == G_92) { - pars[5210] = 1.0; - if (block->x_flag) { - settings->axis_offset_x = - (settings->current_x + settings->axis_offset_x - block->x_number); - settings->current_x = block->x_number; - } + if ((g_code == G_52) || (g_code == G_92)) { + pars[5210] = 1.0; - if (block->y_flag) { - settings->axis_offset_y = - (settings->current_y + settings->axis_offset_y - block->y_number); - settings->current_y = block->y_number; - } + if (g_code == G_52) { + if (block->x_flag) { + settings->current_x += settings->axis_offset_x - block->x_number; + settings->axis_offset_x = block->x_number; + } - if (block->z_flag) { - settings->axis_offset_z = - (settings->current_z + settings->axis_offset_z - block->z_number); - settings->current_z = block->z_number; - } - if (block->a_flag) { - settings->AA_axis_offset = (settings->AA_current + - settings->AA_axis_offset - block->a_number); - settings->AA_current = block->a_number; - } - if (block->b_flag) { - settings->BB_axis_offset = (settings->BB_current + - settings->BB_axis_offset - block->b_number); - settings->BB_current = block->b_number; - } - if (block->c_flag) { - settings->CC_axis_offset = (settings->CC_current + - settings->CC_axis_offset - block->c_number); - settings->CC_current = block->c_number; - } - if (block->u_flag) { - settings->u_axis_offset = (settings->u_current + - settings->u_axis_offset - block->u_number); - settings->u_current = block->u_number; - } - if (block->v_flag) { - settings->v_axis_offset = (settings->v_current + - settings->v_axis_offset - block->v_number); - settings->v_current = block->v_number; - } - if (block->w_flag) { - settings->w_axis_offset = (settings->w_current + - settings->w_axis_offset - block->w_number); - settings->w_current = block->w_number; - } + if (block->y_flag) { + settings->current_y += settings->axis_offset_y - block->y_number; + settings->axis_offset_y = block->y_number; + } + + if (block->z_flag) { + settings->current_z += settings->axis_offset_z - block->z_number; + settings->axis_offset_z = block->z_number; + } + if (block->a_flag) { + settings->AA_current += settings->AA_axis_offset - block->a_number; + settings->AA_axis_offset = block->a_number; + } + if (block->b_flag) { + settings->BB_current += settings->BB_axis_offset - block->b_number; + settings->BB_axis_offset = block->b_number; + } + if (block->c_flag) { + settings->CC_current += settings->CC_axis_offset - block->c_number; + settings->CC_axis_offset = block->c_number; + } + if (block->u_flag) { + settings->u_current += settings->u_axis_offset - block->u_number; + settings->u_axis_offset = block->u_number; + } + if (block->v_flag) { + settings->v_current += settings->v_axis_offset - block->v_number; + settings->v_axis_offset = block->v_number; + } + if (block->w_flag) { + settings->w_current += settings->w_axis_offset - block->w_number; + settings->w_axis_offset = block->w_number; + } + + } else { + if (block->x_flag) { + settings->axis_offset_x = + (settings->current_x + settings->axis_offset_x - block->x_number); + settings->current_x = block->x_number; + } + + if (block->y_flag) { + settings->axis_offset_y = + (settings->current_y + settings->axis_offset_y - block->y_number); + settings->current_y = block->y_number; + } + + if (block->z_flag) { + settings->axis_offset_z = + (settings->current_z + settings->axis_offset_z - block->z_number); + settings->current_z = block->z_number; + } + if (block->a_flag) { + settings->AA_axis_offset = (settings->AA_current + + settings->AA_axis_offset - block->a_number); + settings->AA_current = block->a_number; + } + if (block->b_flag) { + settings->BB_axis_offset = (settings->BB_current + + settings->BB_axis_offset - block->b_number); + settings->BB_current = block->b_number; + } + if (block->c_flag) { + settings->CC_axis_offset = (settings->CC_current + + settings->CC_axis_offset - block->c_number); + settings->CC_current = block->c_number; + } + if (block->u_flag) { + settings->u_axis_offset = (settings->u_current + + settings->u_axis_offset - block->u_number); + settings->u_current = block->u_number; + } + if (block->v_flag) { + settings->v_axis_offset = (settings->v_current + + settings->v_axis_offset - block->v_number); + settings->v_current = block->v_number; + } + if (block->w_flag) { + settings->w_axis_offset = (settings->w_current + + settings->w_axis_offset - block->w_number); + settings->w_current = block->w_number; + } + } SET_G92_OFFSET(settings->axis_offset_x, settings->axis_offset_y, @@ -1113,7 +1157,7 @@ int Interp::convert_axis_offsets(int g_code, //!< g_code being executed (mus settings->u_axis_offset, settings->v_axis_offset, settings->w_axis_offset); - + pars[5211] = PROGRAM_TO_USER_LEN(settings->axis_offset_x); pars[5212] = PROGRAM_TO_USER_LEN(settings->axis_offset_y); pars[5213] = PROGRAM_TO_USER_LEN(settings->axis_offset_z); @@ -1123,6 +1167,7 @@ int Interp::convert_axis_offsets(int g_code, //!< g_code being executed (mus pars[5217] = PROGRAM_TO_USER_LEN(settings->u_axis_offset); pars[5218] = PROGRAM_TO_USER_LEN(settings->v_axis_offset); pars[5219] = PROGRAM_TO_USER_LEN(settings->w_axis_offset); + } else if ((g_code == G_92_1) || (g_code == G_92_2)) { pars[5210] = 0.0; settings->current_x = settings->current_x + settings->axis_offset_x; @@ -1198,7 +1243,7 @@ int Interp::convert_axis_offsets(int g_code, //!< g_code being executed (mus settings->v_axis_offset, settings->w_axis_offset); } else - ERS(NCE_BUG_CODE_NOT_IN_G92_SERIES); + ERS(NCE_BUG_CODE_NOT_IN_G52_G92_SERIES); return INTERP_OK; } @@ -3274,14 +3319,15 @@ Returned Value: int convert_setup If any of the following errors occur, this returns the error code shown. Otherwise, it returns INTERP_OK. - 1. code is not G_4, G_10, G_28, G_30, G_53, G92, G_92_1, G_92_2, or G_92_3: - NCE_BUG_CODE_NOT_G4_G10_G28_G30_G53_OR_G92_SERIES + 1. code is not G_4, G_10, G_28, G_30, G_52, G_53, G_92, G_92_1, G_92_2, + or G_92_3: + NCE_BUG_CODE_NOT_G4_G10_G28_G30_G52_G53_OR_G92_SERIES Side effects: See below Called by: convert_g -If the g_code is g10, g28, g30, g92, g92.1, g92.2, or g92.3 (all are in +If the g_code is g10, g28, g30, g52, g92, g92.1, g92.2, or g92.3 (all are in modal group 0), it is executed. The other two in modal group 0 (G4 and G53) are executed elsewhere. @@ -3301,14 +3347,15 @@ int Interp::convert_modal_0(int code, //!< G code, must be from group 0 CHP(convert_home(code, block, settings)); } else if ((code == G_28_1) || (code == G_30_1)) { CHP(convert_savehome(code, block, settings)); - } else if ((code == G_92) || (code == G_92_1) || + } else if ((code == G_52) || + (code == G_92) || (code == G_92_1) || (code == G_92_2) || (code == G_92_3)) { CHP(convert_axis_offsets(code, block, settings)); } else if (code == G_5_3) { CHP(convert_nurbs(code, block, settings)); } else if ((code == G_4) || (code == G_53)); /* handled elsewhere */ else - ERS(NCE_BUG_CODE_NOT_G4_G10_G28_G30_G53_OR_G92_SERIES); + ERS(NCE_BUG_CODE_NOT_G4_G10_G28_G30_G52_G53_OR_G92_SERIES); return INTERP_OK; } @@ -4056,6 +4103,7 @@ Side effects: For m2 and m30, this resets the machine and then calls PROGRAM_END. In addition, m30 calls PALLET_SHUTTLE. + Clear g92 offset unless PERSISTENT_G92_OFFSET is set in the .ini file. Called by: execute_block. @@ -4096,6 +4144,7 @@ settings. They occur on M2 or M30. 7. The spindle is stopped (like M5) - STOP_SPINDLE_TURNING 8. The motion mode is set to G_1 (like G1) - no canonical call 9. Coolant is turned off (like M9) - FLOOD_OFF & MIST_OFF +10. G52/G92 is cleared unless PERSISTENT_G92_OFFSET is set in the .ini file */ @@ -4210,6 +4259,12 @@ int Interp::convert_stop(block_pointer block, //!< pointer to a block of RS27 settings->flood = false; } +/*10*/ + if (! settings->persistent_g92_offset) + // Clear G92/G52 offset + for (index=5210; index<=5219; index++) + settings->parameters[index] = 0; + if (block->m_modes[4] == 30) PALLET_SHUTTLE(); PROGRAM_END(); diff --git a/src/emc/rs274ngc/interp_internal.cc b/src/emc/rs274ngc/interp_internal.cc index 85007095376..73a2ec70b8f 100644 --- a/src/emc/rs274ngc/interp_internal.cc +++ b/src/emc/rs274ngc/interp_internal.cc @@ -116,8 +116,8 @@ Returned Value: 1. A g80 is in the block, no modal group 0 code that uses axes is in the block, and one or more axis values is given: NCE_CANNOT_USE_AXIS_VALUES_WITH_G80 - 2. A g92 is in the block and no axis value is given: - NCE_ALL_AXES_MISSING_WITH_G92 + 2. A g52 g92 is in the block and no axis value is given: + NCE_ALL_AXES_MISSING_WITH_G52_OR_G92 3. One g-code from group 1 and one from group 0, both of which can use axis values, are in the block: NCE_CANNOT_USE_TWO_G_CODES_THAT_BOTH_USE_AXIS_VALUES @@ -173,14 +173,15 @@ int Interp::enhance_block(block_pointer block, //!< pointer to a block to be c mode1 = block->g_modes[1]; mode_zero_covets_axes = ((mode0 == G_10) || (mode0 == G_28) || (mode0 == G_30) - || (mode0 == G_92)); + || (mode0 == G_52) || (mode0 == G_92)); if (mode1 != -1) { if (mode1 == G_80) { CHKS(((polar_flag || axis_flag) && (!mode_zero_covets_axes)), NCE_CANNOT_USE_AXIS_VALUES_WITH_G80); CHKS((polar_flag && mode0 == G_92), _("Polar coordinates can only be used for motion")); - CHKS(((!axis_flag) && (mode0 == G_92)), NCE_ALL_AXES_MISSING_WITH_G92); + CHKS(((!axis_flag) && (mode0 == G_52 || mode0 == G_92)), + NCE_ALL_AXES_MISSING_WITH_G52_OR_G92); } else { CHKS(mode_zero_covets_axes, NCE_CANNOT_USE_TWO_G_CODES_THAT_BOTH_USE_AXIS_VALUES); @@ -193,7 +194,9 @@ int Interp::enhance_block(block_pointer block, //!< pointer to a block to be c block->motion_to_be = mode1; } else if (mode_zero_covets_axes) { /* other 3 can get by without axes but not G92 */ CHKS((polar_flag && mode0 == G_92), _("Polar coordinates can only be used for motion")); - CHKS(((!axis_flag) && (block->g_modes[0] == G_92)), NCE_ALL_AXES_MISSING_WITH_G92); + CHKS(((!axis_flag) && + (block->g_modes[0] == G_52 || block->g_modes[0] == G_92)), + NCE_ALL_AXES_MISSING_WITH_G52_OR_G92); } else if (axis_flag || polar_flag) { CHKS(((settings->motion_mode == -1) || (settings->motion_mode == G_80)) && (block->g_modes[8] != G_43_1), diff --git a/src/emc/rs274ngc/interp_internal.hh b/src/emc/rs274ngc/interp_internal.hh index fa086c15720..7a4b2fc85fc 100644 --- a/src/emc/rs274ngc/interp_internal.hh +++ b/src/emc/rs274ngc/interp_internal.hh @@ -214,6 +214,7 @@ enum SPINDLE_MODE { CONSTANT_RPM, CONSTANT_SURFACE }; #define G_49 490 #define G_50 500 #define G_51 510 +#define G_52 520 #define G_53 530 #define G_54 540 #define G_55 550 @@ -757,6 +758,8 @@ typedef struct setup_struct bool mdi_interrupt; int feature_set; + bool persistent_g92_offset; + #define FEATURE(x) (_setup.feature_set & FEATURE_ ## x) #define FEATURE_RETAIN_G43 0x00000001 #define FEATURE_OWORD_N_ARGS 0x00000002 diff --git a/src/emc/rs274ngc/interp_setup.cc b/src/emc/rs274ngc/interp_setup.cc index 7d51352a70a..a366c19fc37 100644 --- a/src/emc/rs274ngc/interp_setup.cc +++ b/src/emc/rs274ngc/interp_setup.cc @@ -172,6 +172,7 @@ setup_struct::setup_struct() : lathe_diameter_mode(0), mdi_interrupt(0), feature_set(0), + persistent_g92_offset(true), pythis(), on_abort_command(NULL), init_once(0) diff --git a/src/emc/rs274ngc/rs274ngc_pre.cc b/src/emc/rs274ngc/rs274ngc_pre.cc index 8beb7f36843..8b16b44264c 100644 --- a/src/emc/rs274ngc/rs274ngc_pre.cc +++ b/src/emc/rs274ngc/rs274ngc_pre.cc @@ -1007,6 +1007,23 @@ int Interp::init() Error("invalid [RS275NGC]CENTER_ARC_RADIUS_TOLERANCE_MM in ini file\n"); } + // ini file g52/g92 offset persistence default setting + if(NULL != (inistring = inifile.Find("PERSISTENT_G92_OFFSET", + "RS274NGC"))) + { + if (strcmp(inistring,"True") == 0 || + strcmp(inistring, "true") == 0 || + strcmp(inistring, "YES") == 0) { + logDebug("init: PERSISTENT_G92_OFFSET = TRUE"); + _setup.persistent_g92_offset = true; + } else { + logDebug("init: PERSISTENT_G92_OFFSET = FALSE"); + _setup.persistent_g92_offset = false; + } + } else + logDebug("init: PERSISTENT_G92_OFFSET = %s (default)", + _setup.persistent_g92_offset ? "TRUE" : "FALSE"); + // close it inifile.Close(); } @@ -1047,6 +1064,15 @@ int Interp::init() _setup.v_origin_offset , _setup.w_origin_offset); + // Restore G92 offset if PERSISTENT_G92_OFFSET is set in .ini file. + // This can't be done with the static _required_parameters[], where + // the .vars file contents would reflect that setting, so instead + // edit the restored parameters here. + if (! _setup.persistent_g92_offset) + // Persistence disabled: clear g92 parameters + for (k = 5210; k < 5220; k++) + pars[k] = 0; + if (pars[5210]) { _setup.axis_offset_x = USER_TO_PROGRAM_LEN(pars[5211]); _setup.axis_offset_y = USER_TO_PROGRAM_LEN(pars[5212]); diff --git a/src/emc/rs274ngc/rs274ngc_return.hh b/src/emc/rs274ngc/rs274ngc_return.hh index cc2d8d5fa91..ba3eab72563 100644 --- a/src/emc/rs274ngc/rs274ngc_return.hh +++ b/src/emc/rs274ngc/rs274ngc_return.hh @@ -17,7 +17,8 @@ #define RS274NGC_RETURN_HH #include "interp_return.hh" #define NCE_A_FILE_IS_ALREADY_OPEN _("A file is already open") -#define NCE_ALL_AXES_MISSING_WITH_G92 _("All axes missing with g92") +#define NCE_ALL_AXES_MISSING_WITH_G52_OR_G92 \ + _("All axes missing with g52 or g92") #define NCE_ALL_AXES_MISSING_WITH_MOTION_CODE _("All axes missing with motion code") #define NCE_ARC_RADIUS_TOO_SMALL_TO_REACH_END_POINT _("Arc radius too small to reach end point") #define NCE_ARGUMENT_TO_ACOS_OUT_OF_RANGE _("Argument to acos out of range") @@ -32,11 +33,12 @@ #define NCE_BUG_CODE_NOT_G20_OR_G21 _("Bug code not g20 or g21") #define NCE_BUG_CODE_NOT_G28_OR_G30 _("Bug code not g28 or g30") #define NCE_BUG_CODE_NOT_G2_OR_G3 _("Bug code not g2 or g3") -#define NCE_BUG_CODE_NOT_G4_G10_G28_G30_G53_OR_G92_SERIES _("Bug code not g4 g10 g28 g30 g53 or g92 series") +#define NCE_BUG_CODE_NOT_G4_G10_G28_G30_G52_G53_OR_G92_SERIES \ + _("Bug code not g4 g10 g28 g30 g52 g53 or g92 series") #define NCE_BUG_CODE_NOT_G61_G61_1_OR_G64 _("Bug code not g61 g61.1 or g64") #define NCE_BUG_CODE_NOT_G90_OR_G91 _("Bug code not g90 or g91") #define NCE_BUG_CODE_NOT_G98_OR_G99 _("Bug code not g98 or g99") -#define NCE_BUG_CODE_NOT_IN_G92_SERIES _("Bug code not in g92 series") +#define NCE_BUG_CODE_NOT_IN_G52_G92_SERIES _("Bug code not in g52 or g92 series") #define NCE_BUG_CODE_NOT_IN_RANGE_G54_TO_G593 _("Bug code not in range g54 to g593") #define NCE_BUG_CODE_NOT_M0_M1_M2_M30_M60 _("Bug code not m0 m1 m2 m30 m60") #define NCE_BUG_DISTANCE_MODE_NOT_G90_OR_G91 _("Bug distance mode not g90 or g91") diff --git a/tests/.gitignore b/tests/.gitignore index 4f389c555dc..47c336a2ce7 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,2 +1,4 @@ result stderr +*.var +*.var.bak diff --git a/tests/interp/g52/g52-g92-interaction/expected b/tests/interp/g52/g52-g92-interaction/expected new file mode 100644 index 00000000000..9c7e8cf13fb --- /dev/null +++ b/tests/interp/g52/g52-g92-interaction/expected @@ -0,0 +1,41 @@ + 1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 4 N..... SET_XY_ROTATION(0.0000) + 5 N..... SET_FEED_REFERENCE(CANON_XYZ) + 6 N..... COMMENT("G52 and G92 param #5210 setting behavior") + 7 N..... USE_LENGTH_UNITS(CANON_UNITS_INCHES) +Program start: Params all 0 +G92 params: 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92: Set current position to X1 Y2 + 8 N..... SET_G92_OFFSET(-1.0000, -2.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 1.000000 -1.000000 -2.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92.2: Reset G92 + 9 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 0.000000 -1.000000 -2.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92.3: Restore G92 + 10 N..... SET_G92_OFFSET(-1.0000, -2.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 1.000000 -1.000000 -2.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92.1: Clear G92 + 11 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G52: Set origin at X2 Y3 + 12 N..... SET_G92_OFFSET(2.0000, 3.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 1.000000 2.000000 3.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92.2: Reset G92 + 13 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 0.000000 2.000000 3.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G92.3: Restore G92 + 14 N..... SET_G92_OFFSET(2.0000, 3.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 1.000000 2.000000 3.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 +G52 X0 Y0: Zero G92, but leave param 5210 set + 15 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) +G92 params: 1.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 + 16 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 17 N..... SET_XY_ROTATION(0.0000) + 18 N..... SET_FEED_MODE(0) + 19 N..... SET_FEED_RATE(0.0000) + 20 N..... STOP_SPINDLE_TURNING() + 21 N..... SET_SPINDLE_MODE(0.0000) + 22 N..... PALLET_SHUTTLE() + 23 N..... PROGRAM_END() diff --git a/tests/interp/g52/g52-g92-interaction/g52-g92-interaction.ngc b/tests/interp/g52/g52-g92-interaction/g52-g92-interaction.ngc new file mode 100644 index 00000000000..f07a3873262 --- /dev/null +++ b/tests/interp/g52/g52-g92-interaction/g52-g92-interaction.ngc @@ -0,0 +1,39 @@ +(G52 and G92 param #5210 setting behavior) +G20 ; use inches for readability + +(PRINT,Program start: Params all 0) +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92: Set current position to X1 Y2) +G92 X1 Y2 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92.2: Reset G92) +G92.2 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92.3: Restore G92) +G92.3 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92.1: Clear G92) +G92.1 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G52: Set origin at X2 Y3) +G52 X2 Y3 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92.2: Reset G92) +G92.2 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G92.3: Restore G92) +G92.3 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +(PRINT,G52 X0 Y0: Zero G92, but leave param 5210 set) +G52 X0 Y0 +(PRINT,G92 params: #5210 #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +M30 diff --git a/tests/interp/g52/g52-g92-interaction/test.sh b/tests/interp/g52/g52-g92-interaction/test.sh new file mode 100644 index 00000000000..e022110fa76 --- /dev/null +++ b/tests/interp/g52/g52-g92-interaction/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rs274 -g g52-g92-interaction.ngc + diff --git a/tests/interp/g52/g92-offset-persistence/expected b/tests/interp/g52/g92-offset-persistence/expected new file mode 100644 index 00000000000..b630db9b958 --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/expected @@ -0,0 +1,51 @@ + 1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 3 N..... SET_G92_OFFSET(25.4000, 25.4000, 25.4000, 1.0000, 1.0000, 1.0000) + 4 N..... SET_XY_ROTATION(0.0000) + 5 N..... SET_FEED_REFERENCE(CANON_XYZ) + 6 N..... COMMENT("G92 params 5210-5219 will persist or not depending on") + 7 N..... COMMENT("PERSISTENT_G92_OFFSET setting in .ini file") +G92 flag: param 5210 == 2.000000 +G92 params: 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 + 8 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 9 N..... SET_XY_ROTATION(0.0000) + 10 N..... SET_FEED_MODE(0) + 11 N..... SET_FEED_RATE(0.0000) + 12 N..... STOP_SPINDLE_TURNING() + 13 N..... SET_SPINDLE_MODE(0.0000) + 14 N..... PALLET_SHUTTLE() + 15 N..... PROGRAM_END() + 1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 3 N..... SET_G92_OFFSET(25.4000, 25.4000, 25.4000, 1.0000, 1.0000, 1.0000) + 4 N..... SET_XY_ROTATION(0.0000) + 5 N..... SET_FEED_REFERENCE(CANON_XYZ) + 6 N..... COMMENT("G92 params 5210-5219 will persist or not depending on") + 7 N..... COMMENT("PERSISTENT_G92_OFFSET setting in .ini file") +G92 flag: param 5210 == 2.000000 +G92 params: 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 + 8 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 9 N..... SET_XY_ROTATION(0.0000) + 10 N..... SET_FEED_MODE(0) + 11 N..... SET_FEED_RATE(0.0000) + 12 N..... STOP_SPINDLE_TURNING() + 13 N..... SET_SPINDLE_MODE(0.0000) + 14 N..... PALLET_SHUTTLE() + 15 N..... PROGRAM_END() + 1 N..... USE_LENGTH_UNITS(CANON_UNITS_MM) + 2 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 3 N..... SET_G92_OFFSET(0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 4 N..... SET_XY_ROTATION(0.0000) + 5 N..... SET_FEED_REFERENCE(CANON_XYZ) + 6 N..... COMMENT("G92 params 5210-5219 will persist or not depending on") + 7 N..... COMMENT("PERSISTENT_G92_OFFSET setting in .ini file") +G92 flag: param 5210 == 0.000000 +G92 params: 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 + 8 N..... SET_G5X_OFFSET(1, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000, 0.0000) + 9 N..... SET_XY_ROTATION(0.0000) + 10 N..... SET_FEED_MODE(0) + 11 N..... SET_FEED_RATE(0.0000) + 12 N..... STOP_SPINDLE_TURNING() + 13 N..... SET_SPINDLE_MODE(0.0000) + 14 N..... PALLET_SHUTTLE() + 15 N..... PROGRAM_END() diff --git a/tests/interp/g52/g92-offset-persistence/g92_offsets.ngc b/tests/interp/g52/g92-offset-persistence/g92_offsets.ngc new file mode 100644 index 00000000000..66fe6ab61cc --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/g92_offsets.ngc @@ -0,0 +1,7 @@ +(G92 params 5210-5219 will persist or not depending on) +(PERSISTENT_G92_OFFSET setting in .ini file) + +(PRINT,G92 flag: param 5210 == #5210) +(PRINT,G92 params: #5211 #5212 #5213 #5214 #5215 #5216 #5217 #5218 #5219) + +M30 diff --git a/tests/interp/g52/g92-offset-persistence/g92_offsets.var.template b/tests/interp/g52/g92-offset-persistence/g92_offsets.var.template new file mode 100644 index 00000000000..0249226df07 --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/g92_offsets.var.template @@ -0,0 +1,10 @@ +5210 2.000000 +5211 1.000000 +5212 1.000000 +5213 1.000000 +5214 1.000000 +5215 1.000000 +5216 1.000000 +5217 1.000000 +5218 1.000000 +5219 1.000000 diff --git a/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_false.ini b/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_false.ini new file mode 100644 index 00000000000..7fbb807f1e3 --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_false.ini @@ -0,0 +1,2 @@ +[RS274NGC] +PERSISTENT_G92_OFFSET = false diff --git a/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_true.ini b/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_true.ini new file mode 100644 index 00000000000..e310b638e4e --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/persistent_g92_offset_true.ini @@ -0,0 +1,2 @@ +[RS274NGC] +PERSISTENT_G92_OFFSET = true diff --git a/tests/interp/g52/g92-offset-persistence/test.sh b/tests/interp/g52/g92-offset-persistence/test.sh new file mode 100644 index 00000000000..16b126c4c3e --- /dev/null +++ b/tests/interp/g52/g92-offset-persistence/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# +# Set up .var file with made-up values for #5210-#5219 +# +cp g92_offsets.var.template g92_offsets.var +# +# Check PERSISTENT_G92_OFFSET = true +# Should reproduce params in .var file for #5210-#5219 +# +rs274 -g -v g92_offsets.var -i persistent_g92_offset_true.ini \ + g92_offsets.ngc +# +# Check PERSISTENT_G92_OFFSET default = true +# Should reproduce params in .var file for #5210-#5219 +# +rs274 -g -v g92_offsets.var g92_offsets.ngc +# +# Check PERSISTENT_G92_OFFSET = false +# Should produce 0.0000 values for #5210-#5219 +# +rs274 -g -v g92_offsets.var -i persistent_g92_offset_false.ini \ + g92_offsets.ngc + +# Clean up +rm -f g92_offsets.var g92_offsets.var.bak