Only post 4th axis when needed

Only post 4th axis when needed

Anonymous
Not applicable
1,880 Views
19 Replies
Message 1 of 20

Only post 4th axis when needed

Anonymous
Not applicable

Hi all.

 

I have got my post (for a litz 3+1 VMC)working pretty well now, but there is one remaining issue.


I changed the post to only output A axis moves if that toolpath requires it, as the 4th axis is only used occasionally, and locking and unlocking the 4th axis takes a fair bit of time.

 

The issue is that if the 4th axis is moved by the first toolpath and the second toolpath uses the default 4th axis position - 0 deg, then this is not posted.

 

ie: 1st toolpath machines part at 90deg, post rotates A from current position to 90. 

2nd toolpath machines part at 0deg, no A move is posted.

 

It seems like the safest way to address this is for the post to output a A axis move for every toolpath *IF* there are any A axis moves in the program?

 

Can someone please help me get this working?

 

i believe the following code controls what is posted:      Entire post attached also.

  if (abc.isNonZero()) {
    onCommand(COMMAND_UNLOCK_MULTI_AXIS);
  
    if (useMultiAxisFeatures) {
      if (abc.isNonZero()) {
        writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
        writeBlock(gFormat.format(53.1)); // turn machine
      } else {
        writeBlock(gFormat.format(69)); // cancel frame
      }
    } else {
      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))
      );
    }
    
    onCommand(COMMAND_LOCK_MULTI_AXIS);
  
    currentWorkPlaneABC = abc;
  }

Thankyou

0 Likes
Accepted solutions (1)
1,881 Views
19 Replies
Replies (19)
Message 2 of 20

Laurens-3DTechDraw
Mentor
Mentor

Also check if the currentWorkplane is nonzero.

Laurens Wijnschenk
3DTechDraw

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


0 Likes
Message 3 of 20

Anonymous
Not applicable

Wouldn't it also be zero though?

0 Likes
Message 4 of 20

Anonymous
Not applicable

I cant see any way to make this work.

 

currentWorkplaneABC is "abc" if that section sets the 4th axis to a non zero number and "undefined" otherwise?

 

i cant see how you mean for me to use this, i need something that is global for the whole program, not per section if that makes sense? 

0 Likes
Message 5 of 20

Laurens-3DTechDraw
Mentor
Mentor

My point was that you could check a variable that was set in the previous section and if that is not 0 OR the current ABC is not zero you should give the A-axis value.

 

You see this code? It checks if the current abc.x  is the same as currentWorkPlaneABC.x which was set the last time the setWorkPlane function was executeed.

  if (!((currentWorkPlaneABC == undefined) ||
        abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
        abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
        abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {

    return; // no change
  } 

So you can check if abc.isNonZero() or if currentWorkPLaneABC.isNonZero(), than you give out the workplane. Else no need.

Laurens Wijnschenk
3DTechDraw

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


0 Likes
Message 6 of 20

Anonymous
Not applicable

Ok, so i have it working to a point:

 

I think this is along the lines of what you suggested... Im in a fair way over my head here.

However, this only posts A0's for toolpaths that are posted after the 4th axis is moved the first time. Its heading in the right direction, but i really need something that will post AO's for all toolpaths in any program where there is a A axis move.

as it is a crash would occur on a second part if the last toolpath was say A180 and the first toolpath is A0, as the A0 is not present on the first toolpath.

var forthAxisUsed = 0;

function setWorkPlane(abc) {
if (!forceMultiAxisIndexing && is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
return; // ignore
}
if (!((currentWorkPlaneABC == undefined) ||
abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
return; // no change
}

if ((abc.isNonZero()) ||
(forthAxisUsed > 0)) {
onCommand(COMMAND_UNLOCK_MULTI_AXIS);

if (useMultiAxisFeatures) {
if (abc.isNonZero()) {
writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
writeBlock(gFormat.format(53.1)); // turn machine
} else {
writeBlock(gFormat.format(69)); // cancel frame
}
} else {
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))
);
}

onCommand(COMMAND_LOCK_MULTI_AXIS);

forthAxisUsed++;

currentWorkPlaneABC = abc;
}
}
0 Likes
Message 7 of 20

Laurens-3DTechDraw
Mentor
Mentor
Accepted solution

In that case you will need a totally different approach than you took.

You will need to do something like is being done for the tool list.

Check through all the sections to see if one of those has an abc.isNonZero() =  true.

So something like this:

if(isFirstSection()){
 var numberOfSections = getNumberOfSections();
      for (var i = 0; i < numberOfSections; ++i) {
      var section = getSection(i);
      var 4Axis = section.abc.isNonZero();
     if(4Axis == true){
break;
}
}
}

