plc:plc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
plc:plc [2022/10/27 13:41] – ivan | plc:plc [2022/11/07 16:03] (current) – ivan | ||
---|---|---|---|
Line 534: | Line 534: | ||
//**NOTE**: Jog from PLC requires a firmware update. As of February 2022, the feature is available in the Testing firmware branch.// | //**NOTE**: Jog from PLC requires a firmware update. As of February 2022, the feature is available in the Testing firmware branch.// | ||
- | myCNC allows the user to call for a jog command from within PLCs. The advantage of this motion mode is that it allows to perform tasks (such as changing the speed and direction of movement, as well as turning the motion for a particular axis on or off), all without stopping. This is useful in such applications as homing along multiple (for example, three) axes. Such an example is available here: [[plc: | + | myCNC allows the user to call for a jog command from within PLCs. The advantage of this motion mode is that it allows to perform tasks (such as changing the speed and direction of movement, as well as turning the motion for a particular axis on or off), all without stopping. This is useful in such applications as homing along multiple (for example, three) axes. Such an example |
In this mode, the acceleration is set via the following command: | In this mode, the acceleration is set via the following command: | ||
Line 605: | Line 605: | ||
| GVAR_PLC_JOGSPEED_UNITS | 8634 | | | GVAR_PLC_JOGSPEED_UNITS | 8634 | | ||
| GVAR_PLC_JOG | 8635 | | | GVAR_PLC_JOG | 8635 | | ||
+ | |||
+ | An example of a homing PLC that utilized this functionality is shown below. This PLC is designed for the Z-axis only: | ||
+ | |||
+ | <code C># | ||
+ | |||
+ | wait_move() | ||
+ | { | ||
+ | do { code=gvarget(6060); | ||
+ | }; | ||
+ | |||
+ | show_error() | ||
+ | { | ||
+ | gvarset(9121, | ||
+ | timer=50; | ||
+ | message=PLCCMD_MOTION_BREAK; | ||
+ | exit(99); | ||
+ | }; | ||
+ | |||
+ | find_home_z() | ||
+ | { | ||
+ | |||
+ | gvarset(5521, | ||
+ | gvarset(5525, | ||
+ | |||
+ | gvarset(8631, | ||
+ | |||
+ | statez=0; //we set the " | ||
+ | speed=500; | ||
+ | speed_slow=100; | ||
+ | |||
+ | direction=(4<< | ||
+ | |||
+ | gvarset(8634, | ||
+ | |||
+ | gvarset(8635, | ||
+ | timer=0; | ||
+ | do | ||
+ | { | ||
+ | changed=0; | ||
+ | if (statez==0) //to home X | ||
+ | { | ||
+ | sens=portget(INPUT_HOME_Z); | ||
+ | if (sens!=0) | ||
+ | { | ||
+ | statez=1; | ||
+ | gvarset(8634, | ||
+ | changed=1; | ||
+ | }; | ||
+ | }; | ||
+ | if (statez==1) //rollback from home Z | ||
+ | { | ||
+ | sens=portget(INPUT_HOME_Z); | ||
+ | if (sens==0) | ||
+ | { | ||
+ | statez=2; | ||
+ | changed=1; | ||
+ | }; | ||
+ | }; | ||
+ | |||
+ | |||
+ | if (changed!=0) //if any of the sensors state is changed | ||
+ | { | ||
+ | direction=0; | ||
+ | if (statez==0) { direction=direction | (4<< | ||
+ | if (statez==1) { direction=direction | 4; }; //direction set to X+ | ||
+ | gvarset(8635, | ||
+ | }; | ||
+ | |||
+ | |||
+ | |||
+ | if ((timer& | ||
+ | timer++; | ||
+ | ready=(statez==2); | ||
+ | |||
+ | }while(ready==0); | ||
+ | |||
+ | |||
+ | | ||
+ | |||
+ | }; | ||
+ | |||
+ | main() | ||
+ | { | ||
+ | |||
+ | gvarset(8631, | ||
+ | gvarset(5539, | ||
+ | |||
+ | find_home_z(); | ||
+ | |||
+ | |||
+ | exit(99); | ||
+ | };</ | ||
+ | |||
+ | The PLC above can be combined with the XY homing (linked at the start of this section) to create simultaneous XYZ homing. In general, the Jog from PLC functionality allows for this simultaneous movement, cutting down on the previously required separate procedures per each axis. |
plc/plc.txt · Last modified: 2022/11/07 16:03 by ivan