Haas lathe post processor output comment with stock dimension and stick-out from chuck?

Haas lathe post processor output comment with stock dimension and stick-out from chuck?

volkcnc
Participant Participant
317 Views
9 Replies
Message 1 of 10

Haas lathe post processor output comment with stock dimension and stick-out from chuck?

volkcnc
Participant
Participant

I'd like my post processor to output a comment at the start of the program that shows the stock diameter and how far the stock is sticking out of the chuck. Since these are all defined in the CAM, I'm sure there is a way to display that data.

 

I'm using the Haas Generic turning post (with some minor edits)

0 Likes
Accepted solutions (1)
318 Views
9 Replies
Replies (9)
Message 2 of 10

da_fish
Advocate
Advocate

Hi, to display the stock size use the getGlobalParameter("stock-upper-x") in the onOpen function.  This will give you the stock radius.

0 Likes
Message 3 of 10

da_fish
Advocate
Advocate

The part extension is a little more complicated but it can be done. Here is the block of code that I used for my post. 

      var orginRef;
      switch (getGlobalParameter("chuck-front-mode")) {
      case "stock front":
        orginRef = toPreciseUnit(getGlobalParameter("stock-upper-z"), MM);
        break;
      case "stock back":
        orginRef = toPreciseUnit(getGlobalParameter("stock-lower-z"), MM);
        break;
      case "model front":
        orginRef = toPreciseUnit(getGlobalParameter("part-upper-z"), MM);
        break;
      case "model back":
        orginRef = toPreciseUnit(getGlobalParameter("part-lower-z"), MM);
        break;
      default:
        error(localize("Chuck reference must be set to Model or Stock, back or front"));
      }

      var mainSpindlePartExtension = Math.abs(toPreciseUnit(getGlobalParameter("chuck-front-offset"), MM) + orginRef);

  Let me know how this works

Message 4 of 10

volkcnc
Participant
Participant

Thanks for the help. I put this code into my post right after the program name portion, before the "dump machine configuration" code. 

 

I also tried placing it in a couple other places in the post processor and get zero output of anything. Not even an error.

 

Nothing changes when I post a program using it, like its not even in there. I am a dirty heathen using imperial units, could that be an issue?

0 Likes
Message 5 of 10

scottmoyse
Mentor
Mentor
Accepted solution

@volkcnc none of the code above actually writes anything out.. it's just pulling values from the post output, storing them as variables, and in the case of mainSpindlePartExtension variable.. performs some math.

Put this in onOpen() and it will work for you:

 

  // Write Stock
  writeComment("Stock Diameter = " + xFormat.format(toPreciseUnit(getGlobalParameter("stock-upper-x"), MM)) + (unit == MM ? "mm" : "\""));
  var orginRef;
  switch (getGlobalParameter("chuck-front-mode")) {
  case "stock front":
    orginRef = toPreciseUnit(getGlobalParameter("stock-upper-z"), MM);
    break;
  case "stock back":
    orginRef = toPreciseUnit(getGlobalParameter("stock-lower-z"), MM);
    break;
  case "model front":
    orginRef = toPreciseUnit(getGlobalParameter("part-upper-z"), MM);
    break;
  case "model back":
    orginRef = toPreciseUnit(getGlobalParameter("part-lower-z"), MM);
    break;
  default:
    error(localize("Chuck reference must be set to Model or Stock, back or front"));
  }

  var mainSpindlePartExtension = Math.abs(toPreciseUnit(getGlobalParameter("chuck-front-offset"), MM) + orginRef);

  writeComment("Stock Stickout = " + zFormat.format(mainSpindlePartExtension) + (unit == MM ? "mm" : "\""));

 

 

scottmoyse_0-1742160122646.png

 

 


Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


RevOps Strategy Manager at Toolpath. New Zealand based.

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 6 of 10

volkcnc
Participant
Participant

I realized after my initial reply that is was just pulling the data and not displaying it. I played around for an hour trying to figure it out but I'm barely literate in coding.

 

The code you posted works perfectly! Very greatly appreciated!

Message 7 of 10

da_fish
Advocate
Advocate

Yes, correct. Sorry I should have mentioned that.  Glad you got it figured out.

0 Likes
Message 8 of 10

programming2C78B
Advisor
Advisor

Is it possible to have the Seimens post also use this info? We were told we cannot have the stickout pulled from fusion for its stock definition.

Please click "Accept Solution" if what I wrote solved your issue!
0 Likes
Message 9 of 10

scottmoyse
Mentor
Mentor
This same code will work for you. Just chuck it in onOpen() in the location
where you want it output.

Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.


EESignature


RevOps Strategy Manager at Toolpath. New Zealand based.

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

0 Likes
Message 10 of 10

da_fish
Advocate
Advocate

You can but, the chuck reference must be set to either the Model or Stock, back or front. You cannot use "Fixture" or "Selection".

da_fish_0-1742217855644.png

The code posted above checks for that and gives an error message if "Fixture" or "Selection" is used.

0 Likes