User Tools

Site Tools


mycnc:stop_end_program

This is an old revision of the document!


Stop/End program button commands

When using myCNC, the actions performed by the program when the Stop button is pressed are defined in the following files:

  • M02.plc (Settings > Config > PLC > Hardware PLC)
  • OFF.plc (Settings > Config > PLC > Hardware PLC)
  • __HANDLER_GCODE_STOP (Settings > Config > PLC > Software PLC)

The actions taken upon pressing the button differ depending on the sequence of events. If pressing ONCE, the M02.plc procedure is started (below is the M02.plc for the Plasma profile X1366P):

M02.plc
#include pins.h
#include vars.h
#include func_plasma.h
 
main()
{
  timer=0;
 
  portclr(OUTPUT_DRILL_VALVE_DOWN);
  portset(OUTPUT_DRILL_VALVE_UP);
  portclr(OUTPUT_DRILL_POWER);
 
  stop_thc();
  stop_trigger1();
 
  //turn off power source
  portclr(OUTPUT_PLASMA);
 
  portclr(OUTPUT_PROBE);
  test_lift_after_cut();
  do_lift_after_cut();
  proc=plc_proc_idle;
 
  start_trigger2();
  exit(99);
};

If the Stop button is pressed twice, the OFF.plc procedure will be utilized:

OFF.plc
#include pins.h
#include vars.h
#include func_plasma.h
 
main()
{
 
  portclr(OUTPUT_DRILL_VALVE_DOWN);
  portset(OUTPUT_DRILL_VALVE_UP);
  portclr(OUTPUT_DRILL_POWER);
 
 
  //stop_thc();
  //stop_trigger1();
 
  //turn off power source
  portclr(OUTPUT_PLASMA);
  portclr(OUTPUT_PROBE);
  //proc=plc_proc_idle;
 
  exit(99);
};

Additionally, whenever the player stops running G-code, the __HANDLER_GCODE_STOP Software PLC which is continuously running in the background will be activated. By default, the __HANDLER_GCODE_STOP simply consists of the following code:

__HANDLER_GCODE_STOP
main()
 {
  exit(99);
 };

Therefore, in a default configuration, this handler will simply activate, do nothing and then close. However, in situations where it is necessary to add a command which will activate whenever the G-code run has stopped, __HANDLER_GCODE_STOP can be used.

mycnc/stop_end_program.1572279411.txt.gz · Last modified: 2019/10/28 12:16 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki