Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Mauri on January 22, 2017, 04:55:55 PM

Title: Question on 4 Axis Toolpath?
Post by: Mauri on January 22, 2017, 04:55:55 PM
Hi,
For the last 18 months plus, the Mach 4 program has been unable to produce any 4 axis Toolpath that has any resemblance to the actual object, see pics below Venus Bust.
Is there anyone going to fix the issue? ???
Can anyone advise that Mach 4 program can actual cut a 4 Axis Toolpath?
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on April 07, 2018, 12:36:03 PM
Has anyone got any input on this issue. I have seen this issue asked in a few other posts but no real replies that I have found. mach 3 does not have this issue and I generally use mach 3 to check code that I have created but not run before just to make sure nothing is missing or out of range. :o
Title: Re: Question on 4 Axis Toolpath?
Post by: Dazed+Confused on April 08, 2018, 01:54:41 AM
Hi,
I have had it working for a while. I use Industrial version but tried this as a test now in the Mach4 hobby Demo.

First create a Toggle button on your screenset.
In the 'Down Script' enter...

Code: [Select]
--A rot on----------------------
local inst = mc.mcGetInstance()
mc.mcToolPathSetARotationAxis(inst, 0)

In the 'Up Script' enter...
Code: [Select]
--A rot off----------------------
local inst = mc.mcGetInstance()
mc.mcToolPathSetARotationAxis(inst, -1)

Secondly create a DRO and name it 'droRadius'.
In the 'On Modify Script' for the dro enter...

Code: [Select]
local inst = mc.mcGetInstance();
local getVal = scr.GetProperty('droRadius', 'Value');
local getValAsNumber = tonumber(getVal);
getValAsNumber = getValAsNumber / 2;    --convert to radius (dro is entered as diameter)
getValAsNumber = 0 - getValAsNumber;    --make negative for Z offset
mc.mcToolPathSetAAxisPosition(inst, 0.000, 0.000, getValAsNumber);

Load your Venus head in, enable rotations with your toggle button and enter diameter of the model and hit regen.
If weird stuff happens in a 2D job toolpath remember to toggle rotations OFF and regen your toolpath.
Also if your scale is wrong make sure your A Axis Machine Coords are at Zero.

Good Luck!
D+C
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on April 08, 2018, 02:28:52 PM
Thanks for the reply. I am going to try that a little later when I get some time at the machine again. I think what you have will resolve my problem as it appears that mach 4 right out of the box does not really recognize a 4th axis toolpath and this will add that ability to the toolpath window. A few days ago I generated some gcode in which I forgot to set my machine preference up as a 4 axis machine and left it on a 3 axis preference. I generated the code and when I loaded it in to mach 4 the tool path came up and looked exactly like the toolpath I generated in my cam/cad program that generates the gcode. The image in the toolpath window was 3d and represented the cylindrical shaped object I was working on  and I thought wow that's the first time I  have ever saw it actually recreate the object accurately. I then noticed in my gcode window that there was no A axis present only xyz. Once I regenerated the code set to a 4 axis machine and included the a axis movements the picture in the toolpath window looked like it always has in the past with what appears to be an object that looks nothing like what I am cutting but once finished the object does come out as designed.
I will post again after I have added the script to the screen file and let you know if worked for me.
Thanks for taking the time to reply and post that.....  
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 08, 2018, 04:05:22 PM
Dazed+Confused,
That looks like a great solution for my 3 year problem. ;D
I will try it when I later.
Maybe this should be coded in Mach4 Screen sets for all users on the next official release to make Mach4 display 4 axis correctly when choosing 4 Axis G-Code.
Nest question, what about 5 axis users, does this work for them as well?
Will they have to make up another button for the 5th Axis.
Thanks,
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on April 08, 2018, 09:24:38 PM
I made those edits and it does actually give a 3d view of the object in the tool path window.  I have not actually cut anything now so i don't know if that DRO value is intended to scale anything or what the purpose is exactly. Does the diameter you enter in to the DRO actually have any effect on anything?
Thanks again for the help on that....
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on April 08, 2018, 09:33:13 PM
I attached an example of a chess pawn. the 2d is the view I had prior to adding the dro and button. the other is the view when turned on and diameter is entered. The 2d view is a very closely represents what the half shape looks like and the 3d somewhat tapers the end where in the 2d it is kind of rounded and is actually how the object cuts and looks. Is that normal or is there something I need to work on do to get it to be closer to what the part actually looks like after cutting it?

