Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: strikermed on January 02, 2021, 09:58:53 PM

Title: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 02, 2021, 09:58:53 PM
Hey Guys,

I'm pretty new to this, so please bare with me.

I've got a custom built CNC, using Smooth stepper ESS, and Mach 4.  I did my Design and CAM in Fusion 360.  Today was the first day I got it up and running, and I wanted to find out if there are a few things that I could do to streamline the setup of a G-Code file, and perhaps shed some light on an issue I'm having.

I've attached my G-Code, but the below changes won't reflect in the code.

First, I'm new to G-Code, so I did a lot of research to do these small adds.  First, since I'm zeroing the work area, and I found that if you're not exactly where you zeroed the work area the machine will run with some amount of offset that you started at.  So, what I did was added a "G0 Z3" to ensure that where ever the X and Y axis take me, the spindle won't collide with hold downs.  I also added a 10 second pause "G4 P10000" to give me a little mind reset for what's to come.  Next comes the spindle command "s20000 M3" and I added a 4 second pause to allow for the spindle to get to speed "G4 P4000."  The rest runs as is until I get to the end.  This all runs great, with no issues

Problem #1
About 7/8 of the way through the G-Code I run into an issue.  I think it's around line 301 in the attached file.  For some reason, when I have my soft limits enabled (They're set to .5 inches on X and Y and 14+ and 12+ inches respectably) I get an "Error: X Axis commanded over softmin."  I've tried moving the workpiece and work area to the center of the machine with no luck, so that's a mystery to me.  I'll run the G-Code without softlimits and it runs fine.  If someone has insight into this, I'm all ears.

Problem #2
Line 325 in my attached G-Code when we get to the G28 commands, some weird thing happens.  Instead of returning to the work area starting point X0y0, the G-code is sending it to the Machine coordinates, thus tripping my limit switches...  Does anyone have an explanation why that is?

My solutions: Remove line 325 - 327, and after G90 I insert "G0 Z3" to raise the spindle to clear any fastners, and then on the next line I add "G0 X0 y0" to return to the work area coordinates I started at, and then followed on the next line: "S0 M5" to shut down the spindle.


Am I reading all this wrong?  Do I have something else set up wrong where this isn't working as it's intended?  To get this far it took me a better part of the day, but it's definitely something I can repeat fairly quickly with other G-Code.  I would rather this just be done in the CAM software though....

Attached you will find "A3_Test_G_Code" which is the original from the CAM software.  "Revised A3_Test_G_Code" will be the version I revised that does what I want it to.
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: Cbyrdtopper on January 03, 2021, 12:37:52 PM
I’m not sure about problem 1. I’ll think on that more.
Problem 2, however, is not a problem; it is doing exactly what G28 is supposed to do.  It moves to the machine zero position. A better option is to use the G30 that I asked autodesk to add to the mach4 post processor.
Setup variables/register 5181,5182,5183 x,y,z positions respectively. Put a machine coordinate position in these #VARS so the machine will move to your desired position instead of the machine home position.   You must put something in these variables or it will act just like G28.
Haas Automation has a good video on this on their YouTube channel. Also, read up on the G28-30 in the mach4 manual.
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: joeaverage on January 03, 2021, 04:34:15 PM
Hi,
I don't like the Fusion generated G28 either, I use the drop down menu box in Fusions Post page to not use G28 but to go
to the prevailing work zero, ie the origin of your workpiece.

As for problem 1.........How are you homing your machine? Soft Limits are declared in machine coordinates and only make sense
if the machine coordinate zero is at some defined and repeatable location.

Try this analogy.

Imagine the XY extents of your machine to be a rectangular paddock. When you turn your machine on all that Mach knows is that you're somewhere
in that paddock. Lets say however there is one tree in this paddock, it does not really matter where it is, but obviously it does not shift.
So you drive Mach to the trees position and declare that position as 'Home'. Now you can declare that the Northern boundary fence is 52 yards
North of Home, the Eastern boundary fence is 74 yards to the East of Home....etc. These declarations of distances to the boundary are the
equivalent of Machs Soft Limits. You could now set an automatic lawn mower to mow the paddock and it would know how to avoid banging into the
fence by using the knowledge of the boundary distances.....but only if it knows where 'Home' is.

