Macro to trace bounding box of loaded G-code with laser (Answered)

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

maxmeaker
Posts: 27
Joined: Thu Oct 17, 2019 11:36 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: 7804734901A7-0627192197

Macro to trace bounding box of loaded G-code with laser (Answered)

Post by maxmeaker »

This idea is inspired by a blog post I found here: https://hackingismakingisengineering.wo ... c-machine/

Basically, this guy created a macro that looks at the currently loaded program, finds the max and minimum X & Y values, and then moves the machine to trace a bounding box that encapsulates all of the toolpaths in said loaded program.

Here is a short video this fella posted showing his machine doing just that:

So my question is can this be replicated in CNC12? The software must already be doing this to some degree in order to be able to throw 907 axis travel exceeded errors.

You might ask "why do you want this when you can just look at the backplot graphics?" and while I do find that very useful, I think being able to watch a laser physically outline the extent of the toolpaths would be very helpful, especially if you are trying to cut something out of an oddly shaped piece of stock.

Moving the machine to trace the bounding box seems easy enough to put into a Macro. The part I'm unsure about is getting the Macro to look at the loaded program and determine the max and minimum X & Y values.
martyscncgarage
Posts: 7962
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
CNC Control System Serial Number: none
Location: Mesa, AZ

Re: Macro to trace bounding box of loaded G-code with laser

Post by martyscncgarage »

You are responsible for setting part zero after the machine is homed.
You certainly could by an aftermarket cross hair laser and attach it to your Z axis and if you know the overall size of the part you could MDI it and just watch.

I don't see the benefit. You should know how large part is, where you set Part zero is where the part will start to cut. Yes, always press F8 Graph to let CNC12 run through the code to see if you didn't make a mistake in setting your part zero.
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
maxmeaker
Posts: 27
Joined: Thu Oct 17, 2019 11:36 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: 7804734901A7-0627192197

Re: Macro to trace bounding box of loaded G-code with laser

Post by maxmeaker »

Thanks for the response Marty. Yes the next improvement for my machine is to add a cross hair laser.

I completely agree that setting my my part zero is my responsibility. But the goal of this macro is to serve as a double check before hitting cycle start.

You are correct that there are already a few ways to check my part zero.
1) I can use the graph function to watch the backplot, which gives a good overview of the toolpaths relative to your part zero, but that doesn't help you confirm your part zero is infact where you want it.

2) as you suggested, I could use MDI to move the machine around the boundary of the toolpaths, but that's something I would have to manually setup for every program which is not what I want.

If it helps to clarify the benefit of this macro I'm talking about, my machine is a CNC router. I recently attempted to machine an oval shaped part out of a slightly larger oval shape piece of stock (only about 1/8" of positive stock around the perimeter of the whole shape) I did my best to set my part zero at the center of the oval shaped stock, but managed to be off far enough to where one half of the edge of my part wasn't cut, and the other half had more than 1/8" material removed (completely my fault). This laser trace macro I would like to create would have allowed me to catch that my part zero was not accurately centered on my odd shaped stock.

All that aside, my question still stands. Is it possible to have a macro look at the currently loaded program and pull out the min and max X & Y values?
cncsnw
Posts: 1988
Joined: Wed Mar 24, 2010 5:48 pm

Re: Macro to trace bounding box of loaded G-code with laser

Post by cncsnw »

Is it possible to have a macro look at the currently loaded program and pull out the min and max X & Y values?
No.
Sword
Posts: 209
Joined: Fri Nov 30, 2018 1:04 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: none

Re: Macro to trace bounding box of loaded G-code with laser

Post by Sword »

What program are you using to post your code with? Some will have the job dimension added to the top of the file and you could set up the post processor to use that information and give you the option of doing a "Frame" or not. You could also add a frame in your design and toolpath just that with a custom post p that turns on a cross hair laser and inhibits the Z. Just thinking....
Scott

"It’s easier to fool everyone than it is to convince them they've been fooled" - Mark Twain
maxmeaker
Posts: 27
Joined: Thu Oct 17, 2019 11:36 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: 7804734901A7-0627192197

Re: Macro to trace bounding box of loaded G-code with laser

