Hello Guest it is April 19, 2024, 04:02:22 PM

Author Topic: edit Cyclestop in screen  (Read 4927 times)

0 Members and 1 Guest are viewing this topic.

Re: edit Cyclestop in screen
« Reply #10 on: April 22, 2019, 03:29:40 AM »
Hi,
well you got an interesting problem there.

Quote
C]: in function 'mcCntlSetLastError'
   C:\Mach4Hobby\ScreenScript.lua:689: in function <C:\Mach4Hobby\ScreenScript.lua:684>

This is good info, this is where the ***.lua script (recall, is the combination of ALL Lua scripts in Mach) shows its value.
Open the script and scan down to the line 684 and then you can start to diagnose the fault. Note that to fix
the fault, say bad syntax, you will have to go and find the script which is responsible for its inclusion in the ***.lua
script, say the screen load script or whatever.

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

Offline jbuehn

*
  •  101 101
    • View Profile
Re: edit Cyclestop in screen
« Reply #11 on: April 22, 2019, 11:39:29 AM »
C:\Mach4Hobby\ScreenScript.lua:689: wxLua: Expected a 'string' or 'wxString' for parameter 2, but got a 'no value'.
Function called: 'mcCntlSetLastError(string)'
01. mcCntlSetLastError(number, string)

From this part of the error message, you have an mc.mcCntlSetLastError API call but are only use a single parameter (string). It requires two (number, string). These are all listed in the API docs. For mc.mcCntlSetLastError it needs the instance for 'number' and your desired error message for 'string'.

As Craig said, you can use the line number to find where the error is in the screen script.
« Last Edit: April 22, 2019, 11:46:00 AM by jbuehn »
Re: edit Cyclestop in screen
« Reply #12 on: April 22, 2019, 11:14:43 PM »
Well I have fixed the errors  I now get no errors  but the cyclestop function does not work how I want it to
I changed the error message return so  am sure the  function is being run through in the program
But I want to retract the tool and send the machine to machine home as well as turn of the coolant but  it just seems to ignore the Gcode commands
Here is a copy of the function you can see the "Cycle Sxxstopped" i change this so i can tell the function is actually run

function CycleStop()
    mc.mcCntlCycleStop(inst);
    mc.mcSpindleSetDirection(inst, 0);
   mc.mcCntlGcodeExecute(inst, "G90  G53 Z0 Y0");

     mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z0")
    mc.mcCntlGcodeExecuteWait(inst, "G90 G0 G54 X0 Y0" )
     mc.mcCntlSetLastError(inst, "Cycle Sxxstopped");
end
Re: edit Cyclestop in screen
« Reply #13 on: April 23, 2019, 03:18:19 AM »
Hi,
you need to put the:
mc.mcCntlCycleStop(inst);
last thing. You have it near the top, so Mach encounters a Cycle Stop command , so it does and all subsequent
statements are ignored.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: edit Cyclestop in screen
« Reply #14 on: April 23, 2019, 05:19:55 AM »
Hi
I already  tried that and still no joy  I assumed that mc.mcCntlCycleStop(inst); would stop all Gcode running so put it at the bottom  I tried both the
 mc.mcCntlGcodeExecute(inst, "G90  G53 Z0 Y0");

     mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z0")
I am a bit stuck  it seems to me it should work
Regards Ray
Re: edit Cyclestop in screen
« Reply #15 on: April 23, 2019, 05:25:45 AM »
Hi,
what motion mode was active prior to:

 mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z0")

If there is any doubt I would include a g0:

 mc.mcCntlGcodeExecuteWait(inst, "g90 g53  g0 z0")

Note I deliberately reduced to lowercase all the 'g's' etc.....Machs Gcode interpreter reduces all uppercase to lowercase, strips
out leading zeros and whitespace. Despite being somewhat less readable you will have fewer error if you follow Mach's
interpreter.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: edit Cyclestop in screen
« Reply #16 on: April 23, 2019, 05:34:49 AM »
I assume a G1 feed mode  would have been activated 
I have had a couple of program lock ups when fiddling around with order of things in  the cyclestop function
I will have another play tomorrow but I also tried  a M9 to just stop the coolant and that did not work either
Regards Ray
Re: edit Cyclestop in screen
« Reply #17 on: April 23, 2019, 05:41:23 AM »
Hi,
that's 'm9' not M9.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: edit Cyclestop in screen
« Reply #18 on: April 23, 2019, 10:34:49 PM »
Well if I put the command above the cyclestop  it executes the command but locks the screen up  it actualy keeps running and reverts back to running the gcode program  but the screen fades no readouts work and the screen is locked up
Mach4 can then only be stopped with widows task manager

with commands below the cyclestop   the program stops and no commands work I put in the reset command before the  cgode I wanted to run but it does a reset and then just runs the original program again so the reset command after cycle stop works  it is almost like i need to do a cycle start  I tried that but it restarts the program again

It seems to me i need to reactivate the program in some way after a cyclestop so that a gcode commands will work  like in the MDI

I looked at using the retract comand to stop and do what I want
This command I  do not  understand how it works it stops the spindle retracts and goes to machine home but the scrip for it just looks to me to have a signal state altered I can not see where these other command are coming form
Regards Ray
Re: edit Cyclestop in screen
« Reply #19 on: April 24, 2019, 03:03:14 AM »
Hi,
you are not testing return codes and will therefore struggle to make sense of it.

Take for example:
Quote
LUA Syntax:
rc = mc.mcCntlGcodeExecute(
      number mInst,
      string commands)

Description:
Execute G code as a unit of work and wait until it is complete.

Parameters: Parameter Description
mInst The controller instance.
commands A string buffer containing G code.


Returns: Return Code Description
MERROR_NOERROR No Error.
MERROR_INVALID_INSTANCE The mInst parameter was out of range.
MERROR_NOT_NOW The operation could not be completed at this time.
MERROR_NOT_COMPILED The macro scripts could not be compiled.

Note in particular MERROR_NOT_NOW which is a common error when attempting to use this API. You need to test for
it otherwise the code could fail and you would have no idea when or how or why it failed.

Try this for example:

local rc=mc.mcCntlGcodeExecuteWait(inst, "G90 G53 Z0")
if rc==mc.MERROR_NOT_NOW then
      wx.wxMessageBox( "Houston....we have a problem")
end

At least now if the API did not proceed you will know when and probably why.

Smurph recommends EVERY API return code be testedI'm lazy and don't do it as much as I should but after many
frustrating hours trying to debug code I'm getting better at it.

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