### Post by Roger on Aug 18, 2022 21:15:42 GMT

I'm in the process of machining a slot on the outside surface of a cylinder of a commercial job and wanted to use my Alibre CAM software. I could have used Fusion360 which has 4 axis CAM outputs, but I don't have a commercial license for that.

The slot profile was provided as a 2D pattern which was wrapped around the circumference.

The following is the first portion of the G-Code which outputs the arcs as short linear segments as if this was a flat pattern, not wrapped around the cylinder. Most post-processors output using arc commands, but that's not going to work for what I'm doing.

In this raw output format, you can see that there are both X and Y commands, but I want to use X and A commands. The Y values represent the linear distance around the cylinder, but I need those as angles in degrees. Therefore there's a scale factor which is the circumference of the cylinder/360 degrees. In other words, if the Y value was for the whole circumference, the scale factor multiplied by the circumference would give 360 degrees.

Obviously I could have modified a copy of the Post Processor to do this, but I wanted a solution that didn't require changing between post processor.

(Rough Profile)

(Tool Dia. 4.0 Corner radius 2.0)

T1

S1000M03

G01 X8.495 Y-9.914 Z2.000 F1000.0

G01 X8.495 Y-9.914 Z0.600 F300.0

G01 X8.864 Y-10.283 Z0.573 F30.0

G01 X8.927 Y-10.346 Z0.568

G01 X8.989 Y-10.411 Z0.563

G01 X9.051 Y-10.475 Z0.559

KMotionCNC has a number of really powerful features that may or may not be part of the G-Code definition. In particular, you can declare and assign a value to a numbered parameter, in this case the parameter is #1000 and it's being assigned the value of 1.

Each Y value has been substituted with A[#1000* followed by the Y value and a closing ] bracket.

What this is doing is multiplying the Y value by the scale factor in real time while the control is processing each line. I don't know if this would work in Mach4, it might be peculiar to KMotionCNC.

Now, it's not that convenient to do these changes by text substitution, but it's feasible using Ctrl-H and swapping Y for A[#1000* However, you would still have to add the closing ] by replacing ' Z' with '] Z'

Anyway, I decided to add another button to my CNC Utility program to do all of this automatically, which is what you see below. All that's needed to finish the job is to change the scale factor which is used by the whole program.

(Y scaled to A done)

#1000 = 1 (Scale factor Y to A) <--- this will be overwritten by a sensible scale factor for the required diameter

(Rough Profile)

(Tool Dia. 4.0 Corner radius 2.0)

T1

S1000M03

G01 X8.495 A[#1000*-9.914] Z2.000 F1000.0

G01 X8.495 A[#1000*-9.914] Z0.600 F300.0

G01 X8.864 A[#1000*-10.283] Z0.573 F30.0

G01 X8.927 A[#1000*-10.346] Z0.568

G01 X8.989 A[#1000*-10.411] Z0.563

G01 X9.051 A[#1000*-10.475] Z0.559

The result of this is that the Angular positions of the 4th axis scale to the correct values such that they simulate the profile of the flat pattern around the cylinder. Because the radii are made from short lines instead of arcs, each line can have the X unchanged while the Y is scaled.

It looks like this is going to work.

The slot profile was provided as a 2D pattern which was wrapped around the circumference.

The following is the first portion of the G-Code which outputs the arcs as short linear segments as if this was a flat pattern, not wrapped around the cylinder. Most post-processors output using arc commands, but that's not going to work for what I'm doing.

In this raw output format, you can see that there are both X and Y commands, but I want to use X and A commands. The Y values represent the linear distance around the cylinder, but I need those as angles in degrees. Therefore there's a scale factor which is the circumference of the cylinder/360 degrees. In other words, if the Y value was for the whole circumference, the scale factor multiplied by the circumference would give 360 degrees.

Obviously I could have modified a copy of the Post Processor to do this, but I wanted a solution that didn't require changing between post processor.

(Rough Profile)

(Tool Dia. 4.0 Corner radius 2.0)

T1

S1000M03

G01 X8.495 Y-9.914 Z2.000 F1000.0

G01 X8.495 Y-9.914 Z0.600 F300.0

G01 X8.864 Y-10.283 Z0.573 F30.0

G01 X8.927 Y-10.346 Z0.568

G01 X8.989 Y-10.411 Z0.563

G01 X9.051 Y-10.475 Z0.559

KMotionCNC has a number of really powerful features that may or may not be part of the G-Code definition. In particular, you can declare and assign a value to a numbered parameter, in this case the parameter is #1000 and it's being assigned the value of 1.

Each Y value has been substituted with A[#1000* followed by the Y value and a closing ] bracket.

What this is doing is multiplying the Y value by the scale factor in real time while the control is processing each line. I don't know if this would work in Mach4, it might be peculiar to KMotionCNC.

Now, it's not that convenient to do these changes by text substitution, but it's feasible using Ctrl-H and swapping Y for A[#1000* However, you would still have to add the closing ] by replacing ' Z' with '] Z'

Anyway, I decided to add another button to my CNC Utility program to do all of this automatically, which is what you see below. All that's needed to finish the job is to change the scale factor which is used by the whole program.

(Y scaled to A done)

#1000 = 1 (Scale factor Y to A) <--- this will be overwritten by a sensible scale factor for the required diameter

(Rough Profile)

(Tool Dia. 4.0 Corner radius 2.0)

T1

S1000M03

G01 X8.495 A[#1000*-9.914] Z2.000 F1000.0

G01 X8.495 A[#1000*-9.914] Z0.600 F300.0

G01 X8.864 A[#1000*-10.283] Z0.573 F30.0

G01 X8.927 A[#1000*-10.346] Z0.568

G01 X8.989 A[#1000*-10.411] Z0.563

G01 X9.051 A[#1000*-10.475] Z0.559

The result of this is that the Angular positions of the 4th axis scale to the correct values such that they simulate the profile of the flat pattern around the cylinder. Because the radii are made from short lines instead of arcs, each line can have the X unchanged while the Y is scaled.

It looks like this is going to work.