Ok, I've done it.
And YES, it's necessary, because I don't like to damage my 1400 Euro spindle.
I added a button to the screen (ID=20000) and a textfield (ID=20000). With the button I can start or interrupt the warm-up procedure. While the warm-up procedure is running the button for warm-up blinks and show me the remaining seconds of the current stage. Now I can leave my workshop while the spindle is warming up and drink a coffee
The screen looks like this:
- UCCNC-Screen with running warm-up
And the macro looks like this:
- Code: Select all
// Spindle Heat-Up
// stages for warm-up
const int Stages = 4;
double[] Speed = new double[Stages];
int[] Time = new int[Stages];
Speed[0] = 6000;
Time[0] = 300;
Speed[1] = 12000;
Time[1] = 300;
Speed[2] = 18000;
Time[2] = 240;
Speed[3] = 6000;
Time[3] = 60;
// Position for the warm-up procedure
double PosX = 0;
double PosY = 620;
double PosZ = 140;
if (AS3.Getbuttonstate(20000)) // if the warm-up is running already stop it
{
// switch the state to "off"
AS3.Switchbutton(false, 20000);
}
else // start heat-up
{
// machine must be homed
if(!exec.GetLED(56)||!exec.GetLED(57)||!exec.GetLED(58))
{
MessageBox.Show("The machine was not yet homed, home the machine before warm-up!");
AS3.Setfieldtext("ERROR", 20000);
// leave the macro
exec.Stop();
return;
}
// show init info
AS3.Setfieldtext("INIT", 20000);
// switch the state to "on"
AS3.Switchbutton(true, 20000);
// store the current distance mode
int DistanceMode = exec.actualmodal;
// wait until everything is stopped
while(exec.IsMoving()){}
// move the Z axis to the warm-up position
exec.Code("G00 G53 Z"+ PosZ);
while(exec.IsMoving()){}
exec.Wait(200);
// move the X and Y axis to the warm-up position
exec.Code("G00 G53 X" + PosX +" Y" + PosY);
while(exec.IsMoving()){}
exec.Wait(200);
// restore the original distance mode
exec.Code("G" + DistanceMode);
// perform the stages
int Stage = 0;
while (Stage < Stages)
{
// set the spindle speed
exec.Code("S" + Speed[Stage]);
// turn the spindle on
exec.DospinCW();
// wait
int Secs = 0;
while (Secs < Time[Stage])
{
exec.Wait(1000);
Secs++;
AS3.Setfieldtext((Time[Stage] - Secs).ToString(), 20000);
// interrupt the warm-up?
if (!AS3.Getbuttonstate(20000))
{
// stop the spindle
exec.Stopspin();
// show interrupt
AS3.Setfieldtext("", 20000);
// leave the macro
exec.Stop();
return;
}
}
// next Stage
Stage++;
}
// stop the spindle
exec.Stopspin();
// switch the state to "off"
AS3.Switchbutton(false, 20000);
AS3.Setfieldtext("OK", 20000);
}