Multi Setup Posts -which function for start of setup?

Multi Setup Posts -which function for start of setup?

lindsay.fowler
Advocate Advocate
5,245 Views
22 Replies
Message 1 of 23

Multi Setup Posts -which function for start of setup?

lindsay.fowler
Advocate
Advocate

Hi All 🙂

I am busy building a post processor for my CNC machine.

I based it on a post processor for a generic 3 axis CNC.

 

All is pretty much as you would expect and quite fun:

I generate opening g-code using onOpen() for the beginning of the file, onClose() to create any customised ending  g-code, I used onToolChange() to write customised code for my tool changes.

 

Except for this:

Why is there no function for beginning a setup? Something like onBeginSetup() is what I am needing.

Perhaps it is not needed if you are posting out just one setup, but I post multiple setups in one file because I need to flip parts halfway through and the flipped setup has a different coordinate system.

 

So how can I write code that switches off my spindle and moves it out of the way, so my part can be flipped, at the start of the second setup?

 

Thanks All 🙂

 

0 Likes
Accepted solutions (3)
5,246 Views
22 Replies
Replies (22)
Message 2 of 23

matty.fuller
Advisor
Advisor

If your machine is multi axis and you are using 3+2 positional machining, you should be posting a single setup and using 'Tool Orientation' to rotate the workpiece... in this case the rotation of the workplane is handled each time onSection() is called. The function onOpen() is equivalent to the  "onBeginSetup" function you imagine. It might pay to look at an existing multi axis post and examine the code.

 

If you are physically flipping the workpiece and pressing cycle start again, that is multiple setups and each should be posted separately.

0 Likes
Message 3 of 23

lindsay.fowler
Advocate
Advocate

Thanks Matty

My machine is only 3 axis, a home built 3-axis CNC router, so I don't think I am using 3 + 2 positional machining. 

 

I too would have thought onOpen() would get called at the beginning of a setup or the opening of a file, but actually it is not being called at all. I stuck a debug line in it:

// Called in every new gcode file
function onOpen() {
  // See onSection
  writeln("; onOpen() was called.");
  return;
}

And the comment does not appear anywhere in the gcode. Not sure why.

 

Is there any Fusion documentation on working with these functions?

 

I'm trying to automate as much of the work as possible, so I prefer to have everything contained in one file. All I want it to do is move the tool out of the way, tell me to flip the part, tell me what tool to put in next and go on its merry way. 


Anyway it would be very nice to be able to finish my post processor, but I remain stuck at the moment and I'm a bit perplexed as to why the code isn't being called.

Lindsay

0 Likes
Message 4 of 23

Anonymous
Not applicable

I post programs with a manual flip, all in one program. My post uses a section called onparameter that uses an action.

In the program I add a manual nc action (flip), the posts sees the action (flip) and will make the machine do whatever needed to make the flip.

If this is what you are after I can share more info.

Jason

 

0 Likes
Message 5 of 23

matty.fuller
Advisor
Advisor

You need to do some reading, starting with the FAQ thread pinned at the top of this forum: https://forums.autodesk.com/t5/hsm-post-processor-forum/technical-faq/td-p/7473258

 

onOpen() is always called, but it looks like you've got some wacky stuff going on. I don't know what you're doing with a "return;" call in there, for starters.  Read the FAQ which has links to the resources you need... better yet, see if there's already an existing post for your machine's control. The functionality you want might be possible, but it will depend on how your machine/control works... many industrial machines would not let you open the door or declamp the workpiece during a program.

 

 

0 Likes
Message 6 of 23

lindsay.fowler
Advocate
Advocate

Thanks for the links.

To clarify, "return" is standard JavaScript to be found at the end of any function - I didn't put it in there - this was one of the template posts.

 

In any case, there still doesn't seem to be any way of tapping into the beginning of a setup. onOpen() is called at the creation of a gCode file, not the beginning of each setup in that file; in multi-setup posts I believe it is only called once. Perhaps the API will be extended in future, but for now I will just create a seperate gCode file for each setup.

0 Likes
Message 7 of 23

daniel_lyall
Mentor
Mentor

