Simple Homing PLC
The simplest homing PLC will use one of the predifined homing sequences that are built in to pmac_motorhome.
A PLC definition is a python file that defines the following:
One or more
plc()
commands which define a single PLC using PLC number, mototionControllerType
and a filename in which the output of the PLC code generation is saved.Within each PLC, one or more
group()
commands that define groups of motors to be homed as a unit. These require a group number which must be unique within the PLC. Group Number 1 is reserved for ‘home all groups’.Within each group are one or more
motor()
commands that declare the motors in the current group. These require an axis number.Also within each group is a sequence of commands that will generate a sequence of PLC commands in the output file.
plc()
and group()
use
python contexts to manage their scope. This simply means that you add
The with statement
before calling them and then indent the related code.
The basic example below defines a single PLC containing a single group and generates PLC code that will home axes 1 and 2 simultaneously and use the home switch or encoder home mark to find their home positions.
from pmac_motorhome.commands import group, motor, plc
from pmac_motorhome.sequences import home_hsw
with plc(
plc_num=12, controller="GeoBrick", filepath="/tmp/PLC12_SLITS1_HM.pmc",
):
with group(group_num=3):
motor(axis=1)
motor(axis=2)
home_hsw()
To create the PLC file for download to the brick you simply need to execute example.py in the virtual environment in which pmac_motorhome is installed e.g.
pipenv run docs/tutorials/example.py
less /tmp/PLC12_SLITS1_HM.pmc