Success: Help/advice on Edit G-Code needed

I’m looking for help/advice on how to save my current project by editing the G-Code.

Project: Carving Design and Make’s Last Supper in wood from a 100+yr old Oak Church door.

Issue: UGS froze halfway through cut and halfway through a block of G-Code. Actually, UGS froze a few times during this project. I was able to work through earlier UGS freezes.

  • Restarted the project couple of times
  • Deleted ‘finish cutting’ blocks of g-code with bCNC and restarted at new blocks.

bCNC lets me delete ‘blocks’ of G-Code, save the g-code file. Load the g-code file in UGS and long as I have Home spot on, I can restart the finish cut and continue the project.

Currently, the CNC is sitting halfway within the finish cut at line 296,062 in a block of G-Code that is 366,064 lines.

Thinking if I can edit the g-code, I can make a new g-code file to continue the finish cut.

I see that my G-Code files start with the following Header/Setup information.

T1
G17
G20
G0Z0.2500
G0X0.0000Y0.0000S12000M3
G0X3.9343Y-5.8948Z0.2500
G0Z0.2000
G1Z-0.0026F20.0
G1X3.9549Y-5.8943Z-0.0027F100.0 //Changing the X & Y to the new position.

I took pictures of UGS to doc where the last finished coordinate was, so I think.
G1X1.0036Z-0.4995

I’d like make a new G-Code file that starts at the current Y-axis pass, not the spot along the Y-axis. This will allow me to stop the cut if I’m grossly off X or Y, on the edge of the cut area.

Here’s the previous Y.

G1X9.9249Z-0.0031
G1X9.9349Z-0.0022
G1X9.9448
G1X9.9541Y0.6752 //Previous Y
G1X9.9441
G1X9.9242Z-0.0035
G1X9.8745Z-0.0061
G1X9.8346Z-0.0104

Inorder to make a new file to start on this Y pass, I’m thinking from what I know about G-Code, I delete all the previous lines add the Header/setup files and save? Am I correct or missing something.
Such as the following:

T1
G17
G20
G0Z0.2500
G0X0.0000Y0.0000S12000M3
G0X9.9541Y0.6752Z0.2500 //Changed to current Y
G0Z0.2000
G1Z-0.0026F20.0
G1X9.9541Y0.6752F100.0 //Changed to current Y
G1X9.9441
G1X9.9242Z-0.0035
G1X9.8745Z-0.0061
G1X9.8346Z-0.0104

Second question, I haven’t moved the CNC, therefore can I assume the current X/Y positions is X9.9541 Y0.6752. Thus, when I restart UGS can I assume (there’s a problem when you use that word :slight_smile: if I move -9.9541 on X and -0.6752 on Y I’m at the current X/Y zero home based on the last cut? Seems this would be the best way to assume the Home position. Let me know if not.

I use ‘center’ as my Home for this project because the old church door wood has belved edges making it hard to home on the corners. I will note I used a piece of plywood, squared on top of the piece to mark center, so i can check center after the cut was started, ie. after roughing, if anything happened. Every now and then I have a decent idea. Even though I have this plywood, seems to me using the current X/Y would be the best way to re-center. Thoughts?

I always go back to a previous retraction and rapid movement (non-cutting).
Not knowing why it froze, I wouldn’t trust the reported position. While UGS can freeze instantly, your motors can’t stop instantly.
How did you set your zero, in UGS, initially?

1 Like

@NeilFerreri1 what do you mean by a ‘previous retraction and rapid movement’

Good point on not trusting the reported position.

<<How did you set your zero, in UGS, initially?>>
Measuring in from X & Y to center. Then used by Charlie’s Triquetra plate to set Z

Basically, rewind until you get to the last point the Z lifted to a safe height and start from there.

When you set zero, did you use G10L20 or G92? If you used G10L20 (I’m not sure what UGS uses now), you could just load your modified code, home, and go. You’ll be limited by the precision of your homing switches which should be pretty precise.

1 Like

I assume you mean one of these points
G1X-6.3022Z-0.0051
G1X-6.3519Z-0.0031
G1X-6.3619Z-0.0022
G0Z0.2500
G0X10.0286Y-4.7448
G0Z0.2000
G1Z-0.0022F100.0
G1X10.0087Z-0.0039
G1X9.9689Z-0.0069
G1X9.9390Z-0.0113

It appears to this G-Code newbie that these are the beginning of the ‘blocks’ seen in bCNC. Which is what I’ve been doing by deleting cut blocks and starting at uncut blocks of g-code.

If that is the case, Crap, that’s 295,950 lines back.

I set Z with a macro, I don’t have it in front of me right now.
I don’t have homing switches, I’m an upgrade Shapeoko, many upgrades…

Doesn’t matter then, you’ll have to do it manually again.

Yikes. You don’t have to go back to that point, but make sure you’re Z is where it should be. It looked off in your example.

Out of curiosity, if you’re having issues with UGS and you’re using bcnc to modify the code, why not just use bcnc to control the machine?

Okay if I don’t have to go back to that point. How does one create a new point?

Assume you mean, in my case, use Charlie’s Triquetra plate to set Z?

Comfort, I’ve always used UGS, but now I’m done with it. I’ve experianced my last freeze, I know some continue to use it successfully. And as I understand I might have a short which is causing the freezing. I’m not sure how to fund any such short.
Actually was thinking of going to PicSender.
bCNC allows me to edit the file, but wow does it take a long time to load these files. So I never really considered switching to it.

I meant to make sure your Z is where it should be in your file.
And, yes, use a probe for Z0.

Ah, Got it Now. I hope

So make a new G-Code file like the following?

T1
G17
G20
G0Z0.2500
G0X0.0000Y0.0000S12000M3
G0X9.9541Y0.6752Z0.2500 //Changed to current Y
G0Z0.2000
G1Z-0.022F20.0 //Changed from Z-0.0026
G1X9.9541Y0.6752F100.0 //Changed to current Y
G1X9.9441
G1X9.9242Z-0.0035
G1X9.8745Z-0.0061
G1X9.8346Z-0.0104

Sorry for being redundant. I’ve messed with G-Code sometime ago and really screwed up a piece that I trashed. Just don’t want to trash this one…

I’d set my Z0 a few mm high to check if things seem ok. If they do, then set the correct Z, cross your fingers, and go.
If you zero your XY&Z with a G10L20X0Y0Z0 (or Zwhatever for the probe block), jog up a few mm, send G92 Z0. That will temporarily set your Z a few mm high. When you stop the test, reset the controller, and your Z will be ready for the actual cut.

I actually thought of that last night, raise the Z a couple mm to see if it is in the ballpark and check that the G-Code file runs ok. Thanks for suggesting.

G92.1 I assume is what you mean by ‘reset the controller’

Plan A: Edit, home and run the G-Code as stated in this thread with all fingers crossed!
Plan B: Get PicSender, Home as close to original home and start cut over a couple mm deeper on Z

I’ll let you know how it goes. Thank you for the help and advise @NeilFerreri1

After sweating it out, biting all nails, pulling hair (not really I’m bald), and any other procrastination I could come up with - we edited the files, homed the sucker and held our breath as the bite hit the wood. I did test the edited G-Code file as @NeilFerreri1 suggested. After a couple passes we realized Z was a bit to high for some reason. Lowered Z and let the baby cut away.

I’ll let the pictures tell 'The rest of the Story"

Close up of the area where the past cut froze, no sign of misplaced X/Y from what we can see.


Now for some light sanding.

3 Likes