UPDATE: After I posted I see it now. The 3d picture is actually like a mirror or inverted view. After i posted I actually saw the out line of the pawn in the top and bottom of the view, kind of like you are seeing two pawns side by side and tool path is the space between them, if that makes sense.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on April 08, 2018, 11:15:31 PM
Ok got it to generate the picture of the tool path correctly. I set all machine coordinates and work coordinates all to zero and the picture of the pawn shows up correctly in the tool path.
Thank you D+F for sharing that information and I hope my added comments will help anyone else who is wanting to the same and comes across the same little issues I did.
Thanks again D+F
Title: Re: Question on 4 Axis Toolpath?
Post by: Dazed+Confused on April 09, 2018, 02:48:19 AM
@Mauri
I only built a 4axis machine so have not idea about 5 axis stuff.....yet :)

@smav
Yes it is the inversion problem that made me figure out what 'mc.mcToolPathSetAAxisPosition' does.
As long as your machine coordinates are at zero it should work fine, this is probably a bug?
I was to lazy to come up with any lua code to fix it automagically.

Glad to have helped
D+C
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 09, 2018, 07:30:52 AM
Dazed+Confused,
Just a question, what Diameter do you set, the Stock to be cut or the Maximum Diameter of the Model.
If it is the Maximum Diameter of the Model then the only way to ascertain that correctly would be wih the CAM Model, as in my Z Axis (being the Radius) is not the Tip of the Tool but higher by the Radius of the Tool Tip.
Also with 4 Axis Simultaneous the Z Axis would move off center.
Does this ToolPath Regen to display the Correct shape of the Model affect the G-Code being sent to the Controller?
Regards.Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 09, 2018, 04:24:28 PM
Dazed+Confused,
I am still having issues although the shape is getting closer to what it should be on Finishing Cuts on the Venus Statue, I still have not got it right.
On Roughing where multiple cuts are made, it appear to have a lot more issues.
I was just testing a simple cylinder with a roughing cut, the last cut was OK the cut circles joined, but the outer cut they did not, they left a gap.
If you can get it working can you send me a working example G-Code with the Dia you have set so I can see where I am going wrong?
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: dude1 on April 09, 2018, 04:40:27 PM
it's the radius of the stock if its a 100 mm you would put in 50, its doing a radius correction so you have to make sure its dead center otherwise it will go wrong
Title: Re: Question on 4 Axis Toolpath?
Post by: Dazed+Confused on April 10, 2018, 03:35:04 PM
Here is some information/files that might be useful. It is how i have my stock coord set up in RhinoCAM. If your toolpath does not show up properly it is most likely a post issue from your CAM package?

Toolpath in 4th axis mode does not modify gCode at all.

link to video from a test i made using a venus head...
https://youtu.be/0pTqF7th5IQ

D+C
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 10, 2018, 05:01:25 PM
Dazed+Confused,
Thank you for your reply.
All looks good with your demonstration and pictures.
On the Video you show A Rot On as 100, which is your Stock dimension just what I wanted to know.
I use mm on our Machines.
You example works also with my Mach4 using your code so that is OK.
I also use Rhino with madCAM 5Extra so I can also make any type of cut on the Model.
So I would like to duplicate your example as a test with Mach4 with 4 Axis and 4 Axis Simulateneous, to do this I need to know the dimesions of your Venus Model.
In the meantime I will try some mre tests using my models.
I have produced this Model many years ago in brass and wood with Mach3 so I do not have any issues with my CAD/CAM software.
It is good to hear that the G-Code is not affected.
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: Dazed+Confused on April 10, 2018, 05:53:29 PM
Ahh!.. i knew i had forgotten to put something else in the zip. Here is the actual head i used for tests.
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 11, 2018, 08:05:04 AM
Dazed+Confused,
I have found the issue of Toolpath display much more complex when performing the cut along the X Axis with a continual spiral cut around around the Cylinder.
In config "A Rollover" must Not be ticked.
I have found that when "A Rot On" is clicked, then you enter "0" to show the correct display.
However the cut does not cut going across and along the X Axis it continues to rotate in the same spot but the cut display then move over after each revolution.
Below is a G-Code Continuos Rotary cut of a Cylinder on Center.
So I do not know how the "A Rot On" works when you enter "0" but it does and entering "0" keeps the Circle Cylinder in the Center.