Homing your machine to a define and repeatable location is essential to use Soft Limits.

Craig
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 03, 2021, 07:13:29 PM
I’m not sure about problem 1. I’ll think on that more.
Problem 2, however, is not a problem; it is doing exactly what G28 is supposed to do.  It moves to the machine zero position. A better option is to use the G30 that I asked autodesk to add to the mach4 post processor.
Setup variables/register 5181,5182,5183 x,y,z positions respectively. Put a machine coordinate position in these #VARS so the machine will move to your desired position instead of the machine home position.   You must put something in these variables or it will act just like G28.
Haas Automation has a good video on this on their YouTube channel. Also, read up on the G28-30 in the mach4 manual.

That’s a helpful tip, and I’ll have to try that.  I like the idea of sending my machine to the far side after a cut so I can clear the material.

Thanks
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 03, 2021, 07:23:18 PM
Hi,
I don't like the Fusion generated G28 either, I use the drop down menu box in Fusions Post page to not use G28 but to go
to the prevailing work zero, ie the origin of your workpiece.

As for problem 1.........How are you homing your machine? Soft Limits are declared in machine coordinates and only make sense
if the machine coordinate zero is at some defined and repeatable location.

Try this analogy.

Imagine the XY extents of your machine to be a rectangular paddock. When you turn your machine on all that Mach knows is that you're somewhere
in that paddock. Lets say however there is one tree in this paddock, it does not really matter where it is, but obviously it does not shift.
So you drive Mach to the trees position and declare that position as 'Home'. Now you can declare that the Northern boundary fence is 52 yards
North of Home, the Eastern boundary fence is 74 yards to the East of Home....etc. These declarations of distances to the boundary are the
equivalent of Machs Soft Limits. You could now set an automatic lawn mower to mow the paddock and it would know how to avoid banging into the
fence by using the knowledge of the boundary distances.....but only if it knows where 'Home' is.

Homing your machine to a define and repeatable location is essential to use Soft Limits.

Craig

Thanks for the reply Craig.  I home using switches on the negative x and y axis.  Those same switches act as x+ and x-, and y+ and y- limit switches.  I home every time I start up the machine and even occasionally between cuts (which has only been a handful so far).  That’s why I mentioned I was even getting the error in the middle of my machine. 

So it boggles me why soft limits would even be addressed.  Like I said, when I turn them off it runs flawlessly, but I’d prefer to have them on.

Lastly, I stumbled on a video by warp 9 (I’m using a smooth stepper ess) and they go about setting soft limits in a round about way.  I’m curious if there is some issue in how I set mine up.  I used only the Mach 4 interface, aside from activating them in the warp 9 plugin.  Setup can be quite confusing jumping from one setup menu to another for the same purpose....

Regardless, my soft limits worked when manually testing them, but I wonder if some automation aspect has issue with how they are set up.  The video I found is 2 years old: https://youtu.be/laLrcg_RbNw

I didn’t follow this procedure when setting up mine, but this seems more complicated than it needs to be.
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: joeaverage on January 03, 2021, 08:13:19 PM
Hi,
so what data are you populating the SoftLimits page with?.

If you are using X- and Y- as home switches then at least one, say SoftXMin=0 or SoftXMax=0 must be true for each axis

For instance my existing mini-mill has 180mm x 180mm x180mm of travels. The X home and Y home switches occur with
the tool at x=0, y=0, and the Z axis home switch is at the top of travel, Z top=0. My SoftLimits are:

X    min=0 max=180
Y    min=0 max=180
Z    min=-180 max=0

Craig




Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 03, 2021, 08:46:38 PM
Hi,
so what data are you populating the SoftLimits page with?.

