Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: rustyolddog on December 27, 2007, 10:44:13 PM

Title: Everything I learned about setting up a 4th axis, problem solved, ** final cut
Post by: rustyolddog on December 27, 2007, 10:44:13 PM
ETA: See the post on page 2 which is the final draft of the exercise.





I've spent a good bit of time perfecting my 4th  axis and I thought I'd share what I learned with others here. The problem/question is at the end.

Under normal circumstances, the 4th  or 'A' axis is angular and the moves are called out in degrees. If you have a CAD/CAM software that supports a 4th  axis, you are in good shape. If all you have is a 2.5D CAD/CAM, then things can be a bit more challenging.

First, lets address the 4th  axis mechanics. My and most other 4th  axis 'conversions' involve adding a stepper motor to a rotary table. Simple enough. In my case my rotary table was a 1:72 ratio. 72 turns of the worm results in one 360 degree rotation of the table.

My stepper motor is a 200 step per revolution (1.8 deg) per step (360 deg/200 steps=1.8deg/step) My controller runs 1/8 microstep mode so it takes 1600 step pulses (8*200) to make a complete 360 degree motor rotation.

72 motor rotations makes one rotation of the rotary table so 1600*72 means 115,200 steps for one rotation of the rotary table.

If we divide 360 degrees by 115200, we get .003125 degrees per step.

Alternately, we can calculate the number of degrees required to move a linear distance around the circumference of a part.

For example: We have a part that is 1.5” in diameter. 1.5* Pi (3.1415) gives us a circumference of 4.7123” If we divide 4.7123 by 360 we get .01309 inches of  linear movement per degree.

