Table of Contents

AxisSimulatedImpl

Namespace
ZEquipment
Extends
Inherited Properties
Inherited Methods
Implements
FUNCTION_BLOCK AxisSimulatedImpl EXTENDS ZEquipment.AxisImpl IMPLEMENTS ZEquipment.IAxisHoming, ZEquipment.IAxisMovePosition, ZEquipment.IAxisMoveVelocity, ZEquipment.IAxisMoveCurrent, ZEquipment.IAxisFeedbackPosition, ZEquipment.IAxisFeedbackVelocity, ZEquipment.IAxisFeedbackCurrent, ZEquipment.IAxisMoveInterpolatedPosition, ZEquipment.IAxisMoveInterpolatedVelocity, ZEquipment.IAxisMoveInterpolatedCurrent, ZEquipment.IAxisBrake, ZEquipment.IAxisHalt, ZEquipment.IAxisVelocityFeedrate, ZEquipment.IAxisBase, ZEquipment.IAxisAbsolute, ZCore.IBootable, ZCore.IObject, ZCore.IError, ZCore.IManagedObject (
 [output] State : ObjectState)

This function blocks implements the general axis interfaces by simulating every behavior that we expect from a drive/axis. This implementation is used by almost all axes in the Zeugwerk Framework if it is set to SetSimulation(TRUE).

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 (AxisSimulated 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

Constructor

FB_init

METHOD FB_init (
 [input] bInitRetains : BOOL,
 [input] bInCopyCode : BOOL,
 [input] parent : ZCore.IManagedObject,
 [input] parameter : IAxisParameterSimulation,
 [input] parameterTarget : REFERENCE TO AxisParameterTarget) : BOOL

Inputs

bInitRetains BOOL

if TRUE, the retain variables are initialized (warm start / cold start)

bInCopyCode BOOL

if TRUE, the instance afterwards gets moved into the copy code (online change)

parent IManagedObject
parameter IAxisParameterSimulation
parameterTarget REFERENCE TO AxisParameterTarget

Returns

BOOL

Properties

ActualCurrent

PROPERTY ActualCurrent : LREAL

Returns the actual current, which is used by the drive. The value returned is usually given in % of the nominal current.

Property Value

LREAL

ActualFollowingError

PROPERTY ActualFollowingError : LREAL

Returns the deviation between the nominal position of the axis, according to the drive internal profile generator, to the actual position. The actual position is usually related to a position encoder or resolver 1 or 2 depending on which encoder is used for the actual movement. The value returned is given in drive positional-unit, which is usually millimeters or degrees, respectively.

By summing up the values of ActualFollowingError and ActualPosition it is possible to calculate the nominal position of the profile generator.

Property Value

LREAL

ActualMotionState

PROPERTY ActualMotionState : AxisMotionState

This property returns the actual motion state of a drive to find out if the axis is currently accelerating, deceleration, moving with constant velocity or standing still.

Note

While some drives support a dedicated status to retrieve this information, some implementation have to rely on a software implementation. The latter may be not as accurate as a hardware status and rely on settings as the speed-monitoring-window or position-window parameter.

Property Value

AxisMotionState

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

The simulation axis is (currently) not implementing safety features. The return value will always be 0 (no bit of the returned type is set)

Property Value

AxisSafetyStateFlags

ActualVelocity

PROPERTY ActualVelocity : LREAL

Returns the actual velocity of the axis, which is usually calculated by using a position encoder or resolver. The value returned is given in drive velocity-units, which is usually millimeters-per-seconds or degree-per-seconds, respectively. In contrast to speed, velocity is a signed value such that it can have a positive or negative sign.

Property Value

LREAL

BrakeOpened

PROPERTY BrakeOpened : BOOL

Returns the state of the brake that is controlled by the drive. If the drive doesn't have any brake connected to it, this property always returns TRUE.

Property Value

BOOL

DriveEnabled

PROPERTY DriveEnabled : BOOL

This property can be used to check if an axis is powered by its drive. On the one hand, after successfully running an enable drive command with EnableDriveAsync(on:=TRUE) it is expected that this property is returning TRUE. On the other hand, after successfully executing EnableDriveAsync(on:=FALSE) it is expected that this property is returning FALSE.

If the STO of a drive is active or not enabled for any other reason, this property returns FALSE as well.

Property Value

BOOL

DrivePowered

PROPERTY DrivePowered : BOOL

This property returns TRUE if the drive itself is powered and can provide power to an axis by calling EnableDriveAsync. If this property returns FALSE usually an emergency-stop is pressed or power is missing for some other reason.

Property Value

BOOL

DriveStateAsString

PROPERTY DriveStateAsString : ZCore.ZString

Returns the current state of the drive as string. The returned string may differ may differ severly between implementations, manufactures and depends if the axis is simulated or not. So, this should only be used for logging, debugging and visualization and not be linked to any logic.

Property Value

ZString

Manufacturer

PROPERTY Manufacturer : ZCore.ZString

Returns the manufacturer name of the axis as human-readable text

This specific implementation returns Zeugwerk to indicate that it is using the simulated axis.

Property Value

ZString

Parked

PROPERTY Parked : BOOL

Axes can be parked by calling ParkAsync(on:=TRUE). Parking means that any cyclic methods are skipped after executing a parking sequence. If this property returns TRUE, an axis can be "unparked" by using ParkAsync(on:=FALSE).

Property Value

BOOL

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 has to be overwritten by an actual axis implementation (i.e. AxisPlcOpenMc). It is used to switch the axis from a physical instance (i.e. AxisPlcOpenMcImpl) to a simulated axis-instance (i.e. AxisSimulatedImpl).

Settings this property with TRUE or FALSE takes care of automatically parking the unused axis instance and starting the booting sequence for the axis instance that should be used.

Property Value

BOOL

VelocityFeedrate

PROPERTY VelocityFeedrate : LREAL

This property is used to set the actual velocity override of an axis. This override is used to modify a moving axis velocity. Provide values between 0.0 and 1.0 which leads to 0% of the commanded velocity all the way up to 100%.

Note

In simulation this method is currently not implemented!

Property Value

LREAL

Methods

Cyclic

METHOD Cyclic ()

EnableDriveAsync

METHOD EnableDriveAsync (
 [input] startToken : ZCore.IStartToken,
 [input] on : BOOL)

By using this method the power output of a drive to an axis can be enabled (on:=TRUE) or disabled(on:=FALSE), respectively. 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

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.

Inputs

startToken IStartToken
on BOOL

HaltAsync

METHOD HaltAsync (
 [input] startToken : ZCore.IStartToken)

By using this method the drive will stop with the same position profile (regarding jerk, acceleration and deceleration) as it is used to move the axis. Calling this method will beforehand automatically trigger the following sequences

  • Unlock the drive if it has been locked before (AxisPlcOpenMc only)

To check if the method could be started successfully, pass such an StartToken as a startToken. Then Assert this object or check for startToken.Error.

Inputs

startToken IStartToken

(optional) object to check if the method was executed successfully - may be 0

HomingAsync

METHOD HomingAsync (
 [input] startToken : ZCore.IStartToken)

Use this method to start the homing prodedure of the axis.

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.

Note

Although (servo) drives usually offer a comparable method for homing, it is hard to abstract all methods, which might be possible to use for specific drive manufactures. Therefore, the actual selection of a homing method can usually be found in specific implementations with a SetHomingMethod method (i.e. AxisStepperEL7031.SetHomingMethod.

Inputs

startToken IStartToken

IsAtPosition

METHOD IsAtPosition (
 [input] pos : LREAL,
 [input] window : LREAL) : BOOL

Use this method to check if an axis is at a specific location in a given window. Note that some implementation may not use the parameter window, but may rely on a drive internal position-window. In doubt, read the documentation of your axes implementation (i.e. AxisPlcOpenMc).

Inputs

pos LREAL
window LREAL

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.

Inputs

startToken IStartToken

(optional) object to check if the method was executed successfully - may be 0

position LREAL
speed LREAL

MoveCurrentAsync

METHOD MoveCurrentAsync (
 [input] startToken : ZCore.IStartToken,
 [input] current : LREAL)

Starts to move the axes with a constant current such that the axes will continously accelerate. Since current is proportional to the torque or force a motor can output, this method can be used to apply a constant, uncalibrated force or torque (depending on the axis configuration) to an object.

Note

Most of the time this method has to be used in conjunction with a setup procedure, where monitors like following-error are disabled beforehand. This heavily depends on the kind of drive/axis you are using. In doubt refer to the manufactures drive-documentation.

Warning

Starting the drive by calling this method without any obstacle or counterpart, the motor will accelerate until an equilibrium of force or torque to move the axis and force or torque which decelerates the axis is reached. This can lead to damage of the underlaying mechanical system if not used appropriately.

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.

Inputs

startToken IStartToken
current LREAL

MoveInterpolatedCurrentAsync

METHOD MoveInterpolatedCurrentAsync (
 [input] startToken : ZCore.IStartToken)

This method is used to enter the drives interpolated current mode, i.e. CiA402 this mode is usually called cyclic-synchronous-torque (CST) mode. After the mode has been successfully switched to, SetInterpolatedCurrent has to be called every PLC cycle, with a command value, which should not exceed any drive or physicial limit. The Async method is done if the object is not in its Busy state anymore.

Note

This method is used to start a specific operation mode of the drive. Calling any other Async method of the axes interfaces, will finish this mode. This includes methods like StopAsync and HaltAsync.

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.

Inputs

startToken IStartToken

MoveInterpolatedPositionAsync

METHOD MoveInterpolatedPositionAsync (
 [input] startToken : ZCore.IStartToken)

This method is used to enter the drives interpolated position mode, i.e. CiA402 this mode is usually called cyclic-synchronous-position (CSP) mode. After the mode has been successfully switched to, SetInterpolatedPosition has to be called every PLC cycle, with a command value, which should not exceed any drive or physicial limit. The Async method is done if the object is not in its Busy state anymore.

Note

This method is used to start a specific operation mode of the drive. Calling any other Async method of the axes interfaces, will finish this mode. This includes methods like StopAsync and HaltAsync.

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.

Inputs

startToken IStartToken

MoveInterpolatedVelocityAsync

METHOD MoveInterpolatedVelocityAsync (
 [input] startToken : ZCore.IStartToken)

This method is used to enter the drives interpolated velocity mode, i.e. CiA402 this mode is usually called cyclic-synchronous-velocity (CSV) mode. After the mode has been successfully switched to, SetInterpolatedVelocity has to be called every PLC cycle, with a command value, which should not exceed any drive or physicial limit. The Async method is done if the object is not in its Busy state anymore.

Note

This method is used to start a specific operation mode of the drive. Calling any other Async method of the axes interfaces, will finish this mode. This includes methods like StopAsync and HaltAsync.

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.

Inputs

startToken IStartToken

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.

Inputs

startToken IStartToken
distance LREAL
speed LREAL

MoveVelocityAsync

METHOD MoveVelocityAsync (
 [input] startToken : ZCore.IStartToken,
 [input] velocity : LREAL)

Starts to move the axes a specific 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.

Inputs

startToken IStartToken
velocity LREAL

OpenBrakeAsync

METHOD OpenBrakeAsync (
 [input] startToken : ZCore.IStartToken,
 [input] on : BOOL)

Opens and closes the brake that the drive controls. Use on:=TRUE to open the brake and on:=FALSE to close the brake.

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.

Inputs

startToken IStartToken

(optional) object to check if the method was executed successfully - may be 0

on BOOL

ParametrizeAsync

METHOD ParametrizeAsync (
 [input] startToken : ZCore.IStartToken)

This method executes parametrization to the drive. Parameters to read and write can be set-up by using the Parameter property of each axis. Usually this method doesn't have to be called manually, because most other Async method of an axes are calling this method automatically internally. However, use this method if reading or writing is explicitly required at a specific point in the PLC.

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.

Inputs

startToken IStartToken

ParkAsync

METHOD ParkAsync (
 [input] startToken : ZCore.IStartToken,
 [input] on : BOOL)

This method can be used to skip any internal cyclic method. Parking an axes and then "unparking" it will automatically execute a booting sequences, where the PLC variables are reinitialized. Parking is usually needed for drives that are optional for a machine and can be hotplugged.

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.

Inputs

startToken IStartToken
on BOOL

ResetErrorAsync

METHOD ResetErrorAsync (
 [input] startToken : ZCore.IStartToken)

By using this method any remaining unacknowledged errors on the drive are reset. Usually this method doesn't have to be called manually, because most other Async method of an axes are calling this method automatically internally. However, use this method if resetting the error manually is required for some reason.

  • Unlock the drive if it has been locked before (AxisPlcOpenMc only)
  • Write parameters to the drive that have been requested to read or write by using the Parameter property of each specialised axis

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.

Inputs

startToken IStartToken

SetAbsolutePositionAsync

METHOD SetAbsolutePositionAsync (
 [input] startToken : ZCore.IStartToken,
 [input] position : LREAL)

Starts to set the axis current position to a specific value. Note drives usually offer numerous additional parameters to this method, like setting the encoder number to use for this operation (some axes have more than just 1 encoder). Use the Parameter property of each specialised axis to adjust such special parameters and refer to the documentation of your drive to find out, which modes are supported. Calling this method will beforehand automatically trigger the following sequences

  • Unlock the drive if it has been locked before (this appliesAxisPlcOpenMc 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.

However, the actual sequence for setting the absolute position of a drive may vary from implementation to implementation. Some drives for instance may only allow to set the absolute position in disabled state. In doubt, refer to the documentation of the actual implementation that you are using (i.e. AxisPlcOpenMc).

Inputs

startToken IStartToken

(optional) object to check if the method was executed successfully - may be 0

position LREAL

Position that should be set as ActualPosition

SetInterpolatedCurrent

METHOD SetInterpolatedCurrent (
 [input] startToken : ZCore.IStartToken,
 [input] current : LREAL)

This method has to be used together with MoveInterpolatedCurrentAsync to send a command value to the drive. The latter should not exceed any drive or motors physicial limit.

If this method is called when MoveInterpolatedCurrentAsync has not started before, the method will fail. Use startToken for testing if the method was executed correctly.

Inputs

startToken IStartToken
current LREAL

SetInterpolatedPosition

METHOD SetInterpolatedPosition (
 [input] startToken : ZCore.IStartToken,
 [input] position : LREAL)

This method has to be used together with MoveInterpolatedPositionAsync to send a command value to the drive. The latter should not exceed any drive or physicial limit.

If this method is called when MoveInterpolatedPositionAsync has not started before, the method will fail. Use startToken for testing if the method was executed correctly.

Inputs

startToken IStartToken
position LREAL

SetInterpolatedVelocity

METHOD SetInterpolatedVelocity (
 [input] startToken : ZCore.IStartToken,
 [input] velocity : LREAL)

This method has to be used together with MoveInterpolatedVelocityAsync to send a command value to the drive. The latter should not exceed any drive or physicial limit.

If this method is called when MoveInterpolatedVelocityAsync has not started before, the method will fail. Use startToken for testing if the method was executed correctly.

Inputs

startToken IStartToken
velocity LREAL

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 FINAL 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

StopAsync

METHOD StopAsync (
 [input] startToken : ZCore.IStartToken)

By using this method the drive will stop with the quickstop profile (regarding jerk, acceleration and deceleration), usually this profile is quicker than the normal position profile, which is used for normal movement profiles and sometimes also for halt. Calling this method will beforehand automatically trigger the following sequences

To check if the method could be started successfully pass such an StartToken as a startToken. Then Assert this object or check for startToken.Error. However, usually StopAsync can always be called, only some very specific implementations may behave differently. In doubt, refer to the documenation of a specific implementation.

Note

If an ongoing task was started with an ExecutionToken as the token parameter (e.g. _axis.AxisName.MoveAbsolutAsync(THIS^) in a Sequence), it gets informed (aborted), if not the same ExecutionToken is used here with this call.

Inputs

startToken IStartToken

(optional) object to check if the method was executed successfully - may be 0