Calling M215 P* from macro

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Calling M215 P* from macro

Postby Blaise » Wed Jan 19, 2022 3:34 am

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
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby Blaise » Wed Jan 19, 2022 12:50 pm

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
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby ger21 » Wed Jan 19, 2022 1:00 pm

use field 2014 to get the pulley ratio, and do the math in your macro to calculate the actual rpm.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Calling M215 P* from macro

Postby Blaise » Wed Jan 19, 2022 1:04 pm

Thanks ger21,

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

- Blaise
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby Blaise » Wed Jan 19, 2022 1:13 pm

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
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby ger21 » Wed Jan 19, 2022 5:31 pm

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?
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Calling M215 P* from macro

Postby Blaise » Thu Jan 20, 2022 4:02 am

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
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby ger21 » Thu Jan 20, 2022 1:17 pm

Not sure, but my previous reply should work, no?
I would think S6000 should be SSet, but the pulleys seem to change it.
Gerry
UCCNC 2022 Screenset - http://www.thecncwoodworker.com/2022.html
ger21
 
Posts: 2794
Joined: Sat Sep 03, 2016 2:17 am

Re: Calling M215 P* from macro

Postby Blaise » Thu Jan 20, 2022 1:21 pm

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.
Blaise
 
Posts: 82
Joined: Tue Jan 16, 2018 3:41 am

Re: Calling M215 P* from macro

Postby eabrust » Fri Jan 21, 2022 12:39 am

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
CraftyCNC: Plugins for UCCNC (and other neat stuff): http://www.craftycnc.com/plugins-for-uccnc/
eabrust
 
Posts: 361
Joined: Fri Sep 16, 2016 2:32 am
Location: Near Shirland IL, USA

Next

Return to Macros

Who is online

Users browsing this forum: No registered users and 0 guests