Page 1 of 2

Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 3:34 am
by Blaise
Hi all,

The machine I am modernizing has two sets of straps and pulleys and they are automatically changed on the fly depending on the commanded RPM.
Low gear goes from zero RPM to 2500 and high gear from 2501 to 10 000.

I want the M3 and M4 macro to automatically set the pulley ratio (M215 P*).

I've been testing some code but I get weird results. Here is the code:

Code: Select all

float SpindleSpeed = float.Parse(AS3.Getfield(869));


if(SpindleSpeed < 2500){
   exec.Code("M215 P1");
   while(exec.Ismacrorunning(215)>1){}
   MessageBox.Show("Debug 1");
}

if(SpindleSpeed >= 2500 && SpindleSpeed <= 10000){
   exec.Code("M215 P2");
   while(exec.Ismacrorunning(215)>1){}
   MessageBox.Show("Debug 2");
}

if(SpindleSpeed > 10000){
   exec.Code("M215 P2");
   while(exec.Ismacrorunning(215)>1){}
   MessageBox.Show("Commanded spindle speed exceeds machine capabilities");
}


Any one knows I could get this to work?

Thanks!

- Blaise

Re: Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 12:50 pm
by Blaise
Analyzing the results I get, I realized that my problem comes from the first line in my code.
If for exemple I am set to M215 P1 and I call M3 S6000, the spindle speed will be set to the maximum of the current pulley rage so 2500.
So the result from my first line of code returns 2500. What I need is the 6000 result that was originally called with the M3 S6000.

Is there an other field I can get my commanded speed from? A variable maybe? Or some other trickery!

Thanks for your precious help!

- Blaise

Re: Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 1:00 pm
by ger21
use field 2014 to get the pulley ratio, and do the math in your macro to calculate the actual rpm.

Re: Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 1:04 pm
by Blaise
Thanks ger21,

I'll try that tonight after work. I'll let you know how it goes.

- Blaise

Re: Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 1:13 pm
by Blaise
Actually, unless I'm missing something, even if I have the pulley ratio, I can't do the math because I still don't have the 6000 from my initial M3 S6000 call.
The 2500 result I get it not the result of a ratio calculation, it's simply the maximum range of the current selected pulley. So I really need the S parameter from the M3 SXXX before it is processed by the pulley ration system.

I hope I am making sense!

- Blaise

Re: Calling M215 P* from macro

PostPosted: Wed Jan 19, 2022 5:31 pm
by ger21
Field 178 will get you the current max RPM from the pulley speed window. It changes when the pulley is changed.
So you would want whichever is less, Field 869 or Field 178.
I think?

Re: Calling M215 P* from macro

PostPosted: Thu Jan 20, 2022 4:02 am
by Blaise
I will simplify my question.

If I write S6000 on the MDI, is the 6000 number stored in a field or variable somewhere?

Thanks for your help!

- Blaise

Re: Calling M215 P* from macro

PostPosted: Thu Jan 20, 2022 1:17 pm
by ger21
Not sure, but my previous reply should work, no?
I would think S6000 should be SSet, but the pulleys seem to change it.

Re: Calling M215 P* from macro

PostPosted: Thu Jan 20, 2022 1:21 pm
by Blaise
Yes, The pulley change the Sset before it gets to the M3 macro so it's useless. I need to know if there is a variable somewhere that holds the unchanged S parameter as it was input by the user.

Re: Calling M215 P* from macro

PostPosted: Fri Jan 21, 2022 12:39 am
by eabrust
Since your macro will actually be the decision point of what speed ranges apply to the pulley ratio, can't you open up the speed range in the pulley settings dialog so that the 'max speed' of a pulley won't clip the speed you enter in MDI?

Maybe I'm looking at it wrong, so just throwing out an idea.. :) .



regards,
Eric