On more complex displays performing the same cut, for example Venus 100mm Dia stock, If enter on "A Rot On" "0" then it is truncated in the X Axis, but it is On Center.
However making "A Rot On" "-50" Display correctly but it is Off Center.
So I do not know what is going on.
Also I have not tried 4 Axis Simultaneous Spiral cut yet, I will do the tomorrow as it is getting late here.

I wish some would fix the Mach4 Toolpath display program so we do not need to come up the complex solutions to fix this.

Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 12, 2018, 07:57:15 AM
Dazed+Confused,
I have been conducting a number of experiments with various statues to she how to accurately show them in the Toolpath.
I have found in many instances that the following works.
I have put to sleep two line in the Lua code that you provide see below.
I then entered with "A Rot On" the value "0" on all G-code statues and cylinder.
One statue-1 and cylinder  had a normal 4 Axis rotary spiral cut and the other Statue-2 a 4 Axis simultaneous rotary spiral cut.
With this setting they all displayed proportionally correctly although it difficult to say with 100% confidence as I can not take any measurements for confirm this.
Both Statues have a stock diameter of 100mm so the value entered has nothing to do with this value.
Pictures of the Mach4 Toolpath below.
Although on the Large 1521472 G-Code lines Statue-2 on redisplay of the Toolpath the following Mach4 error came up and crashed the program.
On redoing the same action many times and it did not fail the second or more times?
Having trouble sending attachments to I will send an other reply.
Regards,
Mauri.

local inst = mc.mcGetInstance();
local getVal = scr.GetProperty('droRadius', 'Value');
local getValAsNumber = tonumber(getVal);
--getValAsNumber = getValAsNumber / 2;    --convert to radius (dro is entered as diameter)
--getValAsNumber = 0 - getValAsNumber;    --make negative for Z offset
mc.mcToolPathSetAAxisPosition(inst, 0.000, 0.000, getValAsNumber);
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 12, 2018, 08:04:19 AM
Dazed+Confused,
Attachments for previous reply.
All three example with entering "0" to above display all On Center.
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: dude1 on April 12, 2018, 04:14:52 PM
That's what Mach3 does if its origin is dead center end and the toolpath is out from there ever continus, wrap or index from a 3D cad program it will show up correctly with only have 0 as the radius correction as there's nothing to correct it has already been done in CAM.
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 12, 2018, 04:50:17 PM
Dude1,
The only thing is that if you have a G-Code that cuts a long the X Axis instead of around it, then it will not display correctly with a Zero Setting.
So this type of 4 Axis G Code would require a radius compensation.
Regards,
Mauri.
Title: 4 Axis Toolpath Display Final Solution Found
Post by: Mauri on April 13, 2018, 06:30:36 PM
Hi all,
Mach4 the way it is downloaded from the website is Set for 3 Axis Toolpath display.
To make Mach4 a 4 Axis Toolpath display there are two ways:
1) Via Lua code added to the PLC Script.
local inst = mc.mcGetInstance()
mc.mcToolPathSetARotationAxis(inst, 0)
mc.mcToolPathSetAAxisPosition(inst, 0.000, 0.000, 0.000);

OR
2) By modifying the machine.ini file.
[ARotoryAxisPosition]
RotationAbout = 0   <-- In the 3 Axis Toolpath display it is setup as = -1
XAxis = 0.0
YAxis = 0.0
ZAxis = 0.0

This will then display all your 4 axis correctly.
So it has been there for the last 3 years but no one was aware about it.
Regards,
Mauri.
Title: 4 Axis Toolpath Display Final Solution Found More Information
Post by: Mauri on April 13, 2018, 06:36:49 PM
Hi all,
For those that want to perform other 4/5 Axis movements here are some notes from Steve.

