plc:plc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
plc:plc [2022/10/28 09:47] – ivan | plc:plc [2022/11/07 16:03] (current) – ivan | ||
---|---|---|---|
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