Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: maziar on January 31, 2017, 02:06:42 AM
-
Hi
I use Mach4 and ESS SmoothStepper .
I want read state of input port and according of state, output port state set.
I define Macro in Mach4 for this job. (m101)
BUT when i call my Macro in MDI and use start cycle button, my software hang in 2 state and i force restart it :
State 1 : input port state is 1 (occur hang)
State 2 : input port state is 0 (not hang) and after that i change state of it to 1 (occur hang)
My code :
function m101()
local inst = mc.mcGetInstance();
local inputi1 = mc.mcSignalGetHandle(inst,mc.ISIG_INPUT0);
local statei1 = mc.mcSignalGetState(inputi1);
local outputi3 = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT3);
local outputi2 = mc.mcSignalGetHandle(inst,mc.OSIG_OUTPUT2);
if (statei1 == 1) then
mc.mcSignalSetState(outputi3,true);
mc.mcSignalSetState(outputi2,false);
else
mc.mcSignalSetState(outputi2,true);
mc.mcSignalSetState(outputi3,false);
end
end
if (mc.mcInEditor() == 1) then
m101()
end
Please help me for fix this problem.
-
Cannot spot any problem with the code. Maybe you can check return code "rc" of the function calls.
-
I thought we sorted this out on the warp9 forum??
DazTheGas
-
Hi DazTheGas
i send my problem for you about running Macro. my problem fix with your help.
but now when i run this code in some state Mach4 hang and not work. detail of my work is :
i have 2 state :
1. input0's state is 1
in this state when i cake Macro in MDI:
1.1 output3 and output2 set
1.2 start cycle hang and i can not run any command
1.3 i stop run Macro but after that Mach4 not run any another Macro and i force to restart software
2. input0's state is 0
in this state when i cake Macro in MDI:
1.1 output3 and output2 set
1.2 start cycle free and i can run any command
1.3 i change state of input0 to 1 and run Macro m101, again
1.4 output3 and output2 set
1.5 start cycle hang and i can not run any command
1.6 i stop run Macro but after that Mach4 not run any another Macro and i force to restart software
Please help me for fix this problem.
RGDS
-
Hi
log of Mach4 when i call my macro and change state of input port.
2017-02-02 19:05:46.846 - API: mcCntlMdiExecute() called. (m105)
2017-02-02 19:05:46.948 - Attempt transition from "Idle" on event "MDI Start" Controller.cpp:1811
2017-02-02 19:05:46.948 - Signal id 1127, (Jog Enabled), changed from HIGH to LOW.
2017-02-02 19:05:46.948 - S_IDLE_on_exit
2017-02-02 19:05:46.948 - ACTION_start_mdi
2017-02-02 19:05:46.948 - S_MDI_RUNNING_on_entry
2017-02-02 19:05:46.948 - S_MDI_RUNNING2_on_entry
2017-02-02 19:05:46.948 - Signal id 1114, (Gcode Running), changed from LOW to HIGH.
2017-02-02 19:05:46.958 - Signal id 1052, (Output #2), changed from LOW to HIGH.
2017-02-02 19:05:47.061 - Attempt transition from "MDI Running" on event "Stop" GcodeExec.cpp:1099
2017-02-02 19:05:47.061 - S_MDI_RUNNING2_on_exit
2017-02-02 19:05:47.061 - Signal id 1114, (Gcode Running), changed from HIGH to LOW.
2017-02-02 19:05:47.061 - S_MDI_RUNNING_on_exit
2017-02-02 19:05:47.061 - ACTION_stop
2017-02-02 19:05:47.081 - S_IDLE_on_entry
2017-02-02 19:05:56.739 - Signal id 1, (Input #0), changed from LOW to HIGH.
2017-02-02 19:06:00.398 - API: mcCntlMdiExecute() called. (m105)
2017-02-02 19:06:00.501 - Attempt transition from "Idle" on event "MDI Start" Controller.cpp:1811
2017-02-02 19:06:00.501 - S_IDLE_on_exit
2017-02-02 19:06:00.501 - ACTION_start_mdi
2017-02-02 19:06:00.501 - S_MDI_RUNNING_on_entry
2017-02-02 19:06:00.501 - S_MDI_RUNNING2_on_entry
2017-02-02 19:06:00.501 - Signal id 1114, (Gcode Running), changed from LOW to HIGH.
2017-02-02 19:06:00.520 - Signal id 1053, (Output #3), changed from LOW to HIGH.
2017-02-02 19:06:00.520 - Signal id 1052, (Output #2), changed from HIGH to LOW.