Post by maxmeaker »

cncsnw wrote: Wed Apr 07, 2021 4:40 pm
Is it possible to have a macro look at the currently loaded program and pull out the min and max X & Y values?
No.
Bummer. Well thanks for your input cncsnw.
Sword wrote: Wed Apr 07, 2021 7:32 pm What program are you using to post your code with? Some will have the job dimension added to the top of the file and you could set up the post processor to use that information and give you the option of doing a "Frame" or not. You could also add a frame in your design and toolpath just that with a custom post p that turns on a cross hair laser and inhibits the Z. Just thinking....
I'm using Swissi's fusion 360 post. Not sure if it includes the job dimensions like you describe or not. I like your train of thought though. Thats probably the next best way to achieve what I'm after.
martyscncgarage
Posts: 7962
Joined: Tue Mar 28, 2017 12:01 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes
CNC Control System Serial Number: none
Location: Mesa, AZ

Re: Macro to trace bounding box of loaded G-code with laser (Answered)

Post by martyscncgarage »

As the user, you should know where your origin point is set to. You draw up the part, you CAM the part. (If someone else is doing this for you, you should have a drawing showing where the origin point is)
You set part zero on the machine. You test with F8 Graph which shows you the part and scales.
Reminder, for support please follow this post: viewtopic.php?f=20&t=383
We can't "SEE" what you see...
Mesa, AZ
swissi
Posts: 471
Joined: Wed Aug 29, 2018 11:15 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: 985DADEB24D5-0309180716

Re: Macro to trace bounding box of loaded G-code with laser

Post by swissi »

maxmeaker wrote: Wed Apr 07, 2021 11:48 pm I'm using Swissi's fusion 360 post. Not sure if it includes the job dimensions like you describe or not. I like your train of thought though. Thats probably the next best way to achieve what I'm after.
This should do what you want.

Use the Post Processor Property "Add Command to Begin of Job" and enter a command like this:

Code: Select all

G65 "c:\cncm\ncfiles\draw_boundary.cnc"
P1.PNG
P1.PNG (10.8 KiB) Viewed 161 times
If a command has been added, the Post Processor will add the corner coordinates of the bounding box to the job file like this:

Code: Select all

(Face1)
N20 #29002 = 0. ; X- Boundary
N25 #29003 = 6.38 ; X+ Boundary
N30 #29004 = -1.265 ; Y- Boundary
N35 #29005 = 0. ; Y+ Boundary
N40 G54
N45 G65 "c:\cncm\ncfiles\draw_boundary.cnc"
Copy the attached script "draw_boundary.cnc" to the c:\cncm\ncfiles folder and add to the script what ever you want it to do. Right now it just moves to the lower left boundary corner (X- Y-) and draws the boundary box clock wise.

Here's the modified Post Processor and the sample script:
Centroid_Mill_MinRev-40783-swissi-006-Beta1.zip
(21.91 KiB) Downloaded 5 times
draw_boundary.cnc
(250 Bytes) Downloaded 4 times
Post here if you have any questions.

-swissi
If you are using Fusion 360, check out my CNC12 specific Post Processor
If you are using a Touch Probe, Tool Touch Off Device or a Triple Corner Finder Plate, check out my ProbeApp

Contact me at swissi2000@gmail.com
maxmeaker
Posts: 27
Joined: Thu Oct 17, 2019 11:36 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: 7804734901A7-0627192197

Re: Macro to trace bounding box of loaded G-code with laser (Answered)

Post by maxmeaker »

Wow Swissi, thanks for taking the time to explain how I could modify the post to get this working. I'll take a crack at it and share my results.

Cheers!
Sword
Posts: 209
Joined: Fri Nov 30, 2018 1:04 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
MPU11 & GPIO4D -w/ 3rd Party Drives: No
DC3IOB: No
CNC11: No
CPU10 or CPU7: No
CNC Control System Serial Number: none

Re: Macro to trace bounding box of loaded G-code with laser (Answered)

Post by Sword »

How's that for service!! :)

Don't forget to buy the probe app! ;)
Scott

"It’s easier to fool everyone than it is to convince them they've been fooled" - Mark Twain
Post Reply