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: 4985
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: 877
Joined: Sun Sep 25, 2016 7:39 pm
Location: South Wales. Uk

Re: Wait for spindle

Postby richardk » Wed Jan 15, 2025 4:27 pm

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.


Does "wait for the spindle to spin up" functionality really work with the spindle encoder or index sensor only? I set up the modbus spindle control and I have the actual spindle speed available from modbus. How can I connect this functionality to modbus value?
richardk
 
Posts: 18
Joined: Sat Oct 07, 2023 9:32 am

Re: Wait for spindle

Postby valhallaCNC » Wed Jan 15, 2025 9:17 pm

Might be something here that could help you.....viewtopic.php?f=2&t=3366
valhallaCNC
 
Posts: 84
Joined: Wed Jun 30, 2021 8:04 pm

Re: Wait for spindle

Postby richardk » Wed Jan 15, 2025 11:56 pm

valhallaCNC wrote:Might be something here that could help you.....viewtopic.php?f=2&t=3366

Thank you for the answer. Yes I suppose it is possible to write a custom M3 macro for the purpose of waiting for the spindle spool-up. However since there are dedicated setting and functionality already there which e.g also change the color of the read rpm field during waiting e.t.c., I am wondering if it is possible to to connect the modbus register to actual spindle rpm. I suppose no since it looks like the macros works with just statuses of screenset "LEDs", fields etc. For me it is all a strange approach (e.g. common way to set the modbus field responsible to start the spindle with the value of screenset LED "CW run" and not with some internal engine variable/value/status/function with meaning "spindle running". Similarly "actual spindle rpm" could be the internal status adjustable e.g via the dedicated macro function e.g. from the modbus register in macro loop.. Maybe I am missing something however I feel the current macro approach is not ideal..
richardk
 
Posts: 18
Joined: Sat Oct 07, 2023 9:32 am

Re: Wait for spindle

Postby cncdrive » Thu Jan 16, 2025 5:42 pm

Well, the M3 wait for spindle is a built in functionality, but you could easily override this with modifying the postprocessor of your CAM software, e.g. changing the M3 code to for example M300 and then create an M300 macro file with your own spindle CW on code, like:

Code: Select all
exec.Code("M3);
//Place your wait logic here...


Or you could overwrite the M3 macro file directly.
cncdrive
Site Admin
 
Posts: 4985
Joined: Tue Aug 12, 2014 11:17 pm

Re: Wait for spindle

Postby richardk » Sat Jan 18, 2025 8:28 am

Yes I already have it implemented in M3 macro. However my entry was about something a bit different.
Now it is maybe rather something like a feature request:
At the moment we can set "PWM spindle" or "Step/direction" spindle in Settings->Spindle.
What about to add a third option e.g. "Modbus spindle" with just few setting fields:
- edit field "Target speed modbus register"
- edit field "Actual speed modbus register"
- a field to switch between Hz and rpm (as units of above two registers)
I use modbus for setting and reading of spindle rpm only and use digital outputs to run the spindle (which is more safe I suppose), however if somebody wants to control also run/stop via modbus, another fields can be added:
- CW run modbus register
- CW run modbus register bit
- CCW run modbus register
- CCW run modbus register bit

..by "modbus register" in above I of course mean those internal variables on your Modbus master plugin, user will need to add a connection and functions into Modbus master plugin according type of his VFD.

..then user will not need to add a special macro into the loop nor edit M3/M4 macros to implemented waiting for spindle spoolup
I think those Chinese cheap VFDs are common in hobby CNC and Modbus is pretty convenient way of their control from UCCNC.
BTW here another "feature request" may take a place: to add the RS485 interface into your hardware (not sure if you plan a new hardware though). Plus to implement a ETH to modbus gateway in the firmware :-)
richardk
 
Posts: 18
Joined: Sat Oct 07, 2023 9:32 am


Return to UCCNC TOOL BOX

Who is online

Users browsing this forum: No registered users and 20 guests