RotationAbout: It is designed so that A can rotate around Y or Z too.  it would normally be B and C that does this.  However, the tool path only has a notion an A axis rotary at the moment.  But if the RotationAbout is set to 1 (Y axis), you would still use A (instead of B) in the G code.  This is so people with CAM programs that can only output rotary on the A axis can actually rotate around the Y or Z axes if they need to do that.  The default is -1 which means no 4th axis.  It is turned off by default because running the U axis (linear A) would distort. 

XAxis, YAxis, ZAxis: The offset of the rotation.  They are normally 0 and default to 0.  But they can be changed to add the offset of a when the center of rotation is not part 0.

So we can finally put this one to bed.

Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: dude1 on April 13, 2018, 10:25:38 PM
That was to easy
Title: Re: Question on 4 Axis Toolpath?
Post by: Dazed+Confused on April 17, 2018, 11:21:49 AM
Quote
So it has been there for the last 3 years but no one was aware about it
I was :) . I found what i needed in the 'Mach4CoreAPI.chm' in the Docs dir at least 2 years ago.

Anyway things are getting there, this has been added in the latest developer version 4.2.0.3741


Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on April 17, 2018, 03:57:07 PM
 Dazed+Confused,
Finally 4 Axis Toolpath Display has been added to Mach4.
Great news for all.
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: Olovsson on July 15, 2018, 03:43:21 AM
I don’t get this one to work correctly. Using Mach4 3804. I’m only able to get the 4th axis tool path to show correctly if all axis are homed and I zero them in the home position. Tried this with soft limits on and off. If I move to my work piece zero, zero the axis there and then press Regen Toolpath, the tool path window shows only rubbish.

I milled the same file yesterday, so I know it’s working in the machine, will not pass any limits so the problem is not there. Been scratching my head the whole morning. Anybody else that has the same problem. Well you can always select not to generate the toolpath, but then you don’t see where you have milled anyhow.

Noticed that when you press stop, suddenly, the tool path shows correctly.

Pictures attached:
The first one shows how it looks like during milling, when you have succeeded to generate the tool path in the machine zero.

The second one shows when you have pressed stop.

The third one shows when you press Regen tool path in the new work zero.

Well, I’m confused  :), anybody that has this one working and can advice about a solution?

Kjell 
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on July 15, 2018, 08:24:41 PM
Kjell,
Yes, you are correct that is what you get if you regen and not have all Zeros in the DRO displays the outcome can bear little resembalance to the correct profile when these are changed.
Even if say Mach4 as started say had Z=25 and then you loaded the G-Code it would then display an incorrect toolpath.
As I have no idea as to how the program is written to perform this task in the toolpath display of the 4 Axis, it is hard to see if a solution exists.
Brain and Steve are the only two at ArtSoft that may eventual be able to solve this for us all.
The minimum that should at least be fixed is if you change the Z height on the DRO in line with the cutter on the Job (top dead center).
In most other cases X/Y/A start at Zero.
I was at least happy that it could display and run in Mach4.
These things normally get addressed when there enough users asking for a fix or that it fails to perform the correct cut.
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: Olovsson on July 16, 2018, 02:31:50 AM
Mauri,

