Team293 / CNCMilling

Information on using the CNC machines and scripts for generating G-code.
0 stars 0 forks source link

returning to original Z #6

Open anthropotron opened 1 year ago

anthropotron commented 1 year ago

I do wonder if this should be returning to the original Z, with the new tool offset applied, after the X and Y. The original Z is not being stored and not being returned to. It may not be a big deal with the current use, but that may be just by chance.

Just as an example, imagine the position just before M6 to be X-10Y-11Z-5 in machine coordinates, and just before returning after the tool change the machine coordinates are X0Y0Z0 (the end position of the tool change procedure). The returning to original X and Y would be moving to X-10Y-11Z0. If the next statement is a move to X-11Y-11, it will go from X-10Y-11Z0 to X-11Y-11Z0, which isn't correct, because VCarve intended the move to be from X-10Y-11Z-5 to X-11Y-11Z-5. If it's a cutting move, it will be cutting air, which will also leave too much material for the next pass.

There are a couple ways to do this, depending on what information is available to the macro.

One way to do it, without needing to do math on the machine coordinates (by subtracting the old tool length and adding the new one), would be to use a disposable WCS, say G59.3 (for example). You need to be able to save what current coordinate system you are in. Then you can do G10 L20 P9 X0Y0Z0 (or whatever variant of that works on the StepCraft) to set the current position as the origin in G59.3. Then do the tool changes as you already are in machine coordinates (with G53). When done, switch to G59.3, do G0 X0 Y0 and then G0 Z0, which will return the tool to the previous position (also taking into account the new tool length), then switch back to the original coordinate system before returning to the job. The downsides are that you need to make sure your jobs never use G59.3 themselves, and you need to be able to know the original coordinate system. (It won't always be G54.) You don't need to remember the original coordinates at all with this method.

Another way would be to save the original tool length and the original Z (and X and Y) in machine coordinates, then return to G0 X(originalX) Y(originalY) then G0 Z(originalZ - originalToolLength + newToolLength). Maybe this is better if the macro is able to retrieve and save the original and new tool lengths.

Or maybe there's another method that works better.

I'm assuming some things about the StepCraft, but you get the idea. Maybe there is something about this macro or the StepCraft that I don't know, and it's not actually an issue at all, but I wanted to bring it up just in case.