User Tools

Site Tools


plc:software_plc_examples

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
plc:software_plc_examples [2018/09/24 21:10] skirillovplc:software_plc_examples [2019/07/12 09:26] ivan
Line 1: Line 1:
 ==== Software PLC examples ==== ==== Software PLC examples ====
  
-[[How to add mandatory Homing after Emergency Button and-or Servo ready alarm]] +  * [[How to add mandatory Homing after Emergency Button and-or Servo ready alarm]] 
-[[Button to toggle select output pin with indication]] +  [[Button to toggle select output pin with indication]] 
-[[Oil Change counter]] +  [[Oil Change counter]] 
-[[Controller Peripherals Test - BV17]] +  [[Controller Peripherals Test - BV17]] 
-[[plc:Charge Pump]]+  [[plc:Charge Pump]]
  
 === Endless loop for G-code program === === Endless loop for G-code program ===
Line 100: Line 100:
     if (ymax>MAX_Y){ left_right=0;};     if (ymax>MAX_Y){ left_right=0;};
  
-    gvarset(502,left_right); //502 - показывает обе стороны или одна+    gvarset(502,left_right); //502 - shows both sides or single side
     LR=gvarget(500);     LR=gvarget(500);
  
-    if (LR==0) //левая+    if (LR==0) //left
      {      {
-//       gvarset(9100,1); //показать сообщение №+//       gvarset(9100,1); //show message #
-       //do{ a=portget(11); }while(a==0); //ждем педаль, 11 вход +       //do{ a=portget(11); }while(a==0); //press pedalport 11 
-       //do{ a=gvarget(6065); }while(a!=0); //ждем педаль, 11 вход +       //do{ a=gvarget(6065); }while(a!=0); //press pedalport 11 
-//       gvarset(9100,0);  //убрать сообщение+//       gvarset(9100,0);  //clear the message
  
        portclr(10);//Vacuum Left OFF        portclr(10);//Vacuum Left OFF
Line 116: Line 116:
        portset(22);//        portset(22);//
  
-//       gvarset(9101,1); //показать сообщение №+//       gvarset(9101,1); //show message #
-       //do{ a=portget(13); }while(a==0); //ждем педаль, 13 вход+       //do{ a=portget(13); }while(a==0); //press pedalport 13
 //       gvarset(9101,0); //убрать //       gvarset(9101,0); //убрать
  
        portset(10);//Vacuum Left        portset(10);//Vacuum Left
        portclr(9); //        portclr(9); //
-       timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек пока присоски сработают+       timer=5; do{ timer--; }while(timer>0); //wait 0.5 seconds while the vacuum is working
  
        portclr(11);//выключить упоры        portclr(11);//выключить упоры
Line 129: Line 129:
 //// ////
 //ждать пока УП завершится //ждать пока УП завершится
-       do{ a=gvarget(6065); }while(a!=0); //ждем+       do{ a=gvarget(6065); }while(a!=0); //wait
 //// ////
  
  
 do { do {
-      do{ a=gvarget(6065); }while(a!=0); //ждем готовности системы+      do{ a=gvarget(6065); }while(a!=0); //wait for the system to be ready
       gvarset(100010,54); //Дать код G54       gvarset(100010,54); //Дать код G54
-      timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек пока сменится система +      timer=5; do{ timer--; }while(timer>0); //wait 0.5s for the system to switch 
- n=gvarget(5220);//получить текущий номер системы координат + n=gvarget(5220);//gets the current coordinate system number 
- } while(n!=1); //пока текущая система не G54+ } while(n!=1); //while the current system is not G54
  
-       do{ a=gvarget(6065); }while(a!=0); //ждем готовности системы +       do{ a=gvarget(6065); }while(a!=0); //wait for the system to be ready 
-       gvarset(100001,1); //сбросить программу в начало +       gvarset(100001,1); //go to the beginning of the program 
-       timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек +       timer=5; do{ timer--; }while(timer>0); //wait 0.5s 
-       do{ a=gvarget(6065); }while(a!=0); //ждем готовности системы +       do{ a=gvarget(6065); }while(a!=0); //wait for the system to be ready 
-       gvarset(100002,1); //запустить программу +       gvarset(100002,1); //start the program 
- +    }else //right 
-    }else //правая+
     {     {
-//       gvarset(9110,1); //показать сообщение №+//       gvarset(9110,1); //show message #
-//       do{ a=portget(12); }while(a==0); //ждем педаль, 11 вход +//       do{ a=portget(12); }while(a==0); //press pedalport 11 
-//       gvarset(9110,0);  //убрать сообщение+//       gvarset(9110,0);  //clear the message
  
        portclr(15); //Vacuum Left OFF        portclr(15); //Vacuum Left OFF
Line 158: Line 157:
        portset(23); //        portset(23); //
  
-//       gvarset(9111,1); //показать сообщение №+//       gvarset(9111,1); //show message #
-//       do{ a=portget(14); }while(a==0); //ждем педаль, 13 вход +//       do{ a=portget(14); }while(a==0); //press pedalport 13 
-//       gvarset(9111,0); //убрать+//       gvarset(9111,0); //clear
  
        portset(15); //Vacuum Left        portset(15); //Vacuum Left
        portclr(16); //        portclr(16); //
-       timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек пока присоски сработают+       timer=5; do{ timer--; }while(timer>0); //wait 0.5 seconds while the vacuum is working
  
-       portclr(14);//выключить упоры+       portclr(14);//
        portclr(23);//        portclr(23);//
  
 //// ////
-       do{ a=gvarget(6065); }while(a!=0); //ждем +       do{ a=gvarget(6065); }while(a!=0); //wait 
-//ждать пока УП завершится+//wait until the control program is finished
 //// ////
  
 do{ do{
-      do{ a=gvarget(6065); }while(a!=0); //ждем готовности системы +      do{ a=gvarget(6065); }while(a!=0); //wait until the program is ready 
- gvarset(100010,55); //Дать код G54 + gvarset(100010,55); //assigns G54 coordinate system 
-      timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек пока сработает смена координат +      timer=5; do{ timer--; }while(timer>0); //wait 0.5 seconds while the coordinate system switch is happening 
- n=gvarget(5220);//получить текущий номер системы координат + n=gvarget(5220);//obtain the current coordinate system number 
-} while(n!=2);//пока текущая система не G55+} while(n!=2);//while the system is not G55
  
-       do{ a=gvarget(6065); }while(a!=0); //ждем пока процессор занят +       do{ a=gvarget(6065); }while(a!=0); //wait while the processor is busy 
-       gvarset(100001,1); //сбросить программу в начало +       gvarset(100001,1); //return to the beginning of the program 
-       timer=5; do{ timer--; }while(timer>0); //ждем 0.5 сек  +       timer=5; do{ timer--; }while(timer>0); //wait 0.5 seconds 
-       do{ a=gvarget(6065); }while(a!=0); //ждем готовности системы +       do{ a=gvarget(6065); }while(a!=0); //wait for the system to be ready 
-       gvarset(100002,1); //запустить программу+       gvarset(100002,1); //start the program
  
     };     };
  
-       timer=20; do{ timer--; }while(timer>0); //пауза на сек, что программа стартовала +       timer=20; do{ timer--; }while(timer>0); //second pause 
-       do{ a=gvarget(6065); }while(a!=0); //ждем пока завершится программа+       do{ a=gvarget(6065); }while(a!=0); //wait until the program is complete
  
- LR=LR^1; //переключить на другую сторону+ LR=LR^1; //switch to the other side
     gvarset(500,LR);     gvarset(500,LR);
  
plc/software_plc_examples.txt · Last modified: 2022/03/29 15:55 by ivan

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki