New subprogram support in post processors

New subprogram support in post processors

bob.schultz
Alumni Alumni
5,205 Views
24 Replies
Message 1 of 25

New subprogram support in post processors

bob.schultz
Alumni
Alumni

A number of requests have been received to output patterned operations as a single subprogram and then to have the main program call it for each pattern instance. We have implemented new properties to the generic Fanuc post processor that will allow you to do just this. There are now three properties used for the controlling of subprogram output.

 

Subprograms.png


useSubroutines: yes
Setting this property to yes will generate a separate subprogram for each operation. This will work in the same manner as subprograms do in existing post processors.


useSubroutinePatterns: yes
This property controls the output of subprograms during patterned operations. Translated pattern operations will create a single subprogram for the first instance of the pattern and all instances of the pattern will issue a call to the same subprogram to perform the operation. All start of operation codes and the initial position will be output prior to calling the subprogram. The subprogram will be output in incremental mode so that the moves are correct for each pattern instance. 3+2 operations that generate the same motion on separate faces of a part will also be output as a single subprogram.

 

(2D-FACE)
N30 T1 M06
(TOOL COMMENT)
N35 T2
N40 S5000 M03
N45 G54
N50 M08
N60 G00 X3.6811 Y-1.3961
N65 G43 Z0.6299 H01
N70 M98 P1002
N80 G00 X3.6811 Y2.6039
N85 G43 Z0.6299 H01
N90 M98 P1002
N105 G00 X3.6811 Y6.6039
N110 G43 Z0.6299 H01
N115 M98 P1002O1002(2D-FACE)
G91
G00 Z-0.3937
G01 Z-0.2362 F39.4
X-7.3622
G02 Y0.8422 J0.4211
G01 X7.3622
G03 Y0.8421 J0.4211
G01 X-7.3622
G00 Z0.6299
G90
M99

 

useSubroutineCycles: yes
Enabling the useSubroutineCycles property will a create subprogram for cycle hole locations that are used in multiple cycle operations, for example center drilling, drilling, and tapping. All start of operation codes and the initial cycle definition, including the first hole location, will be output prior to calling the subprogram. The subprogram itself will contain the remaining hole locations in the cycle. The minimumCyclePoints variable is defined at the top of the post processor, which defines the minimum number of points in the cycle to consider for placing into a subprogram. Each cycle operation will have to contain the same number of points and the order of the hole locations must be the same in all operations.

 

(DRILL)
N30 T1 M06
N35 T3
N40 S5000 M03
N45 G54
N50 M08
N60 G00 X12.7 Y50.8
N65 G43 Z15. H01
N75 G00 Z5.
N80 G98 G81 X12.7 Y50.8 Z-3. R4. F333.
N85 M98 P1002
N90 G80
N95 X-101.6 Y-38.1 Z15.

(TAP)
N100 M09
N105 M01
N110 T3 M06
N115 T1
N120 S7519 M03
N125 G54
N130 M08
N135 G00 X12.7 Y50.8
N140 G43 Z15. H03
N245 G00 Z5.
N250 M29 S7519
N255 G84 X12.7 Y50.8 Z-28.4 R4. P0 F9549.
N260 M98 P1002
N265 G80
N270 X-101.6 Y-38.1 Z15.
…
O1002(DRILL)
X38.1 Y12.7
X76.2 Y38.1
X25.4 Y-38.1
X-25.4 Y-12.7
X-63.5 Y25.4
X-114.3 Y50.8
X-101.6 Y-38.1
M99

If you are in need of this style of subprogram support, please feel free to download the fanuc.cps post processor with the new subprogram support from the standard Autodesk Post Library. Great care should be taken when running the output from this post on your machine, as always with any new feature or post processor. Once this post has been substantially verified we will be implementing subprogram support into some of the other generic posts.



Bob Schultz
Sr. Post Processor Developer

5,206 Views
24 Replies
Replies (24)
Message 2 of 25

Laurens-3DTechDraw
Mentor
Mentor

@bob.schultz would the patterning version also work if you select order by tool?

And not the order as programmed?

 

Laurens Wijnschenk
3DTechDraw

AutoDesk CAM user & Post editor.
René for Legend.


0 Likes
Message 3 of 25

bob.schultz
Alumni
Alumni

@Laurens-3DTechDraw wrote:

@bob.schultz would the patterning version also work if you select order by tool?

And not the order as programmed?

 


The post does not care about the order of the pattern instances. It stores the first pattern and will then match each instance of the pattern no matter where it falls in the order of sequences.  In the provided example code the Operation order is actually defined as Order by tool.  Here is an example of pattern instances where they are not sequential.

 

