PLC Includes for X1366P
The PLC Includes files allow to systematize and share values and functions among the Hardware and Software PLC procedures within your profile. The below list includes information for the default version of the myCNC X1366P Plasma Cutting profile. The information may differ between profiles, as well as different versions of profiles, and should be used as a general reference only.
A list of G-codes within myCNC software is provided here for reference: G-Codes list
File - pins.h
Defines hardware inputs and outputs (refered to via names, such as OUTPUT_MARKER, INPUT_ARC, etc).
NOTE: The pins.h file is present both in the Hardware and Software PLC tabs within your Settings. On Linux systems, the pins.h labels create a link to a single file - when the values are changed in either the Software or the Hardware tab, they also automatically change in the other upon program reload. This implementation does not work under Windows, therefore the programmer must monitor the synchronization on their own and update the values in both files in order for the changes to take effect correctly.
File - func_plasma.h
Contains plasma cuttings functions (typically related to THC, THC triggers, etc)
Included in: M02 End Program, M45 Start Plasma Marking, M71 Start Cutting, M74 Stop Cutting, M271, M272, OFF
start_thc()
Show code
start_thc()
{
if (thc_enabled!=0) //start THC control
{
gvarset(7570,thc_avc_start); //THC #0 ON
timer=3;do{timer--;}while(timer>0);
};
};
Included in: M45, M71, M271
stop_thc()
Show code
stop_thc()
{
gvarset(7570,0); //THC #0 ON
timer=3;do{timer--;}while(timer>0);
};
Included in: M02, M74, M271, OFF (inactive),
stop_trigger1()
Show code
stop_trigger1()
{
//stop watching for plasma sensor
message=PLCCMD_TRIGGER1_OFF;
timer=3;do{timer--;}while(timer>0);
};
Included in: M02, M74, M271, OFF (inactive),
stop_trigger2()
Show code
stop_trigger2()
{
//stop watching for plasma sensor
message=PLCCMD_TRIGGER2_OFF;
timer=3;do{timer--;}while(timer>0);
};
Included in: currently not utilized in any hardware PLCs by default
start_trigger1()
Show code
start_trigger1()
{
//stop watching for plasma sensor
message=PLCCMD_TRIGGER1_ON;
timer=3;do{timer--;}while(timer>0);
};
Included in: M71, M271
start_trigger2()
Show code
start_trigger2()
{
//stop watching for plasma sensor
message=PLCCMD_TRIGGER2_ON;
timer=3;do{timer--;}while(timer>0);
};
Included in: M02, M74 (inactive), M271 (inactive)
do_wait_pierce()
Show code
do_wait_pierce()
{
timer=ihc_pierce_time;do{timer--;}while(timer>0);
};
Included in: M71, M271
do_wait_plasma()
Show code
do_wait_plasma()
{
timer=timeout_plasma_ready; //wait till plasma arc ready
do
{
timer--;
a=portget(INPUT_ARC);
if (a!=0) { timer=0; };
}while(timer>0); //pause
a=portget(INPUT_ARC); //doublecheck arc sensor
if (a==0)
{
message=PLCCMD_TRIGGER2_ON;
timer=3;do{timer--;}while(timer>0);
portclr(OUTPUT_PLASMA);
exit(plc_exit_plasma_fail);
};
};
Included in: M45, M71, M271
test_lift_after_cut()
Show code
test_lift_after_cut()
{
if (proc==plc_proc_moveup) //if already moving-up - stop & exit
{
message=PLCCMD_LINE_STOP; //PLCCMD_LINE_SOFT_STOP;//skip line
do
{
timer++;
ready=0;
code=gvarget(6060);
if (code==0x57) { ready=1; };//'W' WAIT
if (code==0x4d) { ready=1; };//'M' M-code
}while(ready==0);
proc=plc_proc_idle;
//start_trigger2();
exit(99);
};
};
Included in: M02, M74
do_lift_after_cut()
Show code
do_lift_after_cut()
{
need_lift=1;
if (proc!=plc_proc_plasma) { need_lift=0; };
if (ihc_lift_after_cut<1) { need_lift=0; };
code=gvarget(6060);
if (code!=0x4d) { need_lift=0; };
if (need_lift!=0)
{
proc=plc_proc_moveup;
speedz=gvarget(7043);//Rapid Speed Z
gvarset(7080,speedz);
g0moveA(0x0,0x4,ihc_lift_after_cut); //Z axis
timer=200;do{timer--;}while(timer>0);
do
{
ready=0;
code=gvarget(6060);
if (code==0x57) { ready=1; }; //'W' WAIT
if (code==0x4d) { ready=1; }; //'M' M-code
//a=portget(INPUT_HOME_Z);
//if (a==0)
//{
// ready=1;
// message=PLCCMD_LINE_STOP; //PLCCMD_LINE_SOFT_STOP;//skip line
// timer=10;do{timer--;}while(timer>0);
//}; //Home Z zensor (top position)
}while(ready==0);
};
};
Included in: M02, M74
File - func.h
General functions (currently contains timeout codes).
Included in: M89, M90, M162
timeout_10ms()
Show code
timeout_10ms()
{
timer=10; do { timer--;}while(timer>0);
};
Included in: currently not utilized in any hardware PLCs by default
timeout_2ms()
Show code
#define timeout_2ms(); texit=timer+2;do{timer++;}while(timer<texit);
Included in: M90
File - func_m7.h
do_move_marking_height()
Show code
do_move_marking_height()
{
speedz=gvarget(7043);
gvarset(7080,speedz); //Set speed;
if (var_marking_height>5)
{
g0moveA(0x0,0x4,var_marking_height);//Z axis, ignition_height
timer=200;do{timer--;}while(timer>0);//wait till motion started
do { code=gvarget(6060); }while(code!=0x4d);//wait till motion finished
};
};
Included in: M07
do_marking_probe()
Show code
do_marking_probe()
{
gvarset(7080,var_marking_probe_speed);//set speed;
timer=5;do{timer--;}while(timer>0);
//message=PLCCMD_TRIGGER2_OFF;
//timer=5;do{timer--;}while(timer>0);
//portset(OUTPUT_PROBE);
sens=portget(INPUT_IHC);
if (sens==0)
{
g0moveA(0x0,0x4,0-30000);//Z axis,
timer=200; do{timer--;}while(timer>0);//wait till motion started
do
{
code=gvarget(6060);
sens=portget(INPUT_IHC);
if (sens!=0)
{
code=1;
message=PLCCMD_LINE_STOP;//skip line
};
}while (code==0);
do { code=gvarget(6060); }while(code!=0x4d);//wait till motion finished
};
//portclr(OUTPUT_PROBE);
};
Included in: M07
File - vars.h
Defines variables within the M-codes.
Included in: M02, M07, M08, M45, M46, M71, M72, M73, M74, M78, M195, M271, M272, TRIG01, EST, OFF
File - wait.h
“Waiting” functions - used to wait till motion finished.
Included in: currently not utilized in any hardware PLCs by default
wait4wait()
Show code
wait4wait()
{
do
{
timer++;code=gvarget(6060);
loop=1;
if (code==0x4d){loop=0;};
if (code==0x57){loop=0;};
a=portget(4);
if (a==0) { loop=0; };
}while(loop==1); //wait till motion finished
};
Included in: currently not utilized in any hardware PLCs by default
test_lift_after_cut()
Show code
test_lift_after_cut()
{
if (proc==plc_proc_moveup) //if already moving-up - stop & exit
{
message=PLCCMD_LINE_STOP; //PLCCMD_LINE_SOFT_STOP;//skip line
do
{
timer++;
ready=0;
code=gvarget(6060);
if (code==0x57) { ready=1; }; //'W' WAIT
if (code==0x4d) { ready=1; }; //'M' M-code
}while(ready==0);
proc=plc_proc_idle;
start_trigger2();
exit(99);
};
};
Included in: currently not utilized in any hardware PLCs by default (code in func_plasma.h utilized instead, code block planned to be removed in the upcoming updates).
File - func_ihc.h
Initial Height Control functions.
Included in: M45, M71, M271, M272
do_plasma_probe()
Show code
do_plasma_probe()
{
gvarset(7080,ihc_probing_speed);//set speed;
timer=5;do{timer--;}while(timer>0);
if (ihc_enabled!=0)
{
message=PLCCMD_TRIGGER2_OFF;
timer=5;do{timer--;}while(timer>0);
portset(OUTPUT_PROBE);
timer=200; do{ timer--; }while (timer>0);
sens=portget(INPUT_IHC);
if (sens==0)
{
g0moveA(0x0,0x4,0-30000);//Z axis,
timer=200; do{timer--;}while(timer>0);//wait till motion started
do
{
code=gvarget(6060);
sens=portget(INPUT_IHC);
if (sens!=0)
{
code=1;
message=PLCCMD_LINE_STOP;//skip line
};
}while (code==0);
do { code=gvarget(6060); }while(code!=0x4d);//wait till motion finished
};
};
portclr(OUTPUT_PROBE);
};
Included in: M45, M71, M271, M272
do_move_ignition_height()
Show code
do_move_ignition_height()
{
speedz=gvarget(7043);
gvarset(7080,speedz); //Set speed;
if (ihc_enabled!=0)
{
ihc_current_height=ihc_correction_height+ihc_ignition_height;
if (ihc_current_height>5)
{
g0moveA(0x0,0x4,ihc_current_height);//Z axis, ignition_height
timer=200;do{timer--;}while(timer>0);//wait till motion started
do { code=gvarget(6060); }while(code!=0x4d);//wait till motion finished
};
};
};
Included in: M45, M71, M271, M272
do_move_pierce_height()
Show code
do_move_pierce_height()
{
ihc_current_height=ihc_pierce_height-ihc_ignition_height;
if (ihc_current_height>5)
{
g0moveA(0x0,0x4,ihc_current_height);//Z axis, pierce_height
timer=200;do{timer--;}while(timer>0);//wait till motion started
do { code=gvarget(6060); }while(code!=0x4d);//wait till motion finished
};
};
Included in: M71, M271
do_move_cutting_height()
Show code
do_move_cutting_height()
{
ihc_current_height=ihc_cutting_height-ihc_pierce_height;
if (ihc_current_height!=0)
{
g0moveA(0x0,0x4,ihc_current_height); //Z axis, cutting_height
timer=200;do{timer--;}while(timer>0); //wait till motion started
do { code=gvarget(6060); }while(code!=0x4d); //wait till motion finished
};
};
Included in: M45, M71, M271