If you are using X- and Y- as home switches then at least one, say SoftXMin=0 or SoftXMax=0 must be true for each axis

For instance my existing mini-mill has 180mm x 180mm x180mm of travels. The X home and Y home switches occur with
the tool at x=0, y=0, and the Z axis home switch is at the top of travel, Z top=0. My SoftLimits are:

X    min=0 max=180
Y    min=0 max=180
Z    min=-180 max=0

Craig

That’s essentially what I have.  Since I have my machine back off the switch .5 inches, I have my soft limit min set to .5 and my max set at the machine max prior to activating the limit switch.

I’m confident those settings are correct, what I’m unsure about is which I use to set my homing... do I use the ESS plugin or do I do it in Mach 4 control?
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: joeaverage on January 03, 2021, 09:09:15 PM
Hi,
homing is a shared activity.

Mach provides the basic data, for instance the homing direction each axis is to take, the homing order, the offset (if any), the homing speed
and softlimits.

The homing procedure itself is a realtime procedure and must perforce be done by the controller.The homing axis is set in motion and is meant to stop
when the switch activates. The ESS can do this immediately whereas if it reported back to Mach it would take tens of milliseconds, way too slow, the machine
will have crashed into the stop before then.

In the ESS plugin:
PinsConfig: is where you assign a pin to each of your home switches
InputSignals: is where you map each pin to its logical event, Motor0Home for example, and enable it
Homing: any pins and/or events you have enabled in the InputSignals tab will be replicated in this tab and you can attach more data, like
approach speed, backoff speed and whether you are going to use index homing.

So there are four pages that you need attend to set up homing, the Homing/Limits tab in the Mach Control plugin
and the three (PinsConfig, InputSignals,Homing) tabs in the ESS plugin.

Craig
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 03, 2021, 09:40:21 PM
Hi,
homing is a shared activity.

Mach provides the basic data, for instance the homing direction each axis is to take, the homing order, the offset (if any), the homing speed
and softlimits.

The homing procedure itself is a realtime procedure and must perforce be done by the controller.The homing axis is set in motion and is meant to stop
when the switch activates. The ESS can do this immediately whereas if it reported back to Mach it would take tens of milliseconds, way too slow, the machine
will have crashed into the stop before then.

In the ESS plugin:
PinsConfig: is where you assign a pin to each of your home switches
InputSignals: is where you map each pin to its logical event, Motor0Home for example, and enable it
Homing: any pins and/or events you have enabled in the InputSignals tab will be replicated in this tab and you can attach more data, like
approach speed, backoff speed and whether you are going to use index homing.

So there are four pages that you need attend to set up homing, the Homing/Limits tab in the Mach Control plugin
and the three (PinsConfig, InputSignals,Homing) tabs in the ESS plugin.

Craig

Craig, again you're schooling me in the little things I don't know.  Thanks for that insight about how the ESS and Mach work together.  As for what you have listed, that's exactly how I've set it up, and the only thing that doesn't have information is for the Index pin section of the ESS plugin.
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: joeaverage on January 03, 2021, 09:54:12 PM
Hi,
are you going to use index homing?

I never bothered and with good quality roller plunger snap action microswitches I can get 0.02mm repeatability from session to
session without index homing, and 0.02mm is close enough for me.

If you don't want index homing, just don't enable it. If you do then you'll have to assign pins, input assignments....all the usual stuff for
inputs but for three new index inputs.

Craig
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 03, 2021, 11:45:07 PM
Hi,
are you going to use index homing?

I never bothered and with good quality roller plunger snap action microswitches I can get 0.02mm repeatability from session to
session without index homing, and 0.02mm is close enough for me.

If you don't want index homing, just don't enable it. If you do then you'll have to assign pins, input assignments....all the usual stuff for
inputs but for three new index inputs.

Craig
Gotcha, Yeah I might do it down the road, but as of right now, my method is pretty accurate.  I'm assessing everything right now.  I'm perfectly square, but I need to do some minor motor tuning.  I programmed a 4"x4" square, and my Y axis cut 4.003" and X axis cut 4.016".  My X axis has up to 4 thou of slop, so i know I can still dial that down.  That's about 4 thou per inch that I'm off.... 

