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