Hello Guest it is March 29, 2024, 09:18:48 AM

Author Topic: Stop/Reset scripts with and without Gcode  (Read 1790 times)

0 Members and 1 Guest are viewing this topic.

Stop/Reset scripts with and without Gcode
« on: January 28, 2017, 11:32:55 PM »
Hi All,
I've got myself tied up in knots. Over the last few days I've been helping Zuxztah to write code sufficient to control a VFD
over Modbus. Has been coming on pretty well but find myself out of my depth and the end.

Have got the Modbus link to work, have the scripts necessary for the CW and CCW buttons and associated spindle override to work.

The problem is how to stop the spindle under different conditions. From Gcode or MDI m5 works fine.

For the 'Stop' button I have the following:
Code: [Select]
Shutdown();
CycleStop();

For the 'Reset' button I have:
Code: [Select]
Shutdown();
local inst = mc.mcGetInstance()
mc.mcCntlReset(inst)
--mc.mcSpindleSetDirection(inst, 0)
mc.mcCntlSetLastError(inst, 'diagReset')

And the two functions in the screen load script:
Code: [Select]
---------------------------------------------------------------
--  Spindle Shutdown
---------------------------------------------------------------
function Shutdown();
    local inst=mc.mcGetInstance();
    mc.mcCntlGcodeExecuteWait(inst,"m5");
end;
---------------------------------------------------------------
-- Cycle Stop function.
---------------------------------------------------------------
function CycleStop()
    mc.mcSpindleSetDirection(inst, 0);
    mc.mcCntlSetLastError("Cycle Stopped");
    mc.mcCntlCycleStop(inst);
end

---------------------------------------------------------------

When I click the Reset button it appears to work, namely it calls m5 and therefore stops the spindle executes the mc.mcCntlReset(inst) statement
and as a diagnostic feature displays mc.mcCntlSetLastError(inst, 'diagReset').

When I click the Stop button it executes m5 and stops the spindle and appears to execute mc.mcCntlCycleStop but never displays
mc.mcCntlSetLastError("Cycle Stopped");.

Worse however if I have a Gcode program running and either Stop or Reset buttons are clicked the spindle does not stop and Mach4 crashes.

What am I misunderstanding?

What does mc.mcCntlCycleStop actually do?

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Stop/Reset scripts with and without Gcode
« Reply #1 on: January 29, 2017, 03:40:02 AM »
mc.mcCntlSetLastError("Cycle Stopped")

Is there anything missing from this line that may cause it to not work ;-)

DazTheGas
New For 2022 - Instagram: dazthegas

Offline dude1

*
  •  1,253 1,253
    • View Profile
Re: Stop/Reset scripts with and without Gcode
« Reply #2 on: January 29, 2017, 04:07:52 AM »
syntax is a pita
Re: Stop/Reset scripts with and without Gcode
« Reply #3 on: January 29, 2017, 04:50:37 AM »
Hi Guys,
you're right, mc.mcCntlSetLastError() requires 'inst' as argument.

Other thing I found was:
mcScriptExecute() rather than mcCntrlGodeExecutWait() means that the m5 script does not have to compete with a running Gcode job.

Thanks again
Craig


            
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'