Hello Guest it is October 13, 2019, 05:00:00 PM

Author Topic: Mach4 Spindle At Speed, Spindle Zero Problem  (Read 8919 times)

0 Members and 1 Guest are viewing this topic.

Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #30 on: October 04, 2017, 10:37:59 AM »
Hi Craig,

I wont be able to test new macros for a week but when i test it i will write u the results.

When we finish this lets open a new topic in mach4 forum with name " Macros for Mach4" and lets put working macros under it so all users can find and use them easily.

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #31 on: October 04, 2017, 01:09:19 PM »
Hi,
the daughter board 'Mach4 Toolbox' is the right spot.

It is my experience that a large fraction of users don't read or search the forum. Would they find anything?

Generating some useful code is worthwhile but learning how to write it and the thinking that goes on to improve and develop the code is
even more valuable.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #32 on: October 16, 2017, 11:13:50 AM »
Hi Craig,

The last M3 code you sent does not work, the one before works fine but the last one says "m3 at speed" but it does not wait "spindle at speed" input to turn on, it dives in to gcode while spindle still accelerating.

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #33 on: October 16, 2017, 01:39:04 PM »
Hi Hakan,
I've tested it and have the same problem. The return code from the mcSignalWait is MERROR_INVALID_ARG
yet as far as I know all the arguments are valid. Will make further investigations.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #34 on: October 16, 2017, 02:14:05 PM »
Hi Hakan,
so far what I've discovered is that the API call works with ISIG_INPUT0 but not ISIG_SPINDLE_AT_SPEED.
I have checked and ISIG_SPINDLE_AT_SPEED does evaluate to a number so why the API fails is a mystery. Have started a ticket to ask.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #35 on: October 17, 2017, 02:50:03 AM »
Hi Hakan,
found out a little more about the mcSignalWait API... it accepts signal ID arguments in the range 1-64. Those IDs correspond
to ISIG_INPUT0 thru ISIG_INPUT63.

The two input signals we have used are
ISIG_SPINDLE_AT_SPEED    signal ID =181
ISIG_SPINDLE_AT_ZERO      signal ID=182

So the mcSignalWait API call wont work for these two inputs, but is in all other respects perfect for your purpose.
My suggestion is rather than use ISIG_SPINDLE_AT_SPEED and ISIG_SPINDLE_AT_ZERO chose any two signals from ISIG_INPUT0 to ISIG_INPUT63
instead. You don't have to change any wiring, just assign the pin to your chosen input.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #36 on: October 17, 2017, 03:01:40 AM »
Hi Hakan,
assign Input#62 to your spindle-at-speed pin and Input#63 to your spindle-stopped pin:
Code: [Select]
function m3();
local inst=mc.mcGetInstance();
mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_FWD);
mc.mcCntlSetLastError(inst,"m3 waiting");
local returncode=mc.mcSignalWait(inst,mc.ISIG_INPUT62,mc.WAIT_MODE_HIGH,10);
    if (returncode==mc.MERROR_TIMED_OUT) then
        mc.mcCntlSetLastError(inst,"spindle does not respond");
        mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_OFF);
    else;
        mc.mcCntlSetLastError(inst,"m3 at speed");
    end;
end
if (mc.mcInEditor() == 1) then
    m3()
end

and:
Code: [Select]
function m4();
local inst=mc.mcGetInstance();
mc.mcSpindleSetDirection(inst, mc.MC_SPINDLE_REV);
mc.mcCntlSetLastError(inst,"m4 waiting");
local returncode=mc.mcSignalWait(inst,mc.ISIG_INPUT62,mc.WAIT_MODE_HIGH,10.0);
    if (returncode==mc.MERROR_TIMED_OUT) then
        mc.mcCntlSetLastError(inst,"spindle does not respond");
        mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_OFF);
    else;
        mc.mcCntlSetLastError(inst,"m4 at speed");
    end;
end
if (mc.mcInEditor() == 1) then
    m4()
end
and:
Code: [Select]
function m5();
local inst=mc.mcGetInstance();
mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_OFF);
mc.mcCntlSetLastError(inst,"m5 stopping");
local returncode=mc.mcSignalWait(inst,mc.ISIG_INPUT63,mc.WAIT_MODE_HIGH,10.0);
    if (returncode==mc.MERROR_TIMED_OUT) then
        mc.mcCntlSetLastError(inst,"spindle does not respond");
        mc.mcSpindleSetDirection(inst,mc.MC_SPINDLE_OFF);
    else;
        mc.mcCntlSetLastError(inst,"m5 is stopped");
    end;
end
if (mc.mcInEditor() == 1) then
    m5()
end

See how that works.

Craig
My wife left with my best friend...
     and I miss him!
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #37 on: October 17, 2017, 06:59:06 AM »
Thanks Craig,

I will check and reply.

Regards,

Hakan
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #38 on: October 18, 2017, 09:49:22 AM »
Hi Craig,

the last ones u sent works fine, but in my case vfd sends a signal to input62 for a 2-3 milisecond when spindle starts, it just turns it on for some miliseconds and closes it then when spindle reaches the entered frequency it turns it on, i dont know why it does that but when it turns it on for a 2-3 milisecond or so the m3 code sees the input62 gets high and it says "m3 at speed" and continues the gcode while spindle is still accelerating. In m5 it works correctly because input63 does not do that glitch.

I also checked whether if ISIG_SPINDLE_AT_SPEED did not work because of this glitch but no it doesnt work for m5 either.

So the last code works fine, i will contact with delta vfd support to sort it out.

Regards,

Hakan

Offline DazTheGas

*
  •  750 750
  • DazTheGas
    • View Profile
Re: Mach4 Spindle At Speed, Spindle Zero Problem
« Reply #39 on: October 18, 2017, 01:18:34 PM »
Have you thought about putting a short delay in the script to counteract the short signal.

DazTheGas
Theres always time for a choccy biccy