(2D-CONTOUR WITH COMPENSATION RIGHT)
N2785 G00 X-0.2423 Y1.4283
N2790 G43 Z0.6299 H02
N2795 M98 P1004

(2D-CONTOUR WITH COMPENSATION LEFT)
N2805 G00 X-0.4786 Y5.4283
N2810 G43 Z0.6299 H02
N2815 M98 P1003

(2D-CONTOUR WITH COMPENSATION RIGHT)
N2830 G00 X-0.2423 Y5.4283
N2835 G43 Z0.6299 H02
N2840 M98 P1004

(2D-CONTOUR WITH COMPENSATION LEFT)
N2855 G00 X-0.4786 Y9.4283
N2860 G43 Z0.6299 H02
N2865 M98 P1003


Bob Schultz
Sr. Post Processor Developer

Message 4 of 25

bob.schultz
Alumni
Alumni

We have updated  more of the stock HSM post processors with the new subprogram support as described at the top of this conversation.  Here is a list of the stock post processors that support this feature.  If you require subprogram support in a stock post not listed here, then you can request it in this thread.

 

 

fanuc with a-axis.cps
haas.cps
haas next generation.cps
haas next generation m130.cps
haas umc-750.cps
haas with a-axis.cps
heidenhain.cps
mach2mill.cps
mach3mill.cps
mach4mill.cps

 



Bob Schultz
Sr. Post Processor Developer

Message 5 of 25

mwhitten123
Advocate
Advocate

Hello Bob,

 

Great news and info. This will help out lots of our customers.

 

Thanks

Michael Whitten
Selway Machine Tool
CAM Support
mwhitten@selwayapplications.com
0 Likes
Message 6 of 25

Anonymous
Not applicable

Can this be added to an Okuma custom post?

0 Likes
Message 7 of 25

bob.schultz
Alumni
Alumni

Yes, subprograms can be added to an Okuma post processor.  If you have a customized post processor, then you will need to add this code yourself.  The logic will be quite similar to the Fanuc post processor, with some minor changes for the subprogram/macro definition and call.

 

If you need support for subprograms in the generic Okuma post supplied by Autodesk, then please place a request on the HSM Post Processors Idea Station and we will take a look at it.



Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 8 of 25

Anonymous
Not applicable

18664547_1079778708820723_3598230814044337856_n.jpgi face difficulty to post gcode for 4-axis (rotary) with sub program, may i know the subprogram functions support aAxis?where and how to modify the post processor for fanuc? i need the cnc to do cut many numbers cookies pocket shape cut around the cylinder. 

tqvm

0 Likes
Message 9 of 25

Anonymous
Not applicable

mastercam.jpg

this the code generated by mastercam, which we normally use,we are migrant to Fusion 360, hopefully, the right post precessor can be edited

0 Likes
Message 10 of 25

bob.schultz
Alumni
Alumni

Thank you for bringing this to our attention.  The Fanuc posts do not output the initial A-axis position prior to calling a subprogram as they should.  You can make the following changes in your post to get the correct output.

 

Change the following code in the defineWorkPlane function from ...

 

  if (_section.isMultiAxis()) {
      forceWorkPlane();
      cancelTransformation();
    } else {

 

so that it looks like this ...

 

  if (_section.isMultiAxis()) {
      cancelTransformation();
      abc = _section.getInitialToolAxisABC();
      if (_setWorkPlane) {
        forceWorkPlane();
        onCommand(COMMAND_UNLOCK_MULTI_AXIS);
        gMotionModal.reset();
        writeBlock(
          gMotionModal.format(0),
          conditional(machineConfiguration.isMachineCoordinate(0), "A" + abcFormat.format(abc.x)),
          conditional(machineConfiguration.isMachineCoordinate(1), "B" + abcFormat.format(abc.y)),
          conditional(machineConfiguration.isMachineCoordinate(2), "C" + abcFormat.format(abc.z))
        );
      }

You will also need to enable the useSubroutinePatterns property and not the useSubroutines property to output a single subprogram and a number of calls to that same subprogram.

 

Patterns.png

 

We will be updating the generic Fanuc posts with this change.



Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 11 of 25

Anonymous
Not applicable

 

 

Hi, i feel very happy for the fast respond. icode problem.jpg try to copy the code in, the aAxis is coming out for subprogram code, but the subprogram only generated when use subrontines is set to yes, if only set use subrontines panttern is set to yes only, no subprogram is generated.code generated with use subrontines pattern set to yes.jpg

i  attached a fusion file together with the cps file for your references.

thanks for your technical support, best regards, from JoshuaHeart

0 Likes
Message 12 of 25

bob.schultz
Alumni
Alumni

Hello Joshua,

 

Thanks for supplying the post processor you are using, this helps to find your problem.

 

The problem is the post is setup to output TCP programming, meaning that the tool end point is being output instead of the locations adjusted for the rotary table.  You have two options, you can either use the stock Fanuc post that already has the A-axis enabled.

 

http://cam.autodesk.com/posts/?p=fanuc_with_a-axis

 

Or you can modify your post if you have made other changes to it.  The createAxis line should look like this.

 

 

var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], cyclic:true, preference:1});

