=== M03 Simple Spindle ON procedure === #include pins.h //include file with constant definitions main() { dac01=eparam; //set spindle speed through DAC portset(OUT_SPINDLE); //turn ON Spindle relay exit(99); //normal exit. }; * **OUT_SPINDLE** is constant defined in external include file "pins.h". #define OUT_SPINDLE 0 #define OUT_COOLANT 5 * **#define OUT_SPINDLE 0** - Spindle connected to output #0 It's good to wait some time till spindle achieve rotation speed before start moving So we add a 2 seconds delay before exit from M03 procedure. Advanced procedure may look on **Spindle Rotation** sensor or spindle encoder value to detect spindle speed is good to start. #include pins.h main() { dac01=eparam; //set spindle speed through DAC portset(OUT_SPINDLE); //turn ON Spindle relay timer=2000; //2000 msec delay fixed do{ timer--; }while (timer>0); exit(99); //normal exit. }; In this example delay value is fixed 2 seconds and operator will not be able to change it. In some cases will be better to have spindle ON delay value as parameter and provide interface for operator to change this value. To get it we need to define variable name in vars.h include file - #define spindle_on_delay var05 and change spindle delay to this variable #include pins.h #include vars.h main() { dac01=eparam; //set spindle speed through DAC portset(OUT_SPINDLE); //turn ON Spindle relay timer=spindle_on_delay; //delay <<<< variable do{ timer--; }while (timer>0); exit(99); //normal exit. }; PLC variable **var05** is value for spindle ON delay. The variable will be initialized to correct **delay value** if we add its declaration in **plc-config.xml**, section for **M03** procedure - Spindle Шпиндель 스핀들 500 Spindle On Delay,ms Время на включение шпинделя,мс Opóźnienie włączenia wrzeciona, ms 스핀들 시작지연시간,ms * **number="5"** connection XML item with **var05** PLC variable * **pname="plc-var-spindle-on-delay"** - name definition to add screen items \\(like spinbox, numpad or display) to edit variable value * **suffix="ms"** - suffiz to display value * **type="numpad"** - screen type to edit variable in **PLC Cfg** dialog * **min="0" step="250" max="5000"** min, max value range, step for valu inc/dec PLC Configuration dialog with "Spindle On Delay" is shown below {{ mycnc:mycnc-screen-plc-cfg-spindle-on-delay-001.png }} It's possible to put graphics item to any of GUI widget and connect it with XML item name to edit PLC variable value directly from GUI. Let's add item to User widget of "1280M5" profile. User Widget before is - {{ mycnc:mycnc-user-widget-0.png }} User Widget Configuration in "1280M5" profile is separated in **user-m5.xml** XML file which is included in main **cnc-screen.xml** Items setup in **user-m5.xml** is based in **Layout** subsystem. Complete screen divided to 4(5) layers: * XY * Z * A * B * (Reserved) Reserved Layer is used for plasma profile for plasma-gas specific settings (check **user-plasma.xml** configuration XML include for more details) To add new Item - - Add/Fix new layout after layout for "B" - Add Widget type **myitems** to this layout with name **"user-spindle-01"**\\ user-tab myitems myitems myitems myitems myitems myitems - Add definition for **Numpad** and connect it with XML variable with attribute **pname="plc-var-spindle-speed-on-delay"** Spindle On Delay, sec Задержка на включение шпинделя, сек. * **where="user-spindle-01"** - Parent widget name to put the item * **type="combo-numpad"** Combined type - DRO (display), button, Numpad dialog opened when button pressed to change Item Value. Item optimized to use with Touch Screen monitors. * **action="item:plc-var-spindle-on-delay"** - attach button to edit XML PLC variable with name "plc-var-spindle-on-delay" * **name="display-plc-var-spindle-on-delay"** - attach DRO/display to show XML/PLC variable value * **bgColor="#205020" fgColor="cyan"** - Background and foreground colors for Item * **displayWidth="90"** - width for DRO(display) * **height="60** - Item height * **labelWidth="130"** - Label width * **fontSize="18" fontStyle="bold"** - Font Size and Style for **DRO/display**. If **Label** font should be redefined use "labelFontSize", "labelFontStyle", "labelAlignment" attributes (Case Sensitive). * **format="%5.1f"** - C-style format for DRO * **K="0.001"** - All timings in PLC are in miliseconds. To show value in seconds can be used ratio defined in "K" attribute * **image="3dots"** - image skin for Button {{ mycnc:mycnc-user-widget-0-1.png }}