Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

How to add zero's to tool sequence #


Recommended Posts

Good Day,

 

I am working on an Okuma 7000 lathe post and I am running into a bit of a snag getting the output the operators are looking for. I was able to add a Number line that corresponds to the tool (Thank you Colin) and the output is good: NT1202 (OPERATION NUMBER: 5)

 

But I need to have the output be as follows: NT12 (1st instance of tool 12), NT012 (2nd instance), NT0012 (3rd instance), so on and so forth.

 

The code is pretty straight forward right now:

n$ = (tcnt * seqinc$) + (t$*100)

 

I need to see how I can have the seqinc$ = "0" and then do a logic loop and add an additional zero per instance of the same tool until there are no more tool counts and it ouputs the appropriate number of zero's in front of the tool number. This is where my noodle is starting to bake a bit and I would love a nudge in the right direction if possible.

 

Thanks all!

Link to comment
Share on other sites

Hi Del,

 

For the zero's issue, I'd suggest using the 'newfs' function to change the Format Statement that is assigned to the 't$' variable. You can setup some Format Statements with different numbers of leading zeros, and use your counter logic to set the appropriate FS number.

 

For keeping track of the number of changes per tool, I'd recommend setting up Lookup Table for doing this. That way you can make a call to the Lookup Table each time a tool number is used, and the function (finc) will return an integer that shows which tool change number that is.

 

Try doing a search in this forum. I think I covered the Lookup Table before...

 

Thanks,

 

Colin

Link to comment
Share on other sites

Keep in mind that if you use the FS method of changing the leading zero's, that you are limited to 9 tool changes for each tool, as the largest number MP can handle is +9.6, which is 15 digits.

 

Technically I guess you could convert your tool number into a 6 place decimal value, then force leading and trailing zeros if your program goes above 9 tool changes for the same tool number. That would get a little messy, but it would allow you to support up to 15 tool changes per tool number being called.

 

The only other solution would be to convert the tool number into a string variable value, get the string length, then add extra string characters ("0") to the string prior to output.

 

If you don't think you'll go over 9 tool changes per program, then I'd stick with numeric values and not bother converting it into a string...

Link to comment
Share on other sites

Thank you for the reply, it's greatly appreciated.

 

I have already built up a tool count and a lookup table, so that information is present. What I would like to do is make "0" more of an object instead of a number. So that I can basically say n$ = (tlcnt * "0") + t$

 

The number value zero would return some bad logic, but an object (constant?) would, I assume, be output as many times as the tool count. Am I on the right track or completely lost in space here?

 

Thanks again!

Link to comment
Share on other sites

Hi Del,

 

There is no such animal as a "constant" in the MP language. You get String variables and Numeric Variables. There are functions to convert from one to the other data type, but you aren't going to be able to combine the logic in a single formula statement, like you are attempting to do now.

 

I would use some calls to 'finc' to increment the tool number in the lookup table, and based on the return value, I would select a different Format Statement for output, using the 'newfs' function.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...