Re: G21 + G20 checkbox / LED
Posted: Fri Oct 27, 2017 5:13 pm
I've just finished an experiment making this macroloop. The main trick is to select a proper S value, because in a macroloop you must not use Code, so you can only operate with the SRO, but it is an integer limited to 0..300.
Working code (fixed parameters it's just a test):
Working code (fixed parameters it's just a test):
- Code: Select all
double sSet = AS3.Getfielddouble(869); // Setspindlespeed
double x = exec.GetXpos();
double f = 1.0 * 1000; // requested mm/min
double s = 0.0;
double p = 100.0;
if (x < 0.0001) x = 0.0001; // don't divide by zero!
s = f / (2 * x * Math.PI);
AS3.Setfieldtext(s.ToString("F4"), 21000);
p = Math.Floor(s / sSet * 100); // SpindleSet
if (p > 300) p = 300;
AS3.Setfield(p, 233); // SRODRO
AS3.Validatefield(233);