Hello Guest it is November 14, 2019, 12:59:47 AM

Author Topic: switch an output when G31 (probing) is active  (Read 266 times)

0 Members and 1 Guest are viewing this topic.

switch an output when G31 (probing) is active
« on: April 20, 2019, 04:21:12 PM »
I am looking for a way (in LUA script) to switch an output when G31 (probing) is active.

I looked into the API documentation but found no function where can query the status.

I have read the gcode variables / parameters but also found nothing.
local value = mc.mcCntlGetPoundVar (num inst, num PoundVar)
local Gvalue = mc.mcCntlGetPoundVar (inst, 10) -- G
Gvalue: 1.456e-14
local Gvalue = mc.mcCntlGetPoundVar (inst, 10) -- MOD GROUP 1 4001 // Group 1 // active G-code for motion
Gvalue: 1.0 on G1, G31 movements,

I do not know what the output digitize trigger does. So I searched at google and found this page: https://warp9td.com/index.php/faq/faq-mach4
"Digitize Trigger:  This output activates when the Probe is active with a G31/G31.x command."
I tried but there dont switches state on G31. it seems to be for SmoothStepper.
Re: switch an output when G31 (probing) is active
« Reply #1 on: April 21, 2019, 12:45:36 PM »
You could try monitoring the state of the control using mcCntlGetState for when it is probing. 102 is File:Run:Probe and 202 is MDI:Run:Probe. You can then activate the output when it is either of these states.
Re: switch an output when G31 (probing) is active
« Reply #2 on: April 21, 2019, 01:41:05 PM »
I assume that you want to generate, say, a logic "1" when the probe input is active (i.e. the probe is touching).  Why do this in a script, why not just use the probe logic level?
Re: switch an output when G31 (probing) is active
« Reply #3 on: April 23, 2019, 03:44:23 PM »
You could try monitoring the state of the control using mcCntlGetState for when it is probing. 102 is File:Run:Probe and 202 is MDI:Run:Probe. You can then activate the output when it is either of these states.

that's exactly what I was looking for, thank you buddy.
Re: switch an output when G31 (probing) is active
« Reply #4 on: May 01, 2019, 08:20:23 AM »
if anyone is interested and needs:

Code: [Select]
local inst = mc.mcGetInstance()
local i = 0;
while true do
local name = mc.mcCntlGetStateName(inst, i);
mc.mcCntlSetLastError(inst, "machState: "..tostring(i).." - "..tostring(name))
i = i +1;
if i > 300 then
break;
end;
end;


available mach states (machState, rc = mc.mcCntlGetState(inst);):

machState: 0 - Idle
machState: 1 - Hold
machState: 2 - File:Subroutine
machState: 3 - MDI:Subroutine
machState: 4 - Jogging
machState: 5 - Dry Run
machState: 6 - Homing
machState: 7 - Config
machState: 100 - File:Run
machState: 101 - File:Run:Feed Hold
machState: 102 - File:Run:Probe
machState: 103 - File:Run:Probe:Feed Hold
machState: 104 - File:Run:Threading
machState: 105 - File:Run:Threading:Feed Hold
machState: 106 - File:Run:Feed Hold:Jog
machState: 107 - File:Run:Tapping
machState: 108 - File:Run:Macro Hold
machState: 109 - File:Run:Macro Hold:Jog
machState: 110 - File:Run:Single Block
machState: 111 - File:Run:Retract
machState: 112 - File:Run:Homing
machState: 113 - File:Run:Single Block Hold
machState: 199 - File:Run:Ending
machState: 200 - MDI:Run
machState: 201 - MDI:Run:Feed Hold
machState: 202 - MDI:Run:Probe
machState: 203 - MDI:Run:Probe:Feed Hold
machState: 204 - MDI:Run:Threading
machState: 205 - MDI:Run:Threading:Feed Hold
machState: 206 - MDI:Run:Tapping
machState: 207 - MDI:Run:Macro Hold
machState: 208 - MDI:Run:Macro Hold:Jog
machState: 209 - MDI:Run:Retract

Offline Chaoticone

*
  • *
  •  5,628 5,628
  • Precision Chaos
    • View Profile
Re: switch an output when G31 (probing) is active
« Reply #5 on: May 03, 2019, 06:40:46 PM »
Check the state and store in a variable. Then send message only if it and current state ~=

Stay away from loops when possible and don't spam the core (with 300 unnecessary messages).
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!