Here's an odd question outside of G code now.  I've used a dial indicator to measure and tune the motors using .5 and 1 inch increments.  When I tested a large distance like 12 inches, I would be nearly a 1/32" off when using are reliable straight edge (wood pecker brand) and I used a knife edge of a bit, so a flat profile bit with a sharp edge, to make my measurement.

I'm not sure why this is, but I trusted the overall measurement more than my dial indicator.  I'm kind of lost why fine tuning in 1 inch increments would scew 1/32 of an inch over 12 inches.  After tuning with the straight edge, I then checked with the dial indicator.  My Y axis is off by about .003 over half an inch and my X is .0001 over half an inch. 

You know as I checked those just now, I realized my gantry has .010" of slop (due to plywood compression).  This would probably account for the .016 of being off

For woodworking this is more than close enough.  I cut a 12x12 square out, and you couldn't tell on a measuring tape that it was off by few thou here and there. 

I guess what's important is when I command my axises to move back and forth, they do it reliably and accurately to .002 and .003.


Now the question is, will this be enough to machine aluminum?  Primarily boring out holes so I can upgrade this thing down the road!  I would love to replace the gantry with a 3x6 80/20 product, and make custom uprights so they are stiffer than the plywood setup I have now.  Also, I would like to upgrade how I've mounted the ball screw on the gantry.   All future projects, but for now, I need to learn some more CAD, CAM and G-Code.

If anyone has answers to why soft limits act the way they do running G-Code, please comment. 

If anyone is interested you can check out my build, I've attached pics.
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: KatzYaakov on January 04, 2021, 02:02:46 AM
when i start i also did not use index homing ,but i got many problem ,specheli with z axiss(0.2mm  +-)
we change all our machines to use the index from encoder
,now its much better, i suggest use home index
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: TOTALLYRC on January 07, 2021, 05:36:21 AM
Hi Strikermed,
"Now the question is, will this be enough to machine aluminum?  Primarily boring out holes so I can upgrade this thing down the road!  I would love to replace the gantry with a 3x6 80/20 product, and make custom uprights so they are stiffer than the plywood setup I have now.  Also, I would like to upgrade how I've mounted the ball screw on the gantry.   All future projects, but for now, I need to learn some more CAD, CAM and G-Code."

To increase the stiffness of the X axis, you can add a piece or two of plywood 90 degrees to the current uprights. It looks like you have enough room in the pictures. It should be widest near the linear bearing and can taper to almost nothing at the top. Right now you are flexing the plywood across it smallest dimension (3/4") and the new stiffener will be 2" minimum.
HTH
Mike
Title: Re: Fusion 360 and issues with Mach 4 G-Code
Post by: strikermed on January 07, 2021, 08:56:54 PM
Hi Strikermed,
"Now the question is, will this be enough to machine aluminum?  Primarily boring out holes so I can upgrade this thing down the road!  I would love to replace the gantry with a 3x6 80/20 product, and make custom uprights so they are stiffer than the plywood setup I have now.  Also, I would like to upgrade how I've mounted the ball screw on the gantry.   All future projects, but for now, I need to learn some more CAD, CAM and G-Code."

To increase the stiffness of the X axis, you can add a piece or two of plywood 90 degrees to the current uprights. It looks like you have enough room in the pictures. It should be widest near the linear bearing and can taper to almost nothing at the top. Right now you are flexing the plywood across it smallest dimension (3/4") and the new stiffener will be 2" minimum.
HTH
Mike

Thanks for the suggestion!  I had thought about gussets as well.  I thought by adding a strip of plywood I would be doing that very thing, but I think I need to give it a triangular gusset to stiffen it up.  Down the line I hope to update my gantry with 80/20, and build some custom brackets out of 1/2-3/4 aluminum plate to replace the plywood.  Hence the aluminum requirement.