AxisPlcOpenMc
- Namespace
- ZEquipment
- Extends
- Inherited Properties
- Inherited Methods
- Implements
FUNCTION_BLOCK AxisPlcOpenMc EXTENDS ZEquipment.Axis IMPLEMENTS ZEquipment.IAxisHoming, ZEquipment.IAxisMovePosition, ZEquipment.IAxisMoveVelocity, ZEquipment.IAxisFeedbackPosition, ZEquipment.IAxisFeedbackVelocity, ZEquipment.IAxisFeedbackCurrent, ZEquipment.IAxisHalt, ZEquipment.IAxisVelocityFeedrate, ZEquipment.IAxisBase, ZCore.IObject, ZCore.IBootable, ZCore.IError (
[output] Diagnostics : ZCore.DiagnosticMessage)
This function blocks implements the general axis interfaces by utilizing motion controllers that are conform to the PLCopen standard. This is the goto axes implementation of the Zeugwerk Framework if you want to control your axes via NC Motion (TwinCAT) or Softmotion (Codesys).
Internally, AxisPlcOpenMc uses MC function blocks (standardized by the PLCopen) to implement the Zeugwerk Framework's axis interfaces (i.e. IAxisBase, IAxisMovePosition, ...).
However, this implementation is not only a simple wrapper of MC function blocks, it also simplifies the usage of said function blocks. Any method that is suffixed with Async will automatically take care of fulfilling its preconditions. For instance, a call to MoveAbsoluteAsync will automatically execute an error reset if neccessary and will power on the axis.
- Unlock the drive if it has been locked before (AxisPlcOpenMc only)
- Reset any drive errors if there are still errors, which have not been acknowledged yet
- Write parameters to the drive that have been requested to read or write by using the Parameter property of each specialised axis
- Enable the drive if it is not enabled yet
Besides implementing the axis interfaces of the Zeugwerk Framework, this function block offers some methods, which are specific to PLCopen (e.g. TwinCAT NC)
- Use AxisRef to get hold of the
AXIS_REF
object. This is mainly needed for multiaxes applications (i.e. gantry), since AxisPlcOpenMc is meant for convienent single axis usage only. - (Twincat NC only) Use VelocityFeedrate to overwrite all velocities in percent.
Outputs
Diagnostics
DiagnosticMessage
Constructor
FB_init
METHOD FB_init (
[input] bInitRetains : BOOL,
[input] bInCopyCode : BOOL,
[input] parent : ZCore.IManagedObject) : BOOL
Inputs
bInitRetains
BOOLif TRUE, the retain variables are initialized (warm start / cold start)
bInCopyCode
BOOLif TRUE, the instance afterwards gets moved into the copy code (online change)
parent
IManagedObject
Returns
- BOOL
Properties
ActualCurrent
PROPERTY ActualCurrent : LREAL
Property Value
- LREAL
ActualFollowingError
PROPERTY ActualFollowingError : LREAL
Property Value
- LREAL
ActualPosition
PROPERTY ActualPosition : LREAL
Returns the actual position of the axis, which is usually related to a position encoder or resolver. The value returned is given in drive positional-unit, which is usually millimeters or degrees, respectively.
Property Value
- LREAL
ActualSafetyState
PROPERTY ActualSafetyState : AxisSafetyStateFlags
This property can be used to test if a given safety feature of a drive is currently activated or not. Note that the property returns a "Flags" enumeration, which means that several bits of the returned value can be on at the same time.
Note
Retrieving the safety state of a drive is manufacturer specific.
- Some drives may not support some of the features that are depicted in the returned value (some bits may always be 0).
- Generic axes implementation (i.e. AxisPlcOpenMc) of the Zeugwerk Framework usually do not return the correct safety state of the drive. In doubt refer to the documentation of your specific implementation.
Warning
Since this axis implementation is generic it can not correctly return the
safety state of the drive. The return value will always be 0
(no bit of the
returned type is set)
Property Value
ActualVelocity
PROPERTY ActualVelocity : LREAL
Property Value
- LREAL
Parameter
PROPERTY Parameter : IAxisPlcOpenMcParameter
This property returns an interface to the central parameterization entry point of an PlcOpen Mc Axis. Usually parameters are split in
- Booting parameters
- Drive parameters: homing parameters, positioning type and modulo settings can be accessed here
- Plc parameters: maximum speed and conversion parameters
- Simulation parameters: setting an initial (simulated) position, jerk and acceleration of the simulated trajectory
It is also possible to return the ParameterChannel interface to be able to access every parameter needed of an Axis PlcOpen Mc instance
Property Value
Referenced
PROPERTY Referenced : BOOL
This property can be used to test if an axis is referenced correctly. For axes that use an incremental encoder, this means that a homing procedure has been already been executed correctly. For axes that use an absolute encoder, this usually means that the encoder has been initialized correctly.
Read the documentation of your axes implementation (i.e. AxisPlcOpenMc) for more specifics.
Property Value
- BOOL
Simulation
PROPERTY Simulation : BOOL
This property can be used to enable or disable simulation mode of this axis. Whenever the simulation flag is changed, the drive will automatically (re-)initialize by performing its booting sequence. Hence, it is possible to switch to simulation and back while the PLC is running. The simulated axis instance utilizes AxisSimulatedImpl, which in turn uses the Online-Trajectory-Generator to generate motion profiles.
Warning
Some PLCopen conform motion controllers (NC Motion) come with a built-in simulation mode on their side.
This property will have no impact to the simulation mode of the motion controller.
Thus, when setting up the motion controller, one can use a
simulated (by the motion controller) axis instance, even if on=FALSE
.
Property Value
- BOOL
State
PROPERTY State : ZCore.ObjectState
Returns the object state of the axis object. This exposes if an object is still in its booting phase, had an error, or is busy executing an async action.
Property Value
VelocityFeedrate
PROPERTY VelocityFeedrate : LREAL
Property Value
- LREAL
Methods
AxisRef
METHOD AxisRef () : REFERENCE TO ZPlatform.PlcOpenAxisRef
Returns
- REFERENCE TO PlcOpenAxisRef
HaltAsync
METHOD HaltAsync (
[input] startToken : ZCore.IStartToken)
Inputs
startToken
IStartTokenpass an StartToken instance here to check if the call was successfully executed
HomingAsync
METHOD HomingAsync (
[input] startToken : ZCore.IStartToken)
Inputs
startToken
IStartToken(optional) object to check if the method was executed successfully - may be 0
IsAtPosition
METHOD IsAtPosition (
[input] pos : LREAL,
[input] window : LREAL) : BOOL
Inputs
Returns
- BOOL
MoveAbsoluteAsync
METHOD MoveAbsoluteAsync (
[input] startToken : ZCore.IStartToken,
[input] position : LREAL,
[input] speed : LREAL)
Starts to move the axes to a specific position with a given velocity. The method utilizes the drive's profile generator, which may offer to adjust acceleration, deceleration and jerk as PDOs or SDOs as well. The latter parameters are usually vendor specific and thus are not part of the interface. Use the Parameter property of each specialised axis to adjust said values before calling this method. Calling this method will beforehand automatically trigger the following sequences
- Unlock the drive if it has been locked before (AxisPlcOpenMc only)
- Reset any drive errors if there are still errors, which have not been acknowledged yet
- Write parameters to the drive that have been requested to read or write by using the Parameter property of each specialised axis
- Enable the drive if it is not enabled yet
Executing this method while the drive is still Busy with another Async command will cause this method to fail. This can
be checked by submitting an StartToken as a startToken
. Simply pass such an object and Assert it
or check for startToken.Error
after calling this method.
If a MoveAbsoluteAsync or MoveRelativeAsync command is currently being executed, calling this method can be used to overwrite the current move command. This is an exeception to the rule that this method should not be called while the axis is busy.
Inputs
startToken
IStartTokenpass an StartToken instance here to check if the call was successfully executed
position
LREALPosition in drive position units, usually millimeter or degree
speed
LREALSpeed in drive speed units, usually millimeter-per-second, or degree-per-second
MoveRelativeAsync
METHOD MoveRelativeAsync (
[input] startToken : ZCore.IStartToken,
[input] distance : LREAL,
[input] speed : LREAL)
Starts to move the axes to a specific distance from its current position with a given velocity. The method utilizes the drive's profile generator, which may offer to adjust acceleration, deceleration and jerk as PDOs or SDOs as well. The latter parameters are usually vendor specific and thus are not part of the interface. Use the Parameter property of each specialised axis to adjust said values before calling this method. Calling this method will beforehand automatically trigger the following sequences
- Unlock the drive if it has been locked before (AxisPlcOpenMc only)
- Reset any drive errors if there are still errors, which have not been acknowledged yet
- Write parameters to the drive that have been requested to read or write by using the Parameter property of each specialised axis
- Enable the drive if it is not enabled yet
Executing this method while the drive is still Busy with another Async command will cause this method to fail. This can
be checked by submitting an StartToken as a startToken
. Simply pass such an object and Assert it
or check for startToken.Error
after calling this method.
If a MoveAbsoluteAsync or MoveRelativeAsync command is currently being executed, calling this method can be used to overwrite the current move command. This is an exeception to the rule that this method should not be called while the axis is busy.
Inputs
startToken
IStartTokenpass an StartToken instance here to check if the call was successfully executed
distance
LREALPosition in drive position units, usually millimeter or degree
speed
LREALSpeed in drive spped units, usually millimeter-per-second, or degree-per-second
MoveVelocityAsync
METHOD MoveVelocityAsync (
[input] startToken : ZCore.IStartToken,
[input] velocity : LREAL)
If a MoveVelocityAsync command is currently being executed, calling this method can be used to overwrite the current move command. This is an exeception to the rule that this method should not be called while the axis is busy.
Inputs
startToken
IStartTokenpass an StartToken instance here to check if the call was successfully executed
velocity
LREALvelocity in drive velocity units, usually millimeter-per-second, or degree-per-second; for variable frequency drives rotations/minute are common
RebootAsync
METHOD RebootAsync (
[input] startToken : ZCore.IStartToken)
Reboot of the axis, which means that the internal state is switched back to Booting. In practice, this switches the axis' fieldbus back to PREOP, writes all parameters to the drive and then switches back to OP. Internally this is achieved by parking the axis and then unparking it.
Inputs
startToken
IStartTokenpass an StartToken instance here to check if the call was successfully executed
SetLogger
METHOD SetLogger (
[input] logger : ZCore.ILogger)
Use this method together with SetName to enable logging for this axis. Various methods of this implementation write log messages into the passed logger interface.
Note
Sometimes it is beneficial to disable logging by passing 0
to this method (e.g. for inputs or outputs which are switch very often).
Inputs
logger
ILogger
SetName
METHOD SetName (
[input] name : ZCore.ZString)
Sets the name of this object as it will show up in any log messages that is created by this object. The name set with this method should be relatable to the name of the input in the electrical plan of your automation project to identify the corresponding input properly.
Inputs
name
ZString
SetSimulation
METHOD SetSimulation (
[input] on : BOOL)