Wait for spindle
Posted: Mon Jun 13, 2022 2:30 am
From viewtopic.php?f=4&t=3909
I wanted a way to reduce the spindle spinup delay, especially if I wasn't going to full speed. M3 delay was 9 seconds to be safe.
By using the spindle ready output as an input to the BOB, I was able to wait "only long enough", with the benefit of being able to change spindle speeds between MOPs that used the same tool.
M3 delay is set for zero, and my MOP template from CamBam adds the macro after the spindle/M3 command.
I wanted a way to reduce the spindle spinup delay, especially if I wasn't going to full speed. M3 delay was 9 seconds to be safe.
By using the spindle ready output as an input to the BOB, I was able to wait "only long enough", with the benefit of being able to change spindle speeds between MOPs that used the same tool.
M3 delay is set for zero, and my MOP template from CamBam adds the macro after the spindle/M3 command.
- Code: Select all
// Wait for spindle to reach requested speed
const int pin_spindle=11; // Input pin for spindle ready
const double fail_seconds=10; // Max time to wait for ready
bool ready=AS3.GetLED(pin_spindle);
bool fail=false;
double start_time=DateTime.Now.Ticks;
double elapsed=0;
if(!AS3.Getbuttonstate(114)) // Check for M3
{
exec.AddStatusmessage("Spindle is not running. No spindle delay needed.");
return;
}
if(ready)
{
Thread.Sleep(500); // Debounce to allow the spindle status to change if already running
ready=AS3.GetLED(pin_spindle);
}
if(ready)
{
exec.AddStatusmessage("Spindle is already ready.");
return;
}
exec.AddStatusmessage("Waiting for spindle.");
while(ready==false)
{
elapsed=(DateTime.Now.Ticks-start_time)/10000000;
if(elapsed>fail_seconds)
{
exec.AddStatusmessage("Spindle took too long to be ready.");
exec.Callbutton(130);
fail=true;
break;
}
else
ready=AS3.GetLED(pin_spindle);
}
if(!fail)
exec.AddStatusmessage("Spindle is at requested speed.");