This is not tested, just a general direction.

Laurens Wijnschenk
3DTechDraw

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


Message 8 of 20

Anonymous
Not applicable

Thanks for your help so far mate, but im really not making any progress here

  if(true){
 var numberOfSections = getNumberOfSections();
      for (var i = 0; i < numberOfSections; ++i) 
      var section = getSection(i);
      var fourthAxisUsed = (section.abc.x);
     if(fourthAxisUsed > 0){

 

 

This is the best i have managed, and i always get the error "TypeError: section.abc is undefined"

 

I have no idea how to define it or if that is even possible.  I dont even understand what the output of (section.abc.x) actrually is...

It almost seems like things like section.**** or whatever are things that must be refered to freom the output of the CAM, but i dont understand where they come from, or where to find a list of them... 😞

 

For example:

    var tools = getToolTable();
    if (tools.getNumberOfTools() > 0) {
      for (var i = 0; i < tools.getNumberOfTools(); ++i) {

 getNumberOfTools...... so we are getting the number of tools, easy enough... but where did "NumberOfTools" come from? its not anywhere else in the post, and its not in the dump log either, so where does it come from, and how are we supposed to know to use it?

 

Thanks.

 

0 Likes
Message 9 of 20

Laurens-3DTechDraw
Mentor
Mentor

abc = getWorkPlaneMachineABC(section.workPlane);

Probably need this line too.

Laurens Wijnschenk
3DTechDraw

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


Message 10 of 20

Laurens-3DTechDraw
Mentor
Mentor

I'll try to make time to check this myself.

Laurens Wijnschenk
3DTechDraw

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


Message 11 of 20

uygar
Explorer
Explorer

Yes, General Post Processor to fix a mistake

0 Likes
Message 12 of 20

Laurens-3DTechDraw
Mentor
Mentor

@Anonymous wrote:

Yes, General Post Processor to fix a mistake


@uygar

What do you mean here?

Laurens Wijnschenk
3DTechDraw

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


0 Likes
Message 13 of 20

Anonymous
Not applicable
I'm doing an online JavaScript course, and downloaded the help file you linked.... Working on it.... Still over my head though.
0 Likes
Message 14 of 20

uygar
Explorer
Explorer

(2B-PROFIL1)

1.A0

2.A-51.429

...

7A51.429

(2B-PROFIL3)

1. A0 no rotate to continue from the last (2B-PROFIL1) 7.A51.429

....

add nc. code

0 Likes
Message 15 of 20

Anonymous
Not applicable

Ok, it seems like i am getting really close, but i am getting either always a A move posted, or never an A move posted...

Seems like it might be a simple fix from here, but i just cant figure it out.

 

function setWorkPlane(abc) {
  if (!forceMultiAxisIndexing && is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
    return; // ignore
  }
  if (!((currentWorkPlaneABC == undefined) ||
        abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
        abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
        abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
    return; // no change
  }
  var numberOfSections = getNumberOfSections();

  for (var i = 0; i < numberOfSections; ++i) {
  var sectionB = getSection(i);
  abcUsed = getWorkPlaneMachineABC(sectionB.workPlane);
  var fourthAxisUsed = abcUsed.isNonZero();
	  
	  
  if(fourthAxisUsed!=true){   
    onCommand(COMMAND_UNLOCK_MULTI_AXIS);
  
    if (useMultiAxisFeatures) {
      if (abc.isNonZero()) {
        writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
        writeBlock(gFormat.format(53.1)); // turn machine
      } else {
        writeBlock(gFormat.format(69)); // cancel frame
      }
    } else {
      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))
      );
    }
    
    onCommand(COMMAND_LOCK_MULTI_AXIS);
	currentWorkPlaneABC = abc;
	break;
    }
  }
}
0 Likes
Message 16 of 20

Laurens-3DTechDraw
Mentor
Mentor

Seems like you only should do the check once.

In the beginning:

function setWorkPlane(abc) {
  if (!forceMultiAxisIndexing && is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
    return; // ignore
  }
  if (!((currentWorkPlaneABC == undefined) ||
        abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
        abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
        abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
    return; // no change
  }
  var numberOfSections = getNumberOfSections();

if(isFirstSection()){
  for (var i = 0; i < numberOfSections; ++i) {
  var sectionB = getSection(i);
  abcUsed = getWorkPlaneMachineABC(sectionB.workPlane);
  var fourthAxisUsed = abcUsed.isNonZero();
}	  
	  
  if(fourthAxisUsed!=true){   
    onCommand(COMMAND_UNLOCK_MULTI_AXIS);
  
    if (useMultiAxisFeatures) {
      if (abc.isNonZero()) {
        writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
        writeBlock(gFormat.format(53.1)); // turn machine
      } else {
        writeBlock(gFormat.format(69)); // cancel frame
      }
    } else {
      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))
      );
    }
    
    onCommand(COMMAND_LOCK_MULTI_AXIS);
	currentWorkPlaneABC = abc;
	break;
    }
  }
}