If we want to move a linear distance of 1.125” on our 1.5” diameter (4.7123" cir) part, we divide 1.125” by .01309 in/deg and get 85.94 degrees of movement required to move 1.125” linear on the 1.5” diameter part.

Thus, we can create a correction factor or scaling factor for our 4th axis by dividing the circumference of the part by 360, and manually coding the linear distance for the ‘A’ axis move.

Alternately, if your CAD/CAM software has a scaling feature, you can create a scaling correction factor. You would create your part in standard 2.5D with X & Y moves with Y typically being the axis to be converted to ‘A’.  You take the circumference and divide it by 360 then take the inverse of that value (1/x) and that becomes your scaling correction factor.

Using the previous example: 1.5”* 3.1415= 4.7123”
4.7123”/360=.01309
1 divided by 0.01309=76.397 scaling correction factor
 
Therefore, you would scale your ‘Y’ axis by a factor of 76.397 to get the equivalent linear move on the ‘A’ axis. Once you post the scaled code, you would do a simple search & replace substituting ‘A’ for ‘Y’ in your text editor. The end result  X, Y, backplot & drawing will look strange because the Y axis will be substantially elongated. But it will be correct as far as the computer is concerend.

While it does work, this later method has an inherent problem. The feed rate will be significantly slower than the desired or specified feed rate.

As a result, I had to search for a better method. Thus part 2.

Using the same math:
72:1 ratio, 1600 steps per rev of the motor, 115200 steps for 360 rotary table movement .

In Mach2 (my version), we can take the total number of steps for 360 deg. Table rotation and divide it by the circumference to determine the number of steps per inch of movement. Again using the previous example:

1.5” diameter*3.1415=4.7123”
115200/4.7123=24447 steps per inch of linear movement.

In Mach, we change our A axis from angular to linear. Then calculating for the diameter of the part, we take the solution and use it in the ‘Steps per Unit’ setting for the ‘A’ axis in the motor tuning menu. We do this for each different diameter of part that we have machine. For a 1.5” diameter, we enter 24447 for our steps per unit.

Thus, by doing so we do NOT have to scale our ‘Y’ axis by a calculated scaling correction factor. Our backplot & drawing appears normally. We still have to do a search & replace substituting the A for the Y axis in our posted code. And the beauty of it is the specified feed functions correctly. 

While the technique works perfectly for X,Y moves, IJ interpolation causes things to go bonkers. If anyone has any mathematical reasons why that may be, I’d sure like to hear them along with any suggested solutions.   

Hope this little math exercise is of some help to others.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: docltf on December 28, 2007, 02:06:46 AM
I and J work around a fixed point.
when you rotate your A axis you make the point move.not to good unless your setup and software are pretty much perfect.
if you can do it,explain the piece you are trying to cut and the material you want to use.
also in your post,your A axis has a pretty good resolution,do you need that much.that will cut into your speed pretty good.
try setting your driver to full step.that will give you 40 steps per degree or 10 steps for 1/4 degree.good for general machining
if you are going to finish out the piece by grinding,then the high resolution helps.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: rustyolddog on December 28, 2007, 07:23:17 AM
I and J work around a fixed point.
when you rotate your A axis you make the point move.not to good unless your setup and software are pretty much perfect.
if you can do it,explain the piece you are trying to cut and the material you want to use.
also in your post,your A axis has a pretty good resolution,do you need that much.that will cut into your speed pretty good.
try setting your driver to full step.that will give you 40 steps per degree or 10 steps for 1/4 degree.good for general machining
if you are going to finish out the piece by grinding,then the high resolution helps.

My application is small jewelry wax engraving so the level of resolution is required. Geometric moves & text engraving function just fine, the curves in the text engraving are made up of small straight segments. Where things get messy is with spline and true curved geometry. The IJ moves for some reason don't translate properly when going from Y to A in a simple substitution. I don't know if that's a Mach setting or a interpretation problem. My initial thinking was that since the A axis had been made linear, the IJ moves should translate. Last time I tried, I got wild arc moves. In addition, somthing got corrupted in the Mach settings file. I plan on trying again when I get a chance but only after I make a backup.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: jimpinder on December 28, 2007, 08:28:45 AM
If I am getting the point of the post - what we are saying is this complicated way of converting angular motion into linear motion seems to work alright if we stick to simple straight line formula. Once we ask the computer to move the axis in a circular motion then it goes bananas.

If you think about g2 or g3 moves, these ask the computer to guide the axis around a plane in a circle. Since the plane is flat, then the distance from the centre of the circle can be easily calculated, and the vectors of the points on the circumference of the circle (two co-ordinates) can be calculated as the tool advances. As we probably know, one axis advances as per a sine wave, the other in a 90 opposition.

What you are trying to do is the equivelant of drawing a circle on the side of a sphere. You cannot represent the centres of a flat circle and a circle of the same diameter on a sphere by the same point. If you imagine drawing a circle the same size as the sphere, then a flat representation would show the diameter as D, whereas the true diameter of the circle you actually wanted to draw is pi D/2. The same is true if you imagine drawing a circle on the side of a cylinder, but only on one axis.

Your method may work - but it is not based on the actual mathmatics involved. Whilst angular mathematics is complicated it is easier working in degrees or radians where appropriate - particularly if you are going to mix flat planes (essentially two co-ordinates) with spherical or spacial measurements (essentially three co-ordinates).
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: rustyolddog on December 28, 2007, 10:00:20 AM
If I am getting the point of the post - what we are saying is this complicated way of converting angular motion into linear motion seems to work alright if we stick to simple straight line formula. Once we ask the computer to move the axis in a circular motion then it goes bananas.

If you think about g2 or g3 moves, these ask the computer to guide the axis around a plane in a circle. Since the plane is flat, then the distance from the centre of the circle can be easily calculated, and the vectors of the points on the circumference of the circle (two co-ordinates) can be calculated as the tool advances. As we probably know, one axis advances as per a sine wave, the other in a 90 opposition.

What you are trying to do is the equivelant of drawing a circle on the side of a sphere. You cannot represent the centres of a flat circle and a circle of the same diameter on a sphere by the same point. If you imagine drawing a circle the same size as the sphere, then a flat representation would show the diameter as D, whereas the true diameter of the circle you actually wanted to draw is pi D/2. The same is true if you imagine drawing a circle on the side of a cylinder, but only on one axis.

Your method may work - but it is not based on the actual mathmatics involved. Whilst angular mathematics is complicated it is easier working in degrees or radians where appropriate - particularly if you are going to mix flat planes (essentially two co-ordinates) with spherical or spacial measurements (essentially three co-ordinates).

No, we're not getting past the point of the post. It was intended to be a real world discussion of a back door method to accomplish 4th axis moves  in a 2.5D world. Kinda like using an X,Y drawing to accomplish X, Z moves on a lathe in absence of a dedicated lathe CAD/CAM.

Drawing a circle on a sphere is far more complex than the problem in hand in that a Z axis move would be required while making the X and A axis moves. In my application the Z axis is simply in the cut or out at a fixed depth. What I am trying to accomplish is a circle on a cylinder.

The X axis move, coordinated with the A axis move, of which the A axis has been tricked into being a linear axis. Mechanically, it's a non issue as the machine is capable of it. I can machine 'O's and '0' without a problem but in the CAD/CAM software, these are created by short linear line segments, with the end appearance being a smooth circle. Splines on the other hand are true curves. I have no problem under normal circumstances on a flat surface with X & Y moves. But for some reason, at least in the past tests, substituting A for Y in the G-Code, in which A has been configured as a linear axis, causes unexpected moves with the IJ command.

I've recovered the setup file since I had the problem, it had gotten corrupted I presumed as a result of trying to run the IJ commands. Everything had been functioning properly prior to that both in X, Y mode and X, A mode with linear moves. I haven't retested since then. What I am trying to determine is whether there is something mathematically & G-Code wise that I am overlooking or not seeing or if it was just a glitch in Mach or related to the Absolute or Incremental setting, or if I need to disable or change a setting for the A axis in Mach.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: rustyolddog on December 28, 2007, 10:11:37 AM
if you can do it,explain the piece you are trying to cut and the material you want to use.
also in your post,your

To clarify, this process is a straight wall pocketing operation, just like you would cut a cam slot it's not a complex 3D art relief. Z remains at a fixed depth.
The setup is as follows: The cylindrical part is mounted on the 4th axis, the cylinder center line is located in the Y plane, Y is zeroed and left undisturbed from that point. The X & Z zero point of reference is located and the operation commences.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: docltf on December 28, 2007, 12:50:23 PM
i think what you are doing is simular to a part that i cut for some of my cues.we need the straight wall to make the part work.
your pieces are more elaborite than mine but you still need the straight wall.i cut a six point splice joint that has to be glueable.
i dont have any pictures right now of unasembled parts, try to cut some this weekend to show you.the g-code for these are hand written.
not to much luck trying to do it with a cad.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: jimpinder on December 28, 2007, 01:57:41 PM
Ive got the picture now - rather like writing (only in this instance cutting) the Heinz logo on a can of beans. The A axis rotates the can backwards and forwards and the other axis goes up and down. The other axis - holding the brush - is fixed.

I must admit, then, in that case, if you have correctly set your pulses per distance, I cannot see why it cannot perform G2 and G3 as well. The only thing I can see is if the A axis still knows it is a rotating axis and not linear. In that instance, it could perform linear movement but still not reference itself to the centre of a circle.

A silly thing - looking at General Config - have you ticked A axis as angular. I know it is, but we are making believe it isn't, therefore the machine must think it isn't. I dont think it would make any difference to G0 and G1 moves, but an angular axis cannot make G2 and G3 moves because it cannot reference a centre with another axis.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem
Post by: rustyolddog on December 28, 2007, 09:23:13 PM
I ran the test again tonite and I definately think it's a Mach2 problem.

The A axis Angular is unticked.

I tried both Absolute and Incremental IJ

I also unticked/ticked the No Angular Discrimination box.

In absolute mode, I get a series of circles on the tool path display, in Incremental, I get a fewer number of circles.

Keep in mind all I did was take my posted code and subtitute A for Y and here's what happens:

The test code contains bot X moves, A moves and A moves with IJ commands.

The X moves are correct, the A moves are correct

When an A move with an IJ command runs, I get movement in the Y axis even though there is no Y command anywhere, in addition, I get wild feeds in the A axis which vary from extremely slow to motor stalling fast even though the motor is tuned way below the stall limit.

I can't understand why the Y axis would move when there is no Y axis move specified UNLESS IJ commands can only be associated with a X,Y axis move. And associating IJ with the A axis results in an illegal instruction. This has to be an issue with Mach2 code, no? I think I can work around it by simply swapping my A axis cable with the Y axis cable, changing the Units setting, motor tuning and backlash setting for the 4th axis and just run the code as X,Y. This would be a real pain to do on a regular basis and leaves the door open to mistakes. I'll see if I can get Art to weigh in.
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: ART on December 28, 2007, 10:25:25 PM
Hi:

 You have it right. You cannot do arcs other than in the XY plane, XZ plane or YZ plane. There is no conceptual plane for
a rotary axis. The checkbox for linear/angualr only tells an axis not to convert when switching from mm to inch, other than that it
has no purpose. A, B and C are always rotary axis.. So using an IJ with an A axis is an error in syntax, though still legal, the missing Y in this
case woudl simply be interpreted as the current Y location, and the A would just be a linearised motion on that axis during the movement of the XY
in the XY plane arc.

Art
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: docltf on December 28, 2007, 10:28:53 PM
rustyolddog

the I parameter is associated with the X axis and the J parameter is associated with the Y axis.they are not associated with A B or C  axis even if you check the box use as linear.
now you can move them around on differant planes XY  XZ  YZ but not with ABC.

you can take a linear program and wrap it around a cylinder without super software by creating a new setup profile.
when you log onto mach do the create a new profile.
go to ports and pins and move your A axis setup to Y. then move your Y axis to A.
set your A axis to linear so you can jog it around.
set your Y axis steps to get what you want.
now you can carve around a cylinder without having a code with A in it.

bill
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: rustyolddog on December 28, 2007, 10:47:29 PM
rustyolddog

the I parameter is associated with the X axis and the J parameter is associated with the Y axis.they are not associated with A B or C axis even if you check the box use as linear.
now you can move them around on differant planes XY XZ YZ but not with ABC.

you can take a linear program and wrap it around a cylinder without super software by creating a new setup profile.
when you log onto mach do the create a new profile.
go to ports and pins and move your A axis setup to Y. then move your Y axis to A.
set your A axis to linear so you can jog it around.
set your Y axis steps to get what you want.
now you can carve around a cylinder without having a code with A in it.

bill

Doh!!! Thanks Bill for pointing that out, it's so obvious & simple! Why didn't I think of it?!
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: rustyolddog on December 28, 2007, 10:48:52 PM
Hi:

 You have it right. You cannot do arcs other than in the XY plane, XZ plane or YZ plane. There is no conceptual plane for
a rotary axis. The checkbox for linear/angualr only tells an axis not to convert when switching from mm to inch, other than that it
has no purpose. A, B and C are always rotary axis.. So using an IJ with an A axis is an error in syntax, though still legal, the missing Y in this
case woudl simply be interpreted as the current Y location, and the A would just be a linearised motion on that axis during the movement of the XY
in the XY plane arc.

Art


Thanks for clearing that up Art!
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: rustyolddog on December 29, 2007, 02:45:53 PM
Hey Bill, thanks again for the tip. I created a new configuration, changed the port setting, motor tuning & backlash settings and it works absolutely great!.

In a nutshell for others who might be trying to accomplish the same thing:

I configured the output ports so that the controller output for the 4th axis stepper was on the Y axis port.

I changed the motor tuning on the Y axis to match my 4th axis, changed the Units per my previous post.

I configured the output ports so that the controller output for the Y axis stepper was on the A axis port.

I changed the motor tuning on the A axis to match my Y axis, changed the Units to match the Y axis setting used in the conventional mill mode.

Unticked the A axis Angular setting

Changed the Hotkeys so that they worked as in Conventional mill mode U/D arrow keys controlled the remapped A axis (Y axis), and my Home/End keys control the Y (A rotary axis) this prevents any jogging crashes when going from Conventional and Rotary Mach configurations.

Changed the Motor Reversals as required for the proper direction.

Created a new Profile & Shortcut Key for Rotary Configuration.

Now, no matter what I do in my CAD/CAM software the posted code needs no changes, I can perform the operations in either the Flat 2.5D environment or the rotary environment by simply selecting the Appropriate start up  Icon. All my posted code remains the same. The only other setting I have to change is the Units setting & backlash  for the diameter of the part I am working with.  

 ;D :D ;D :D ;D Pure Mach Nirvana!!!!!!! :D ;D :D ;D :D
Title: Re: Everything I learned about setting up a 4th axis & a question/problem **Updated*
Post by: rustyolddog on December 29, 2007, 08:16:36 PM
Here's and edited and corrected version in case someone wants to print for their notes:



I've spent a good bit of time perfecting my 4th axis and I thought I'd share what I learned with others here.

Under normal circumstances, the 4th or 'A' axis is angular and the moves are called out in degrees. If you have a CAD/CAM software that supports a 4th axis, you are in good shape. If all you have is a 2.5D CAD/CAM, then things can be a bit more challenging.

First, lets address the 4th axis mechanics. My and most other 4th axis 'conversions' involve adding a stepper motor to a rotary table. Simple enough. In my case my rotary table was a 1:72 ratio. 72 turns of the worm results in one 360 degree rotation of the table.

My stepper motor is a 200 step per revolution (1.8 deg) per step (360 deg/200 steps=1.8deg/step) My controller runs 1/8 micro step mode so it takes 1600 step pulses (8*200) to make a complete 360 degree motor rotation.

72 motor rotations makes one rotation of the rotary table so 1600*72 means 115,200 steps for one rotation of the rotary table.

If we divide 360 degrees by 115200, we get .003125 degrees per step.

Alternately, we can calculate the number of degrees required to move a linear distance around the circumference of a part.

For example: We have a part that is 1.5” in diameter. 1.5* Pi (3.1415) gives us a circumference of 4.7123” If we divide 4.7123 by 360 we get .01309 inches of  linear movement per degree.

If we want to move a linear distance of 1.125” on our 1.5” diameter (4.7123" cir) part, we divide 1.125” by .01309 in/deg and get 85.94 degrees of movement required to move 1.125” linear on the 1.5” diameter part.

Thus, we can create a correction factor or scaling factor for our 4th axis by dividing the circumference of the part by 360, and manually coding the linear distance for the ‘A’ axis move.

Alternately, if your CAD/CAM software has a scaling feature, you can create a scaling correction factor. You would create your part in standard 2.5D with X & Y moves with Y typically being the axis to be converted to ‘A’.  You take the circumference and divide it by 360 then take the inverse of that value (1/x) and that becomes your scaling correction factor.

Using the previous example: 1.5”* 3.1415= 4.7123”
4.7123”/360=.01309
1 divided by 0.01309=76.397 scaling correction factor

Therefore, you would scale your ‘Y’ axis by a factor of 76.397 to get the equivalent linear move on the ‘A’ axis. Once you post the scaled code, you would do a simple search & replace substituting ‘A’ for ‘Y’ in your text editor. The end result  X, Y, back plot & drawing will look strange because the Y axis will be substantially elongated. But it will be correct as far as the computer is concerned.

While it does work, this later method has an inherent problem. The feed rate will be significantly slower than the desired or specified feed rate. And IJ Moves will not work as they are functions of the X & Y axis, they are not recognized in an A move.

As a result, I had to search for a better method. Thus part 2.

Using the same math:
72:1 ratio, 1600 steps per rev of the motor, 115200 steps for 360 rotary table movement .

In Mach2 (my version), we can take the total number of steps for 360 deg. Table rotation and divide it by the circumference to determine the number of steps per inch of movement. Again using the previous example:

1.5” diameter*3.1415=4.7123”
115200/4.7123=24447 steps per inch of linear movement.

Calculating for the diameter of the part, we take the solution and use it in the ‘Steps per Unit’ setting for the Rotary axis in the motor tuning menu. We do this for each different diameter of part that we have machine. For a 1.5” diameter, we enter 24447 for our steps per unit.

Thus, by doing so we do NOT have to scale our ‘Y’ axis by a calculated scaling correction factor. Our back plot & drawing appears normally. The beauty of it is the specified feed functions correctly. 

Now, in order for the IJ moves to work correctly on our rotary axis, we have to substitute the Rotary axis for the Y axis (or X if you desire), then remap the Y axis to the A axis. It’s a lot simpler than it sounds.

First I created a new profile called rotary and cloned the Mach2mill profile. This retains all your setting currently in use.

I configured the output ports so that the controller output for the 4th axis stepper was on the Y axis port. Just swap the output pin numbers in the port menu between Y and A.

I swapped the motor tuning data between the Y axis & 4th axis, changed the steps per units as noted above for the diameter I’m working with.

Unticked the A axis Angular setting

Changed the Hotkeys so that they worked as in Conventional mill mode U/D arrow keys controlled the remapped A axis (now the Y axis), and my Home/End keys that control the Y (now A rotary axis) This prevents any jogging crashes when going from Conventional and Rotary Mach configurations since the jog keys will move the same axis regardless of the configuration (Mill or Rotary) selected.

Changed the Motor Reversals as required for the proper directions.

Created a new Shortcut Key for the Rotary profile Configuration, I used the lathe icon to prevent a mistake.

Now, no matter what I do in my CAD/CAM software the posted code needs no changes, I can perform the operations in either the Flat 2.5D environment or the rotary environment by simply selecting the appropriate start up icon. All my posted code remains the same. The tool path display functions normally. The rotary mode tool path looks just like a 2.5D tool path. 

The only setting I have to change for a job is the Steps per Unit setting per the math/diameter discussion & the backlash setting for the diameter of the part I am working with. 

Hope this little exercise is of some help to others.
Title: Re: Everything I learned about setting up a 4th axis, problem solved, ** final cut
Post by: Chaoticone on December 29, 2007, 09:50:08 PM
Thanks for shareing that with us Rustyolddog, that is very nice. I have't got to read it all but will next week. The gifts that members give such as this and the curtosy they share is the main reason this forum is so great.

 :) Thanks,
Brett
Title: Re: Everything I learned about setting up a 4th axis, problem solved, ** final cut
Post by: Bodini on February 10, 2008, 11:56:04 AM
d00d,

it pained me to see you do all that math and motor tuning and what not.  so i threw up a thing on a screenset to do all that.  forgive me for any crudeness to it, it was a 10 minute task, and I used the screen that use most too.

anywho, if you load the screenset attached, you will see some dros on the program run screen:

Diameter: [put your desired dia here, you had "1.5"] (dro 1500)
Rot Step: [put your rotary steps here, you had "115200"] (dro 1501)
Y2A: [this is calulated to what you called "steps per inch of linear movment"] (dro 1502)
Calculate button (script on button for portability sake)

So enter your dia, the rotary steps, and press Calc.

this calcs the steps per inch of linear movement as shown in the Y2A dro.  now go to your motor tuning and see that by pressing the Calc, it also SET the motor tuning of the Y counts to that value.

So there you have it, no more calcumalation or motor tuning BS.

-nick
Title: Re: Everything I learned about setting up a 4th axis, problem solved, ** final cut
Post by: rustyolddog on February 15, 2008, 10:18:50 PM
d00d,

it pained me to see you do all that math and motor tuning and what not. so i threw up a thing on a screenset to do all that. forgive me for any crudeness to it, it was a 10 minute task, and I used the screen that use most too.

anywho, if you load the screenset attached, you will see some dros on the program run screen:

Diameter: [put your desired dia here, you had "1.5"] (dro 1500)
Rot Step: [put your rotary steps here, you had "115200"] (dro 1501)
Y2A: [this is calulated to what you called "steps per inch of linear movment"] (dro 1502)
Calculate button (script on button for portability sake)

So enter your dia, the rotary steps, and press Calc.

this calcs the steps per inch of linear movement as shown in the Y2A dro. now go to your motor tuning and see that by pressing the Calc, it also SET the motor tuning of the Y counts to that value.

So there you have it, no more calcumalation or motor tuning BS.

-nick

Thanks Nick, I'll give it a try. Just got a new machine to run Mach 3.