I didn't like the G10 and potentially getting lost if you stopped midprogram. I will post the code below using more common macros replacing an older program that was verified to work but using other ones.
This is for a .125 spacer using a .118 cutoff , ran 4 times. This machine may not be able to run #500 macros, and I know #100s work.
Hello EndlessWaltz,
Your reasoning is flawed. What you're doing with the following Block:
#5222=[#5222-#100]
is exactly what you would be doing using G10. You're actually changing the value of the G54 Z Workshift. Accordingly, if you have to stop the program midpoint, you will be equally lost with this solution, as you would be using G10 to modify the G54 Workshift.
I don't see your approach as being simple. It requires more work, in the way of recording the original value of the G54 Workshift Offset and restoring it in a manner that is relatively fool proof. You would want to be able to restore the original value under any circumstance of having to abort the program. You really need to be able to restore the original value at the Start of the program, in case the program didn't make it to the End. In this case you would probably have to store the value in a Common, Nonvolatile Variable before the program is started (manual input). Using G52, you simple include G52 Z0.0 at the Start of the program; that's it.
#5222=0 Unsure if needed here
You definitely don't want the above Block there, or anywhere. That will set the G54 Z to Zero, meaning that the Z Zero of the Workpiece will be at the Z Reference return Position of the machine. What happens with the next Motion Move will depend on the parameter settings, ie, whether a change to the Offset is effective in the Next Motion Block, or not until G54 is executed again. What would be more logical is the following:
G28U0.0W0.0
T0101
G54
#105 = #5222 (Store The Original G54 Z Workshift Value)
G50S900
G96S400
M3
M8
Then at the end of your program, restore the original value to your G54 Z Workshift as shown below:
T0505(MDT)
G50S900
G96S200
M3
M8
G0 X1.010 Z.1
#103=-.243
M98Q44L4
N45
M9
#100=0
#5222 = #105
G28U0.0W0.0
M30
But you're still going to be screwed if you have to abort the program before restoring the G54 Z Workshift; it will be whatever value it was when you aborted. However, this may work in your favor, if you wanted to start where you left off, but based on your comment in an earlier Post
EndlessWaltz said:
what I would rather have, cut air if need be.
, that won't happen.
That's why I stated in my previous Post:
you don't have to remember the original Workpiece Coordinate System Value
when using G52. Simply execute G52 Z0 at the Start of the program and the G52 Offset Shift will be extinguished from the G54 Z Workshift. The G54 Worksfit Offset remains unchanged throughout the machining process.
Your Subprogram could be arranged something like the following:
N44(sub)
T0505
G1 X.950 Z0.0 F.010
G1 X.990 Z-.020 F.004
G1 Z-.223 F.010
G1 X.950 Z-.243 F.002
M10
G1 X0.0 F.002
M11
G0X1.010
#100=[#100+#103]
G52 Z#100
M9
M99
For safety, G52 Z0.0 would appear before G54 at the Start of your program. This would ensure that No Offset Shift was being applied to your Workshift Offset. Similarly, depending on parameter setting, G52 will be reset to Zero when Reset is Pressed. For G52 to be set to Zero with Reset is the default parameter setting.
The way in which you have applied the Offset Shift is also flawed. Your following code:
#100=[#100+#103]
#5222=[#5222-#100]
will compound the Shift Offset. First Loop of the Subprogram, -0.243 will be applied to the G54 Z Workshift, on the Second Loop -0.486, the Third Loop -0.729 and so on. These Offset Shifts would be applied to that previously modified G54 Workshift, Accordingly, your code as is, will modify the G54 Z Workshift Offset by 2.43" after four cycles of the Subprogram, instead of only 0.972" and it will be applied in the wrong direction.
Also, you would have to specify G54 in the Subprogram so that the New Workshift value is applied. You could do this as follows:
N44(sub)
T0505
G1 G54 X.950 Z0.0 F.010
With regards to Offset Shift being applied in the wrong direction, the logic of subtracting #100 is incorrect. In the First Loop of the Subprogram:
#100=[#100+#103]
would have #100 = -0.243, the Second Loop, #100 = -0.486 and so on. As #5222 will be a negative value to start off, subtracting a minus value is the same as adding a positive value. The net result of your algorithm is a G54 Workshift value that is less negative than it was and therefore, the Z zero of the Workpiece move in a Positive direction, instead of the desired Negative direction. Its always preferable to add a variable and allow the sign of the variable to determine direction its applied (+ or -). Adding a Minus value is the same as Subtracting a Positive value.
Fancuku solution will allow you to restart from where you left off, without air cutting, but the program is more verbose and it relies on the operator knowing where he got up to if a restart is required. The above G52 solution is very safe, but will cut air for the parts that have already been parted off; it doesn't require any thinking by the operator.
Regards,
Bill