Good then I’m not the one screwing up at least
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 12, 2020, 06:54:04 PM
I had posted some time ago about this problem and I was using the example of a chess pawn. I continue to have the problem and very sporadically I can get the object I am working with to come up in the tool path window as desire but is very seldom and I have not been able to repeat it. What I get is a tool path with everything stacked up in a line with not evidence of any y movement, so it basically looks like a disk. The other view I can create is kind of like a single half outline of the object in the y axis. The very few times I have been able to get the a axis to show up correctly I record all current configuration settings and steps on what I did but am not able to recreate after I restart mach4. I came across the making sure all axis are zeroed before starting but there must be other things that are also causing issues, so at this point I can't say for 100% that the zeroing axis is even an issue even tho I always start that way.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 13, 2020, 09:03:09 PM
I have attached a picture of what I get when I select "Rotate around Y axis" and "A Rollover" is checked. I am running mach4 version: 4.2.0.4300. The object should be a chess rook and as you can see it appears to be two of them side by side with the area between them filled in with the tool path. I also get the same type of picture with the chess pawn I tested out. I believe I have only twice been able to get it to generate correctly or as one would hope to see the toolpath generate, once with the pawn and once with the rook but only once each and only after a lot of just making changes and regenerating the tool path. However, when I started over and went through the exact same steps, to the best of my knowledge, the closest I can get back to what one would want to see for a tool path is what you see in the picture. When I first purchased mach 4, I inserted the code and added the dro suggested earlier in this post thread as can be seen below the axis dros', in the attached picture, which worked at one point but it does not work now on this newer version of mach 4. Anyway if anyone has any solutions from what you see here I would appreciate your suggestions. Also, I home and zero all of the axis first on startup, go to the tooth path tab under the configure menu and set the A rotation around Y as it seems to always default to "no rotation"
Title: Re: Question on 4 Axis Toolpath?
Post by: Mauri on January 13, 2020, 10:01:55 PM
SMAV,
The only way it will display correctly on the Toolpath is if the Top of your chess piece is Z=0 and Z=0 in the Mach4 setting.
If Z is set to anything else it will NOT display correctly in the Toolpath, however it will cut correctly.
This makes it very difficult when cutting anything but a previse round shape to the accuracy you want to cut.
For example if you are cutting it out on say a 25mm diameter steel rod that is accurate then if the G-Code has Z=0 as the top of the Rod you intend to machine then it will display correctly in the Toolpath as well as display correctly.
So when you load your G-Code it will display correctly, however as soon as you enter the correct Z height it will not display correctly.
In other words Z being ZERO at the Centre of the Part then it will NOT display correctly, but Z = 0 at the TOP of the Part then it will.
So until the fix this issue, it is best to ignore it.
Regards,
Mauri.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 14, 2020, 01:42:00 AM
I figured out most of the issues I am having. The script as Mauri wrote it is for a machine with the rotation along the x axis. Once I realized that I could get the tool path to display correctly as long as I set the DRO value correctly. However if I change the 0 value to 1 for the button down function in the " mc.mcToolPathSetARotationAxis(inst, 0)" It will and does give me the picture I posted above and changing the DRO value does not correct it. I took the same gcode for the piece above and changed all the Y coordinates to X and it did display correctly. I also changed the setting for the rotation in the toolpaths tab as well to say "Rotation along Y axis." So it appears the orientation is correct but the value I am entering in to the dro is not correcting it like it does when I use it in the X axis.....Any suggestions on that?...Thanks
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 14, 2020, 01:20:36 PM
Thanks Mauri for the clarification on that. That was one of the things I figured out last night after I realized I could get the chess pieces to show up correctly in the X axis. I also noted that DRO value that you enter corrects for the z position. What I was attempting to accomplish last night was to be able to swap the rotation to the Y axis, which I thought I could accomplish by changing the zero to a one in the script for the "A rotation" button down script and it would orientate the piece on the screen correctly but the when you enter a value for the dro it moves the z axis but does not regenerate the toolpath like it does when it is set for the X axis.

April of 2018 Dazed+Confused listed the script that was need to correct for the z axis so the radius could be adjusted or corrected to show the toolpath. He wrote "mc.mcToolPathSetAAxisPosition(inst, 0.000, 0.000, getValAsNumber);" for the "dro Radius" which would be the x, y value to be 0 and the z is whatever you input in to the dro. That is what I believe makes the correction so that whatever the work piece Z zero position is, it can be corrected for the toolpath generating. When I wrote that line of the script for the DRO as you stated " mc.mcToolPathSetAAxisPosition(inst, 0.000, 0.000, 0.000);" and tested it I found as you stated the g-code has to have the top of the work piece as zero.
I am going to attempt to work on getting it to swap to the Y axis again tonight and be able to have it correct it with the dro radius  value but if you have any ideas I would appreciate it. Using the code Dazed+Confused published back in 2018 works for the X axis as stated but simply changing the axis value in the line “mc.mcToolPathSetARotationAxis(inst, 0)” from 0 to 1 doesn't seem to work as itended.
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 15, 2020, 12:28:59 PM
The script that Dazed+Confuse shared in this thread back in 2018 works for objects orientated on the X axis, does anyone know how to get it to orientate and work on the Y axis?
Title: Re: Question on 4 Axis Toolpath?
Post by: smav on January 27, 2020, 12:43:42 PM
If anyone is able to get a rotary toolpath to show up orientated along the y axis, it would be appreciated if you share it here......thanks