Hello Guest it is April 16, 2024, 03:23:51 PM

Author Topic: TouchOff Module Error... need help  (Read 1203 times)

0 Members and 1 Guest are viewing this topic.

TouchOff Module Error... need help
« on: January 15, 2019, 04:36:33 PM »
Trying to use the TOUCH Button on the Mach4Router profile to set my z to zero...everytime I run it I wind up with a Lua Error.  History shows the following:

Z axis is performing a touch move
Z Axis Offset set to -2.4219749779216
Retracting
Touch is finished. Z Axis set to -2.4219749779216
Lua: Error while running ChunkC:\Mach4Hoby/Modules/mcTouchOff.lua:1178:attempt to compare nil with numberstack traceback:C:\Mach4Hoby/Modules/mcTouchOff.lua:1178:in function 'frameMainOnUpdateUI' C:\Mach4Hoby/Modules/mcTouchOff.lua:912:in Function<C:\Mach4Hoby/Modules/mcTouchOff.lua:911>

I have set the fields in the Touch Module Screen but have not modified the TouchOff module code in any way.

Any help appreciated...
Thanks
Hit the e-stop! Hit the e-stop!
Re: TouchOff Module Error... need help
« Reply #1 on: January 19, 2019, 08:45:28 AM »
Hello,
What version of Mach4 are you running?  I experienced various errors and crashes when using the Touch routine in Dev version 4006 but they seem to have been fixed in version 4026.  I do not have any experience using Touch in the GA version.

Jamie
Re: TouchOff Module Error... need help
« Reply #2 on: January 19, 2019, 03:28:31 PM »
I'm getting the same error. Touch off works normal for everything except I get the same error message.

I'm running version 3804
« Last Edit: January 19, 2019, 03:33:31 PM by Soxfan963 »
Re: TouchOff Module Error... need help
« Reply #3 on: January 19, 2019, 03:31:36 PM »
I'm getting the same error. Touch off works normal for everything except I get the same error message.

I'm running version 3804
« Last Edit: January 19, 2019, 03:35:08 PM by Soxfan963 »
Re: TouchOff Module Error... need help
« Reply #4 on: January 19, 2019, 04:32:08 PM »
Hi,
I am using 3804 and without that difficulty.

Do you wish to raise a Support Ticket with NFS or do you want to try to understand and fix it yourself?

The diagnostic error message narrows down where you have to look.

Open the Zero Brane Editor and navigate to the Mach4Hobby\Modules\mcTouchOff.lua.

This is the code that occurs at line 911 through 915:

Code: [Select]
UI.frameMain:Connect( wx.wxEVT_UPDATE_UI, function(event)
frameMainOnUpdateUI()

event:Skip()
end )

So exactly as the diagnostic suggests the error occurs in the function frameMainOnUpdateUI().
That function is defined in lines 1158 through 1188 and I have copied it here:

Code: [Select]
function frameMainOnUpdateUI()

mcState, rc = mc.mcCntlGetState(inst)
if (co ~= nil) and (mcState == 0) then
local state = coroutine.status(co)
if state == "suspended" then --We are about to run some more code so check to see if we have to check the probe state
local IsOk = true;
if ( m_CheckProbe == true) then --The probe should be active at the end of the move
IsOk = CheckProbe(1)
else
IsOk = CheckProbe(0) --The probe should NOT be active at the end of the move
end
if ( IsOk == false ) then --If the check failed lets kill the Coroutine
co = nil
IsOk = true
else
coerrorcheck, rc, m_CheckProbe = coroutine.resume(co)
if(coerrorcheck == false) then --Something happened here to the coroutine so kill it
co = nil
end
if(rc < 0) then --Something happened in the Gcode and we have an error So Kill the coroutine
co = nil
end
end
end

if state == "dead" then --Kill the coroutine
co = nil
end
end

The line that faults, 1178, is copied here:

Code: [Select]
if(rc < 0) then --Something happened in the Gcode and we have an error So Kill the coroutine
The error message ':attempt to compare nil with numberstack ' tells me that it looks like the variable rc is nil, ergo comparing
a nil with a number results in an error. Reading the few lines previous to find the current vale of rc:

Code: [Select]
coerrorcheck, rc, m_CheckProbe = coroutine.resume(co)
if(coerrorcheck == false) then --Something happened here to the coroutine so kill it
co = nil
end
if(rc < 0) then --Something happened in the Gcode and we have an error So Kill the coroutine

Thus rc is assigned a value when this expression is evaluated:
Code: [Select]
coerrorcheck, rc, m_CheckProbe = coroutine.resume(co)
What I would like to suggest is to put a wxMessageBox diagnostic report statement immediately after the faulty expression
to establish if the assignment of rc is indeed of type nil.

I would therefore edit the mcTouchOff.lua file with this statement:

Code: [Select]
wx.wxMessageBox(" rc="..tostring(rc)) immediately after line 1178.

Run the code and see if the wxMessageBox indicates the value of rc, whether it be nil or otherwise.

This would not solve the problem but it would give you a way of digging in to find out why.

Craig

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