Re: Разбираемся в софте контроллеров mycnc
Добавлено: 14 фев 2018, 22:11
М03:
//Turn on Spindle clockwise
//set Spindle speed through DAC channel
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_CCW_SPINDLE
//OUTPUT_SPINDLE
//SPINDLE_ON_DELAY
//*****************************************************
#include common.const.h
#include pins.h
#include vars.h
main()
{
timer=0;
proc=plc_proc_spindle;
val=eparam;
if (val>0xfff) {val=0xfff;};
if (val<0) {val=0;};
dac01=val;
portclr(OUTPUT_CCW_SPINDLE);
portset(OUTPUT_SPINDLE);
command=PLC_MESSAGE_SPINDLE_SPEED_CHANGED;
parameter=eparam;
message=PLCCMD_REPLY_TO_MYCNC;
timeout=timer+10;do{timer++;}while (timer<timeout);
//pause to push the message with Spindle Speed data
//delay after spindle started
timeout=timer+spindle_on_delay;
do{timer++;}while (timer<timeout); //delay for Spindle reach given speed
gvarset(7370,1);
gvarset(7371,eparam);
exit(99); //normal exit
};
М08:
#include common.const.h
#include pins.h
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_FLOOD
//*****************************************************
main()
{
gvarset(7372,1);
portset(OUTPUT_FLOOD);
exit(99); //normal exit
};
М07:
#include common.const.h
#include pins.h
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_MIST
//*****************************************************
main()
{
gvarset(7373,1);
portset(OUTPUT_MIST);
exit(99); //normal exit
};
Часть кода cnc-screen.xml, отвечающая за кнопки М03-М09:
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;0" width="80" height="80" image="button-m03" action="plc-run:M03/#5524" type="xbutton"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;80" width="80" height="80" image="button-m04" action="plc-run:M04/#5524" type="xbutton"/>
<gitem where="magic" position="1200;160" width="80" height="80" image="button-m05" action="plc-run:M05/0" type="button"/>
<gitem where="magic" position="1200;240" width="80" height="80" image="button-m06" action="run-numpad:direct-run:M06 T%v" type="button"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;320" width="80" height="80" image="button-m07" action="plc-run:M07/0" type="xbutton"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;400" width="80" height="80" image="button-m08" action="plc-run:M08/0" type="xbutton"/>
<gitem where="magic" position="1200;480" width="80" height="80" image="button-m09" action="plc-run:M09/0" type="button"/>
//Turn on Spindle clockwise
//set Spindle speed through DAC channel
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_CCW_SPINDLE
//OUTPUT_SPINDLE
//SPINDLE_ON_DELAY
//*****************************************************
#include common.const.h
#include pins.h
#include vars.h
main()
{
timer=0;
proc=plc_proc_spindle;
val=eparam;
if (val>0xfff) {val=0xfff;};
if (val<0) {val=0;};
dac01=val;
portclr(OUTPUT_CCW_SPINDLE);
portset(OUTPUT_SPINDLE);
command=PLC_MESSAGE_SPINDLE_SPEED_CHANGED;
parameter=eparam;
message=PLCCMD_REPLY_TO_MYCNC;
timeout=timer+10;do{timer++;}while (timer<timeout);
//pause to push the message with Spindle Speed data
//delay after spindle started
timeout=timer+spindle_on_delay;
do{timer++;}while (timer<timeout); //delay for Spindle reach given speed
gvarset(7370,1);
gvarset(7371,eparam);
exit(99); //normal exit
};
М08:
#include common.const.h
#include pins.h
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_FLOOD
//*****************************************************
main()
{
gvarset(7372,1);
portset(OUTPUT_FLOOD);
exit(99); //normal exit
};
М07:
#include common.const.h
#include pins.h
//*****************************************************
//The following variables Should be defined outside
//OUTPUT_MIST
//*****************************************************
main()
{
gvarset(7373,1);
portset(OUTPUT_MIST);
exit(99); //normal exit
};
Часть кода cnc-screen.xml, отвечающая за кнопки М03-М09:
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;0" width="80" height="80" image="button-m03" action="plc-run:M03/#5524" type="xbutton"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;80" width="80" height="80" image="button-m04" action="plc-run:M04/#5524" type="xbutton"/>
<gitem where="magic" position="1200;160" width="80" height="80" image="button-m05" action="plc-run:M05/0" type="button"/>
<gitem where="magic" position="1200;240" width="80" height="80" image="button-m06" action="run-numpad:direct-run:M06 T%v" type="button"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;320" width="80" height="80" image="button-m07" action="plc-run:M07/0" type="xbutton"/>
<gitem where="magic" xattr="60;4;16;16;led;red;round" address="outputs" number="0" position="1200;400" width="80" height="80" image="button-m08" action="plc-run:M08/0" type="xbutton"/>
<gitem where="magic" position="1200;480" width="80" height="80" image="button-m09" action="plc-run:M09/0" type="button"/>