Wait for spindle

Here is where you can drop off Examples of WORKING macros,plugins,Gcode programs , macro Wizards etc.
Please give a brief description of what it is and how it works.

Wait for spindle

Postby rojhan » 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.

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.");
rojhan
 
Posts: 23
Joined: Fri Jun 10, 2022 4:45 pm

Re: Wait for spindle

Postby cncdrive » Mon Jun 13, 2022 3:14 am

We've added this functionality was added to the next release of the UCCNC, however it requires a spindle encoder or index sensor to measure the speed of the spindle.
You can set the tolerance % and a time constant for stable spindle speed.
For example you set 90% and 1seconds and programming S1000 then the controller will wait for the speed to reach 900 RPM and if the RPM is above 900RPM for 1seconds then it continues the g-code execution after and M3 or M4 or S command.
cncdrive
Site Admin
 
Posts: 4695
Joined: Tue Aug 12, 2014 11:17 pm

Re: Wait for spindle

Postby rojhan » Mon Jun 13, 2022 4:15 am

cncdrive wrote:We've added this functionality was added to the next release of the UCCNC, however it requires a spindle encoder or index sensor to measure the speed of the spindle.
You can set the tolerance % and a time constant for stable spindle speed.
For example you set 90% and 1seconds and programming S1000 then the controller will wait for the speed to reach 900 RPM and if the RPM is above 900RPM for 1seconds then it continues the g-code execution after and M3 or M4 or S command.


Could the functionality be extended using the concepts in the macro? Rather than UCCNC measuring RPM, just specify a "spindle ready" input pin for the VFDs that support it.
rojhan
 
Posts: 23
Joined: Fri Jun 10, 2022 4:45 pm

Re: Wait for spindle

Postby Battwell » Wed Jun 29, 2022 10:36 am

use a while loop at the end of your m3 macro to wait for the at speed signal to go active.
Uc300eth on router and mill.
UK uccnc powered machine sales. https://cncrouter.uk/atc-cnc-routers.htm
Automateanything/duzzit cnc/mercury cnc
Battwell
 
Posts: 821
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk


Return to UCCNC TOOL BOX

Who is online

Users browsing this forum: No registered users and 3 guests