And you will have to modify the code so that G43 is output instead of G43.4 (enables TCP) inside of the onSection function.

 

 

 

writeBlock(
        gAbsIncModal.format(90),
        gMotionModal.format(0),
        gFormat.format(currentSection.isMultiAxis() ? (machineConfiguration.isMultiAxisConfiguration() ? 43 : 43.5) : 43),
        xOutput.format(initialPosition.x),
        yOutput.format(initialPosition.y),
        zOutput.format(initialPosition.z), hFormat.format(lengthOffset)
      );

 

 

 

 



Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 13 of 25

Anonymous
Not applicable
hi, Mr bob.schultz. Good day to you, you are so nice and finally I found the Fusion 360 can run the 3+1 Axis, substitution aAxis to yAxis. I really feel good to use the Fusion as my new cam software. I already can run the program at my HUST cnc controller, made in taiwan after i remove some unwanted code.by the way, i really need your help to remove some unwanted code. I really thanks for your hardwork in helping me! thank you! i am using your cps.
 
 
besides, I face a difficulty to generate sub program in 2 Pattern, it look like the code in aAxis is more than 360degree( may be is correct, cause the rotary table will make more than one round. am I correct?). normally we need to array my cookies mold in two direction, one is circular pattern, follow by a linear pattern. the fusion can simulate it perfectly, but the code is not same as what we used normally. i will give the code picture. i am ready to produce the first cylinder mold with fusion. thanks again! best regard, Joshua
 
double pattern.jpg2 x 4 holes.jpg
0 Likes
Message 14 of 25

bob.schultz
Alumni
Alumni

Hello Joshua,

 

I am glad to hear that you finding that Fusion can satisfy your machining needs.  For your last request, this should be moved to a new Forum post, since we are now diverging from the intent (subprograms) of this thread.

 

Thanks



Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 15 of 25

Anonymous
Not applicable

double pattern.jpg

 

sorry, i drag to far from this subject:

so now i come back to subrontines, 

I face a difficulty to generate sub program in 2 Pattern, it look like the code in aAxis is more than 360degree, any setting to change to avoid generate this aAxis ?

0 Likes
Message 16 of 25

bob.schultz
Alumni
Alumni

The range setting in the createAxis command informs the post on the limits of the rotary axis.  Make the following change when creating the A-axis to get the output degrees always between 0-360 degrees.

 

var aAxis = createAxis({coordinate:0, table:true, axis:[1, 0, 0], cyclic:true, range:[0, 360], preference:1});


Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 17 of 25

Anonymous
Not applicable

thank you,  i will try...

0 Likes
Message 18 of 25

Anonymous
Not applicable

Good day to you! the 3+1 aAxis cnc cam code finally generated with sub program! it work!

 

 

 

i found fusion will generate wrong code if the pocket draw at 0 degree. 

0 Likes
Message 19 of 25

bob.schultz
Alumni
Alumni

This problem is due to the rotary axis being output between 0-360 degrees and incremental mode being handled by the output variable 'aOutput'.  For example, while a move from A1 to A358 while in absolute mode may move the table 3 degrees, in incremental mode it will output A357.  You can correct this output by adding the following function to your post.

 

function setAAxis(_a) {
  if (incrementalMode) {
    var previousA = aOutput.getCurrent();
    var diff = _a - previousA;
    if (diff > Math.PI) {
      aOutput.format(previousA + Math.PI * 2);
    } else if (diff < -Math.PI) {
      aOutput.format(previousA - Math.PI * 2);
    }
  }
}

and then add the following call prior to formatting the A-axis for output in the onRapid and onLinear functions.

 

setAAxis(_a);
var a = aOutput.format(_a);


Bob Schultz
Sr. Post Processor Developer

0 Likes
Message 20 of 25

Anonymous
Not applicable

TQVM, WILL TRY .....Smiley Happy

0 Likes