cncgotoguy

Ending in single digit spindle speed warning, that isn't 0

Recommended Posts

Our spindles don't like when we have a speed ending in a single digit, that isn't 0.

We do however want the posted code to match the mastercam file

Any idea the best way to throw a warning at posting to let the programmer know the spindle speed needs to be rounded?

Share this post


Link to post
Share on other sites
31 minutes ago, cncgotoguy said:

Our spindles don't like when we have a speed ending in a single digit, that isn't 0.

We do however want the posted code to match the mastercam file

Any idea the best way to throw a warning at posting to let the programmer know the spindle speed needs to be rounded?

It might be better to just round it up or down but I have no idea how to do that

Share this post


Link to post
Share on other sites
37 minutes ago, cncgotoguy said:

Any idea the best way to throw a warning at posting to let the programmer know the spindle speed needs to be rounded?

Which mastercam version?

Share this post


Link to post
Share on other sites

2020 Mcam

I see some string functions to convert the number to a string, then break the string into pieces.

We don't want to round. We want the posted file to be exactly the same as the source file.

Share this post


Link to post
Share on other sites

Implement a modulo post block in your post, something like this should get you started...

modulo_result : 0
int_a         : 0
int_n         : 0
remainder     : 0

p_modulo(int_a, int_n, !remainder)
	modulo_result = int_a / int_n
	modulo_result = int(modulo_result)
	modulo_result = modulo_result * int_n
	remainder = int_a - modulo_result

Then call it passing in your spindle speed as int_a, 10 as int_n, and use any numeric value for the returning value (the remainder)

p_modulo(ss$, 10, !result)

If the remainder returns 0, your spindle speed is evenly divisible by ten, so it ends in zero. 

Here are a few test cases

	  p_modulo(20000, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 0.
	  
	  p_modulo(123456, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 6.
	  
	  p_modulo(45000, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 0.
	  
	  p_modulo(1776, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 6.
	  
	  p_modulo(1852, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 2.
	  
	  p_modulo(105, 10, !result)
	  "->", ~result, e$
	  //Output 
          // -> result 5.

 

  • Thanks 1
  • Like 2

Share this post


Link to post
Share on other sites

Have the post alter the variable 'speed' so a spindle speed not ending in zero won't happen, such as:

change the least significant digit to zero.

speed = (int(speed/10)) * 10

 

or

 

define a new variable, say, alt_speed  then a new postblock:

pfixspeed         # spindle speed to end in zero

             alt_speed = (int(speed/10)) * 10

             speed = alt_speed

              *speed

 

or

 

pfixspeed         # spindle speed to end in zero

             alt_speed = (int(speed/10)) * 10

              *alt_speed

then substitute pfixspeed where speed is output

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks everybody, especiialy  Zaffin_D for the help on this. I went with the following code and got it to work. Probably not the prettiest code around

 

fmt     4  modulo_result
fmt     4  int_a
fmt     4  int_n
fmt     4  remainder

 

modulo_result : 0
int_a         : 0
int_n         : 10
remainder     : 0

 

p_modulo
    int_a = speed
    modulo_result = int_a / int_n
    modulo_result = int(modulo_result)
    modulo_result = modulo_result * int_n
    remainder = int_a - modulo_result
    if remainder <>0, result=mprint(ssingledigitspindle)
    If remainder <>0, "(TOOLPATH SPINDLE SPEED ENDS IN SINGLE DIGIT)", e$

 

 

Then I ran the post block p_modulo after each toolchange. 

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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