Control Source
A Control Source provides a way to connect an external controller to a specific FB_PackML_BaseModule
, this could be the Machine Module or any Equipment module. The external component could be the HMI, the main operator panel, or any push button station on the machine. For the purpose of Encapsulation, it is typical to use multiple Control Sources, and even multiple Control Sources per module.
Registration
Each Control Source must be registered to the MM or EM using its RegisterExternalController()
method. An instance of a function block that implements I_PackML_ExternalController
must be passed into the method. This is typically done by creating your control source that EXTENDS FB_ControlSource
from the SPT Base Types
Library. Once the FB has been passed to the Registration()
method the CyclicLogic()
method of the ControlSource
must be called once.
Permissive
The Control Source is then used to control the state machine of the module. In its simplest form it will have a single CyclicLogic()
method that monitors the current mode and state, when a HMI, Hardware push button or other command is passed into the control source through a property, it will be compared against the defined permissive and conditions to determine how the state machine will respond. For example, if the current state is Aborting then most likely all commands will be ignored. But once the state changes to Aborted, the Reset button could be used to issue the Clear command to the state machine from within the Control Source.
The permissive can also be used to ensure an axis is homed before it’s allowed to be jogged, and to check that other interlocks have been properly handled.
Requests
When a button is pressed or a switch is turned, this status can be sent to the control source through a property. This can then be read internally by the CyclicLogic()
method, and if the permissive allows it, the state or mode can be changed. Once the state machine is in the proper condition, the same property can be read from the state method of the EM to carry out the command. For example, if the machine is currently in Manual
and Idle
, and the Jog button is pressed. The control source will check the permissive and issue the Start command to the state machine. Then, once the Execute()
method for the EM is called it will process the code for Manual and read the ControlSource.Jog
property as its command to jog the axis.
Where should Control Sources be used?
The Machine Module is the most obvious choice to start with a Control Source. While you can directly call the ChangeMode()
or ChangeState()
methods, using a Control Source creates a clean and encapsulated way to manage changes in the state machine. It is possible to register a control source for each Equipment module. Doing so can allow for a more modular machine, and also allow for the HMI connection to mirror the modularity of the PLC.
Not only can the HMI be a reason for a Control Source, but it is also possible to have a Control Source dedicated to hardware inputs and outputs. Some smaller operator panels have similar button layouts and functionality, and these can be excellent candidates for a reusable control source. Although being reusable is not a requirement, it does help with development time.
Creating a Control Source for the operator hardware provides a single location for the declaration of the hardware variables along with a place to connect them to the code. If the %I
and %Q
variables are declared locally within a Control Source then properties can be created to provide those variables to other parts of the code. Additionally a Control Source can be created for HMI variable which will provide the same familiarity for connecting external variables to the PLC code.