ParameterChannelPlcOpenUM
- Namespace
- ZAux
- Implements
FUNCTION_BLOCK ParameterChannelPlcOpenUM IMPLEMENTS ZCore.IParameterChannel, ZCore.IUnmanagedObject, ZCore.IObject, ZCore.IError
This ParameterChannel implementation allows to read and write parameters that are used by a motion controller. This specific implementation handles TwinCAT NcMotion parameters.
To use it in an application to access (read or write) NC-Motion parameters just instantiate it and provide the AxisId which is referenced in the AXIS_REF structure from your NC-Motion instance;
PROGRAM MAIN
VAR
DateTime : ZAux.DateTimeUM;
Logger : ZAux.LoggerFile7FFUM(datetime:=DateTime, filePath:='C:\temp\logfile.log', target:='');
Step : ZCore.Step(0, 100);
Axis1 : ZEquipment.AxisPlcOpenMcUM;
Channel : ZAux.ParameterChannelPlcOpenUM(Axis1.AxisRef());
value : LREAL;
END_VAR
-------------------------------------------------------
DateTime.Cyclic();
Logger.Cyclic();
Axis1.Cyclic();
Channel.Cyclic();
CASE Step.Index OF
0: // wait until logger is ready (est. 2 cycles)
IF Logger.Operational
THEN
Logger.Info('Appliation started');
Step.SetNext(10);
END_IF
10: // initialize axis and channel
Axis1.SetLogger(Logger);
Axis1.SetName(name:='Axis1');
Axis1.SetSimulation(FALSE);
Channel.SetLogger(Logger);
Channel.SetName('ChannelAxis1');
Channel.SetTimeout(3.0);
Channel.SetAxisReference(Axis1.AxisRef());
Step.SetNext(20);
20: // start read request to a parameter
IF Step.OnEntry()
THEN
// read AxisAcc -> parameter1 = Index-Group (0x4000 + ID), ID can be ignored, will be filled automatically by channel
// parameter2 = Index-Offset for AxisAcc Parameter
Channel.RequestAsync(taskToken:=0, actionFlags:=ZCore.ParameterChannelActionFlag.Read,
parameter1:=16#4000, parameter2:=16#0000_0101, parameterType:=ZCore.ParameterChannelPlcOpenParameterType.Int32,
bufferPtr:=ADR(value), bufferSize:=SIZEOF(value));
END_IF
IF Channel.Error
THEN
Logger.Error(Channel.ErrorMessage());
ELSIF NOT Channel.Busy
THEN
Step.SetNext(30);
END_IF
30: // ready for next test
;
END_CASE
Constructor
FB_init
METHOD FB_init (
[input] bInitRetains : BOOL,
[input] bInCopyCode : BOOL,
[input] axisRef : REFERENCE TO ZPlatform.PlcOpenAxisRef) : 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)
axisRef
REFERENCE TO PlcOpenAxisRefReference to the axis of the nc-motion instance in use; Depending on the platform the actual Reference may differ, for Beckhoff systems the AXIS_REF struct is used here
Returns
- BOOL
Properties
Booted
PROPERTY Booted : BOOL
Property Value
- BOOL
Busy
PROPERTY Busy : BOOL
Use State
to find out if the object is busy executing its initialization phase,
or it is busy performing an actual sequence.
Property Value
- BOOL
Done
PROPERTY Done : BOOL
If the object is in idle state (often mentioned as "the object is not busy and not on error"),
this is indicated by this property returning TRUE
.
Property Value
- BOOL
Error
PROPERTY Error : BOOL
Property Value
- BOOL
Methods
Cyclic
METHOD Cyclic ()
This method should be called every cycle to enable this class to operate. The method returns immediately if no task of the function block has been started (e.g. RequestAsync.
ErrorId
METHOD ErrorId () : UDINT
Returns the error code of the first error source for this object. The method recursively goes down the error stack until the initial source of error of this object can be found. For performance reasons, the error stack is not cleared when the error state is reset. So this method should always used in conjunction with Error.
Returns
- UDINT
ErrorMessage
METHOD ErrorMessage () : ZCore.ZString
Returns the error description of the first error source for this object. The method recursively goes down the error stack until the initial source of error of this object can be found. For performance reasons, the error stack is not cleared when the error state is reset. So this method should always used in conjunction with Error.
Returns
ErrorSource
METHOD ErrorSource () : ZCore.IError
This method returns the direct error source of this object. This method can then be used to retrieve the actual error source by using the method of the returned IError.
Returns
RequestAsync
METHOD RequestAsync (
[input] taskToken : ZCore.ITaskToken,
[input] actionFlags : ZCore.ParameterChannelActionFlag,
[input] parameter1 : DWORD,
[input] parameter2 : DWORD,
[input] parameterType : INT,
[input] bufferPtr : ZCore.ZPointer,
[input] buffersize : UDINT)
Depending on the chosen actionFlag
this method starts a Read or Write
request.
Warning
If any request fails, all remaining requests are cleared from the internal buffer as well.
Inputs
taskToken
ITaskTokenactionFlags
ParameterChannelActionFlagactions to be performed for the following parameter. This is a flags parameter (several actions are possible)
parameter1
DWORDindex group, the last 8bit of this number, which is the axisid, are ignored and handled internally
parameter2
DWORDindex offset
parameterType
INTbufferPtr
ZPointerPointer to the location this method writes to or reads from
buffersize
UDINTSize of the location buffer is pointing to
SetAxisReference
METHOD SetAxisReference (
[input] axisRef : REFERENCE TO ZPlatform.PlcOpenAxisRef)
If a ParameterChannelPlcOpen is used and one uses the same instance for different axes, SetAxisReference can be used to change the reference to the actual PlcOpen-Axis reference of an axis.
For Beckhoff systems a Reference to the AXIS_REF structure can be used. If a Zeugwerk-AxisPlcOpenMc instance is used the AXIS_REF-reference can be retrieved by calling the AxisRef()-method
See the example code provided at ParameterChannelPlcOpenUM
Inputs
axisRef
REFERENCE TO PlcOpenAxisRefReference to the actual axis-reference of a PlcOpenAxis. For Beckhoff systems, provide a reference to the AXIS_REF structure
SetLogger
METHOD SetLogger (
[input] logger : ZCore.ILogger)
Use this function to enable logging for this parameter channel instance. If logging is
enabled, every parameter request (Read and Write)
is written to the logger
.
If no Logging Instance is given here (logger=0
), logging is generally deactivated.
Inputs
logger
ILogger
SetName
METHOD SetName (
[input] name : ZCore.ZString)
This method can be used to give a name to the parameter channel instance, which is useful if logging is used.
Inputs
name
ZStringName of the ParameterChannel Instance, usually the name of the device which is connected on the Ethercat fieldbus
SetTimeout
METHOD SetTimeout (
[input] timeout : LREAL)
Sets the timeout values for the ADS-Requests. If reading or writing takes longer than this timeout, an error will be thrown and can be signaled with Error. If no user specific Timeout is set, the default Timeout set in DefaultTimeout is used. Especially for configurations with many configured axes this timeout should be increased to avoid running into it.
Inputs
TraceErrorStack
METHOD TraceErrorStack (
[input] trace : ZCore.IErrorTrace)
This method is used internally when recording an error trace.
Inputs
trace
IErrorTrace