User Tools

Site Tools


plc:plc

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
plc:plc [2020/05/19 10:06]
ivan
plc:plc [2020/11/24 16:06] (current)
ivan
Line 1: Line 1:
-{{mycnc:plc:mycnc-plc-builder-001.png?600}} 
- 
- 
 ====== PLC ====== ====== PLC ======
-PLC - programmable logic controller.+PLC stands for "Programmable Logic Controller".
  
 PLC controller can load and run small binary programs (PLC procedures). PLC procedure should be written in a simplified C-like language, compiled and stored in PLC controller memory to be ready to run. myCNC software includes [[plc:plc_builder|PLC Builder]] - tiny IDE (Integrated Development Environment) to create and modify PLC procedure source files, compile them to binary code and upload it as RomFS iso image disk to PLC controller memory. PLC controller can load and run small binary programs (PLC procedures). PLC procedure should be written in a simplified C-like language, compiled and stored in PLC controller memory to be ready to run. myCNC software includes [[plc:plc_builder|PLC Builder]] - tiny IDE (Integrated Development Environment) to create and modify PLC procedure source files, compile them to binary code and upload it as RomFS iso image disk to PLC controller memory.
  
 +{{mycnc:plc:mycnc-plc-builder-001.png}}
  
 +myCNC control has 2 types of built-in PLC systems that named
 +[[#Hardware PLC]] and [[#Software PLC]]. 
  
-myCNC control has 2 types of built-in PLC systems that named¬†+Note that hardware PLC can be launched from software PLC if necessary, through the use of //gvarset(100040,HARDWAREPLC);// command (replace //HARDWAREPLC// with your M-command of choice). You can read more on the process in the Software PLC section down below. 
-[[#Hardware PLC]] and [[#Software PLC]]+
  
 ==== Hardware PLC ==== ==== Hardware PLC ====
Line 162: Line 161:
  
   * All Software PLC procedures (except "system" procedures) are compiled and started simultaneously in separate threads with myCNC software start or after "Build All" button pressed in **PLC Builder/Software PLC**.   * All Software PLC procedures (except "system" procedures) are compiled and started simultaneously in separate threads with myCNC software start or after "Build All" button pressed in **PLC Builder/Software PLC**.
-  * "System" PLC procedures are procedures with names start with \\ <code>__ (double underscore)</code> symbols. "System" procedures are not started automatically with the myCNC software start, but instead can be started automatically with some events or manually. There are pre-defined "System" PLC handlers- +  * "System" PLC procedures are procedures with names start with \\ <code>__ (double underscore)</code> symbols. "System" procedures are not started automatically with the myCNC software start, but instead can be started automatically with some events or manually. There are a few pre-defined "System" PLC handlers- 
  
  
Line 170: Line 169:
 | <code>__HANDLER_GCODE_START</code> | The procedure executed just before the myCNC software run g-code (after pressing PLAY button) | | <code>__HANDLER_GCODE_START</code> | The procedure executed just before the myCNC software run g-code (after pressing PLAY button) |
 | <code>__HANDLER_GCODE_STOP</code> | The procedure executed just after the myCNC software finished g-code running (after pressing STOP/PAUSE button) | | <code>__HANDLER_GCODE_STOP</code> | The procedure executed just after the myCNC software finished g-code running (after pressing STOP/PAUSE button) |
 +| <code>__BV17</code> | Initially named BV17, this Software PLC had double underscores added to remove an issue with automatic enabling of the testing mode for the controller peripherals (by becoming a System PLC, it prevents the procedure from starting automatically when the program is loaded). | 
 +
 +Variables used in Software PLC:
 +
 +^Variable^Use^Example^Comment^
 +| 100020 | Jog the selected axis (100020 through to 100027) | //gvarset(100020, 100);// | Negative values are not accepted, use 0-X (for example, //gvarset(100020, 0-100);//)|
 +| 100040 | Launch a Hardware PLC from within a Software PLC | //gvarset(100040, 607)//; | This will launch Hardware PLC M607 |
 +| 100041 | Eparameter to feed into the Hardware PLC being launched using 100040 | //gvarset(100041, 333);// | Used before //gvarset(100040, 607);//, this will set eparam=333 | 
  
   * [[software_plc_examples|Software PLC Examples]]   * [[software_plc_examples|Software PLC Examples]]
Line 448: Line 455:
 | --- | 17028 | Return Current MACHINE V Position in PLC units (0.01mm) | | --- | 17028 | Return Current MACHINE V Position in PLC units (0.01mm) |
 | --- | 17029 | Return Current MACHINE W Position in PLC units (0.01mm) | | --- | 17029 | Return Current MACHINE W Position in PLC units (0.01mm) |
 +
 +====Launching a PLC command using an on-screen button====
 +
 +The following video illustrates the process of creating a button to launch a software PLC command (a similar process can also be used for hardware PLCs):
 +
 +{{youtube>uII_1znYNE4?large}}
  
plc/plc.1589897187.txt.gz · Last modified: 2020/05/19 10:06 by ivan