Laurens Wijnschenk
3DTechDraw

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


0 Likes
Message 17 of 20

Anonymous
Not applicable

Now it only posts A moves for the first toolpath, and still posts A0 if there are no A moves in the program... 😞

0 Likes
Message 18 of 20

Laurens-3DTechDraw
Mentor
Mentor

So didn't look to well.

The problem is you didn't break out the moment it finds a 4-axis move.

 

So something like this?

function setWorkPlane(abc) {
  if (!forceMultiAxisIndexing && is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
    return; // ignore
  }
  if (!((currentWorkPlaneABC == undefined) ||
        abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
        abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
        abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
    return; // no change
  }
  var numberOfSections = getNumberOfSections();

if(isFirstSection()){
  for (var i = 0; i < numberOfSections; ++i) {
  var sectionB = getSection(i);
  abcUsed = getWorkPlaneMachineABC(sectionB.workPlane);
  var fourthAxisUsed = abcUsed.isNonZero();
 if(fourthAxisUsed){
break;
}
}	  
	  
  if(fourthAxisUsed){   
    onCommand(COMMAND_UNLOCK_MULTI_AXIS);
  
    if (useMultiAxisFeatures) {
      if (abc.isNonZero()) {
        writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
        writeBlock(gFormat.format(53.1)); // turn machine
      } else {
        writeBlock(gFormat.format(69)); // cancel frame
      }
    } else {
      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))
      );
    }
    
    onCommand(COMMAND_LOCK_MULTI_AXIS);
	currentWorkPlaneABC = abc;
	break;
    }
  }
}

 

Laurens Wijnschenk
3DTechDraw

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


0 Likes
Message 19 of 20

Anonymous
Not applicable

finally got it!!!

you were pretty much there with the post i accepted with a solution still not sure what exactly is going on, but it works!

using abc as the variable name was causing issues i think, i have just changed it to j, since i have no idea what it actually does.

Here is the final code for anyone interested:

function setWorkPlane(abc) {
  if (!forceMultiAxisIndexing && is3D() && !machineConfiguration.isMultiAxisConfiguration()) {
    return; // ignore
  }
  if (!((currentWorkPlaneABC == undefined) ||
        abcFormat.areDifferent(abc.x, currentWorkPlaneABC.x) ||
        abcFormat.areDifferent(abc.y, currentWorkPlaneABC.y) ||
        abcFormat.areDifferent(abc.z, currentWorkPlaneABC.z))) {
    return; // no change
  }

  
  if(isFirstSection()){
    var numberOfSections = getNumberOfSections();
    for (var i = 0; i < numberOfSections; ++i) {
      var section = getSection(i);
	  j = getWorkPlaneMachineABC(section.workPlane);
      var fourthUsed = j.isNonZero();
      if(fourthUsed == true){
		fourthAxisUsedGlobal++;  
        break;
      }
    }
  }
  
  if(fourthAxisUsedGlobal>0){   
    onCommand(COMMAND_UNLOCK_MULTI_AXIS);
  
    if (useMultiAxisFeatures) {
      if (abc.isNonZero()) {
        writeBlock(gFormat.format(68.2), "X" + xyzFormat.format(0), "Y" + xyzFormat.format(0), "Z" + xyzFormat.format(0), "I" + abcFormat.format(abc.x), "J" + abcFormat.format(abc.y), "K" + abcFormat.format(abc.z)); // set frame
        writeBlock(gFormat.format(53.1)); // turn machine
      } else {
        writeBlock(gFormat.format(69)); // cancel frame
      }
    } else {
      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))
      );
    }
    
    onCommand(COMMAND_LOCK_MULTI_AXIS);
	currentWorkPlaneABC = abc;
    }
}

Thanks very much for your help Laurens, i couldn't have done it without you.Smiley Happy

0 Likes
Message 20 of 20

guido_antoniol
Enthusiast
Enthusiast

Good morning, I'm referring to this post, but the same thing can be done with the generic Fanuc post, I tried but after the changes the post stops working.

0 Likes