Commands

The commands module contains functions that can be called directly from the Homing PLC definition file.

These functions are used to define PLCs, axes and axis groupings.

pmac_motorhome.commands.plc(plc_num, controller, filepath, timeout=600000, post=None, post_home=PostHomeMove.none, post_home_distance=0)[source]

Define a new PLC. Use this to create a new Plc context using the ‘with’ keyword.

Must be called in the global context.

Parameters
  • plc_num (int) – Number of the generated homing PLC

  • controller (ControllerType) – Determines the class of controller Pmac or Geobrick

  • filepath (pathlib.Path) – The output file where the PLC will be written

  • pre (str) – some raw PLC code to insert at the start of a group

  • post (str) – some raw PLC code to insert at the end of a group

  • post_home (PostHomeMove) – action to perform on all axes after the home sequence completes

  • post_distance (int) – A distance to use in post_home

Returns

the Plc object for use in the context

Return type

Plc

pmac_motorhome.commands.group(group_num, post_home=PostHomeMove.none, post_distance=0, comment=None, pre='', post='')[source]

Define a new group of axes within a PLC that should be homed simultaneously. Use this to create a new context using the ‘with’ keyword from within a Plc context.

Must be called in a Plc context.

Parameters
  • group_num (int) – an identifying number note that group 1 is reserved for homing all groups

  • axes (List[int]) – a list of axis numbers to include in the group

  • post_home (PostHomeMove) – action to perform on all axes after the home sequence completes

  • post_distance (int) – A distance to use in post_home

Returns

The Group object for use in the context

Return type

Group

pmac_motorhome.commands.motor(axis, jdist=0, index=- 1, post_home=PostHomeMove.none, post_distance=0, enc_axes=[], ms=- 1)[source]

Declare a motor for use in the current group.

Must be called in a group context.

Parameters
  • axis (int) – axis number

  • jdist (int) – number of counts to jog after reaching a home mark. Required to far enough to move off of the home mark.

  • index (int) – for internal use in conversion of old scripts sets the index of this motor to a different value than the order of declaration. -1 means use the order that motors were added.

  • post_home (PostHomeMove) –

  • post_distance

  • enc_axes (list) – List of additional encoders that need zeroing on homing completion

pmac_motorhome.commands.only_axes(*axes)[source]

Creates a context in which actions are performed on a subset of the groups axes

Must be called in a group context.

For an example of the use of this, see Custom Homing PLC

Parameters

axes (int) – List of axis numbers

Returns

an OnlyAxes object for use in the context

Return type

OnlyAxes

pmac_motorhome.commands.post_home(**args)[source]

Perform one of the predefined post homing actions on all axes in the current group.

Must be called in a Group context.

This function is called as the last step in all of the Predfined Homing Sequences functions