If you have not yet grabbed the post processor editing program here get it, it makes life a bit easier.

 

https://forums.autodesk.com/t5/hsm-post-processor-forum/technical-faq/td-p/7473258

 

The bit you are after is on section using the editor above takes you to the correct places in the post for editing.


Win10 pro | 16 GB ram | 4 GB graphics Quadro K2200 | Intel(R) 8Xeon(R) CPU E5-1620 v3 @ 3.50GHz 3.50 GHz

Daniel Lyall
The Big Boss
Mach3 User
My Websight, Daniels Wheelchair Customisations.
Facebook | Twitter | LinkedIn

0 Likes
Message 8 of 23

fredsi
Collaborator
Collaborator
Accepted solution

Just want to throw this out there to see if it is of interest...

 

We have three kinds of 'stops' in our programs for our Brother machines (essentially Fanuc code). The first is the obligatory optional stop. Actually a function of the controller setting to honor M01 or not - doesn't apply to this discussion.

 

Second type is 'Fixture Stop'; machine stops, turns off spindle and coolant, raises spindle to tool change height and centers table. Idea here is that one doesn't flip the part, but removes clamps, inserts other hold-downs (screws, bolts, etc.), then hits start to continue with the next operation (no change in wcs).

 

Third type is 'Program Stop'; does exactly what the fixture stop does, but the intent is flip parts in vises or fixtures for next operations. This is used when the setup (wcs) is changing for subsequent operations. Both put out a comment on screen, either 'Fixture' or 'Program' to remind operator of what needs to be done. 

 

This is implemented with regular expressions (triggered off of comments rather than Manual NC). Let me know if this has any value for you and be glad to attach the post. 

 

Fred

Message 9 of 23

lindsay.fowler
Advocate
Advocate

Thanks, that's interesting, although it doesn't answer the question I posted.

0 Likes
Message 10 of 23

fredsi
Collaborator
Collaborator

Sorry, think I was incomplete in what I posted. 

 

When we post our programs for multiple setups which involve flipping or turning parts to different setups (multiple wcs) it is actually one program - IOW, post all setups to a single program. We use comments in certain operations and code in onSectionEnd() to halt the machine and move to a convenient location for operator to flip part. 

 

Code at the beginning of onSection() interrogates previous section to see if setup (wcs) has changed and puts out appropriate code to continue with the program. This is why, at least in the situation I described, we don't need a separate onBeginSetup() function. 

 

Again, my apologies if I'm misunderstanding the issue.

 

Fred

0 Likes
Message 11 of 23

Anonymous
Not applicable
Accepted solution

Hi Lindsay, your question was (So how can I write code that switches off my spindle and moves it out of the way, so my part can be flipped, at the start of the second setup?) I think Fred did answer you question, and so did I when I mentioned a Manual NC action. As for your question (Why is there no function for beginning a setup? Something like onBeginSetup() is what I am needing.), I think that is because  is not needed. I think your issue is that a stop is needed before your next setup, weather a flip or moving to a new WCS#. Using a Manual NC action allows you to customize the stop depending on what you are doing, like adding messages and controlling machine movements that are needed for for the operation.

Jason

0 Likes
Message 12 of 23

daniel_lyall
Mentor
Mentor

Having a set and forget in the post saves a lot of time, you can have it go to a spot that you set when posting, on routers this is very handy as the head may be a few meters away.


Win10 pro | 16 GB ram | 4 GB graphics Quadro K2200 | Intel(R) 8Xeon(R) CPU E5-1620 v3 @ 3.50GHz 3.50 GHz

Daniel Lyall
The Big Boss
Mach3 User
My Websight, Daniels Wheelchair Customisations.
Facebook | Twitter | LinkedIn

0 Likes
Message 13 of 23

Anonymous
Not applicable

Hi Daniel, what do you mean by a set and forget in the post?

Thanks,

Jason

0 Likes
Message 14 of 23

daniel_lyall
Mentor
Mentor

It is a set position in the post-processor, to change it you will have to go into the post and change it if you have to add it to the Gcode everytime you post code out there is a chance you will forget it.


Win10 pro | 16 GB ram | 4 GB graphics Quadro K2200 | Intel(R) 8Xeon(R) CPU E5-1620 v3 @ 3.50GHz 3.50 GHz

Daniel Lyall
The Big Boss
Mach3 User
My Websight, Daniels Wheelchair Customisations.
Facebook | Twitter | LinkedIn

0 Likes
Message 15 of 23

Anonymous
Not applicable

Thanks for the reply, It sounds similar to what I am doing.

Jason

0 Likes
Message 16 of 23

daniel_lyall
Mentor
Mentor

It is not like what you suggested at all, you only change it if you need to otherwise you leave it.


Win10 pro | 16 GB ram | 4 GB graphics Quadro K2200 | Intel(R) 8Xeon(R) CPU E5-1620 v3 @ 3.50GHz 3.50 GHz

Daniel Lyall
The Big Boss
Mach3 User
My Websight, Daniels Wheelchair Customisations.
Facebook | Twitter | LinkedIn

0 Likes
Message 17 of 23

Anonymous
Not applicable

You said it is a set position in the post processor. I have set positions in the post processor I was not talking about editing the G-code every time. In the picture below I highlighted what I meant by Manual NC Action. The post is setup to do specific machine movements based on which action is added in cam and also outputs the messages for the operator. In this case the action is flip.FLIP.JPG

 

0 Likes
Message 18 of 23

lindsay.fowler
Advocate
Advocate

Hi Jason, 

Thank you.

I will see if I can grasp how Manual NC commands are used.

 

0 Likes
Message 19 of 23

Anonymous
Not applicable

Below is the onParameter code I am using if it helps. some of the posts have the onParameter section and some don't

Jason

 

function onParameter(name, value) {
switch (name) {
  case "action":
    if (value.toUpperCase() == "FLIP") {
   
  
  writeBlock(gFormat.format(0), zOutput.format(40));
  onCommand(COMMAND_COOLANT_OFF);
  writeBlock(gFormat.format(15),"H01",gFormat.format(80));
 
  feedOutput.reset();
  writeBlock(gFormat.format(00), "P1", xOutput.format(-40), yOutput.format(15));
  writeBlock ("G116");
  onCommand(COMMAND_STOP_SPINDLE);
 
  writeBlock(mFormat.format(0));    // ADDED onParameter section
  

 

 

 

 

 

 

 

 

0 Likes
Message 20 of 23

lindsay.fowler
Advocate
Advocate

That's helpful thanks

Oh I see.

Let me rewrite it, because I think I can do so in a way that is more structured and helpful to others:

 

 

 

Your post processor contains the onParameter function, which you can modify with custom gcode:

 

function onParameter(name, value) {
switch (name) {
  case "action":
    if (value.toUpperCase() == "FLIP") {
    
   
  writeBlock(gFormat.format(0), zOutput.format(40));
  onCommand(COMMAND_COOLANT_OFF);
  writeBlock(gFormat.format(15),"H01",gFormat.format(80));
 
  feedOutput.reset();
  writeBlock(gFormat.format(00), "P1", xOutput.format(-40), yOutput.format(15));
  writeBlock ("G116");
  onCommand(COMMAND_STOP_SPINDLE);
  
  writeBlock(mFormat.format(0));    // ADDED onParameter section

 

Manual NC commands cause the onParameter function to be called, with two arguments passed: name and value (set below).

 

 

In CAM you use the Setup > Manual NC menu to create a command of a certain type: you created an NC command of type "action", as "action" is a there as a case in the case statement.

Screen Shot 2019-01-15 at 12.45.16 pm.png

You then set the value to like this:

Screen Shot 2019-01-15 at 12.52.34 pm.png

("FLIP" coincides with the if statement)

 

 The Manual NC command appears in the list like any other operation:

Screen Shot 2019-01-15 at 1.03.57 pm.png

Finally, when posting g code, the post processor produces gcode for each operation, including the Manual NC command. In the example above, when the upper side is done, there is ManualNC2, so onParameter is called thus: onParameter("action". "FLIP") and your custom code gets executed to write your custom flip gcode to the output file.

0 Likes