FunctionBlocks General MC_RobotTaskFB - ThorstenBrach/SRCI GitHub Wiki
This functionblock manages various internal mechanisms for client-server communication and data processing. It includes the following key operations:
-
Establishes and verifies communication between the client (PLC) and server (RC).
-
Configures and verifies telegram numbers to ensure correct data transmission.
-
Manages cyclic, acyclic, and optional cyclic data within telegrams.
-
Handles the execution order of commands (ACR) based on priority.
-
Manages telegram sequences according to defined sequence IDs.
-
Logs events and handles user-relevant data.
-
Transfers user-defined configurations via the ExchangeConfiguration function.
-
Synchronizes configuration data between the server and client.
The function ensures the telegram number is correctly matched and handles discrepancies with error or warning messages.
Manages data areas for cyclic, acyclic, and optional cyclic data, ensuring sufficient space and proper reading/writing operations.
Ensures the client and server share synchronized configuration data, including tools, frames, loads, and work areas, with configurable synchronization modes and actions.
The function also handles message logging, provides user data storage, and supports user configuration settings, enabling customized behavior for tool/frame/load synchronization, delays, and other parameters.
VAR_INPUT
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
InternalLogger |
- |
For internal usage only |
- |
|
ExternalLogger |
- |
For internal usage only |
- |
|
LogLevel |
- |
For internal usage only |
- |
|
Enable |
- |
Set TRUE (default) to initialize the interface |
M |
|
RobotName |
- |
User defined command name |
M |
|
SystemTime |
- |
Date and time of the PLC |
M |
|
OnlineChange |
- |
Online change detected → recalculate pointer/references |
M |
|
AxesGroupID |
- |
For convenience, an RC with only one RA must assign ID 1 to this RA |
M |
|
ParCfg |
- |
Configuration parameter to configure the |
M |
VAR_IN_OUT
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
RobotInData |
ARRAY[0..RobotLibraryParameter.ROBOT_IN_DATA_MAX] |
- |
Inputs of PLC for communication from RC |
M |
RobotOutData |
ARRAY[0..RobotLibraryParameter.ROBOT_OUT_DATA_MAX] |
- |
Outputs of PLC for communication to RC |
M |
UserData |
- |
User data stored on the PLC |
M |
|
ToolData |
ARRAY[0..RobotLibraryParameter.TOOL_MAX-1] |
- |
ToolData stored on PLC |
M |
FrameData |
ARRAY[0..RobotLibraryParameter.FRAME_MAX-1] |
- |
FrameData stored on PLC |
M |
LoadData |
ARRAY[0..RobotLibraryParameter.LOAD_MAX-1] |
- |
LoadData stored on PLC |
M |
WorkAreas |
ARRAY[0..RobotLibraryParameter.WORK_AREAS_MAX-1] |
- |
Work areas stored on PLC |
M |
SWLimits |
- |
Software limits stored on PLC |
M |
|
DefaultDynamics |
- |
Default dynamics stored on PLC |
M |
|
ReferenceDynamics |
- |
Reference dynamics stored on PLC |
M |
|
SystemLog |
ARRAY[0..RobotLibraryParameter.SYSTEM_LOG_MAX] |
- |
System log on PLC |
M |
MessageLog |
ARRAY[0..RobotLibraryParameter.MESSAGE_LOG_MAX] |
- |
Message buffer on the PLC |
M |
AxesGroup |
- |
Robot assignment of function |
M |
VAR_OUTPUT
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
Busy |
- |
FB is being processed |
M |
|
Initialized |
- |
Interface is initialized. |
M |
|
Synchronized |
- |
Server and client were successfully synchronized. |
M |
|
Error |
- |
Error occurred during execution. See ErrorID for details |
M |
|
ErrorID |
- |
Error ID as raw value for error diagnosis |
M |
|
ErrorIDEnum |
- |
Error ID as enumeration for error diagnosis |
M |
|
ErrorAddTxt |
- |
Additional error text information |
M |
|
WarningID |
- |
Warning ID as raw value for identifying warnings |
M |
|
WarningIDEnum |
- |
Warning ID as enumeration for identifying warning |
M |
|
InfoID |
- |
Info ID for as raw value for identifying additional information |
M |
|
InfoIDEnum |
- |
Info ID for as enumeration for identifying additional information |
M |
|
InvalidFrames |
- |
Amount of counted invalid frames |
M |
RobotTaskParCfg
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
Com |
- |
Common parameter |
M |
|
Plc |
- |
PLC parameter |
M |
|
Rob |
- |
Robot parameter |
M |
RobotTaskParCfgCom
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
LifeSignTimeOut |
T#50MS |
Maximum allowed time between LifeSign increments before communication error. |
M |
|
TelegramLengthPlcToRob |
256 |
Frame size (bytes) for telegram from client (PLC) to server (robot) |
M |
|
TelegramLengthRobToPlc |
256 |
Frame size (bytes) for telegram from server (robot) to client (PLC) |
M |
RobotTaskParCfgPlc
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
CycleTime |
T#10MS |
PLC cycle time |
M |
|
Parameter |
- |
Configuration of plc parameter |
M |
|
OptionalCyclic |
- |
Configuration of optional cyclic data send to the Robot |
M |
RobotTaskParCfgPlcParameter
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
ManufacturedID |
- |
Manufactured ID |
M |
|
OrderID |
- |
Order ID |
M |
|
SerialNumber |
- |
Serial Number |
M |
|
FirmwareVersion |
- |
Firmware Version |
M |
|
InterfaceVersion |
- |
Client Interface Version |
M |
|
SynchronizationModes |
- |
Synchronization Modes |
M |
|
SyncUserInteraction |
- |
Synchronization needs user interaction |
M |
RobotTaskParCfgRob
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
Parameter |
- |
Configuration of robot parameter |
M |
|
OptionalCyclic |
- |
Configuration of optional cyclic data received from the Robot |
M |
RobotTaskParCfgRobParameter
Parameter | Data Type | Default Value | Description | Required |
---|---|---|---|---|
WaitAtBlendingZone |
- |
Configuration of robot parameter |
M |
|
AllowSecSeqWhileSubprogram |
- |
Configuration of robot parameter |
M |
|
AllowDynamicBlending |
- |
Allows blending when CallSubprogram is called in sequence and removed afterwards. |
M |
|
DelayTime |
- |
Defines waiting time of RC between receiving a first move command when motion queue is empty and starting the first movement |
M |
|
WaitForNrOfCmd |
- |
Define number of points required to calculate the blending. |
M |
|
SyncDelay |
0 |
Defines a delay time between detecting an inconsistency of configuration data between server and client and executing the defined SyncReaction. |
M |
|
SyncReaction |
- |
Specifies system reaction in case inconsistency of synchronization data is detected according to Table 6-81. |
M |
|
MessageLevel |
MessageLevelEnum.WARNING |
Defines up to which level of severity messages will be transmitted to the PLC’s message buffer |
M |
Declaration
VAR_GLOBAL
/// Inputs of PLC for communication from RC
RobotInData AT %I* : ARRAY[0..RobotLibraryParameter.ROBOT_IN_DATA_MAX ] OF BYTE;
/// Outputs of PLC for communication to RC
RobotOutData AT %Q* : ARRAY[0..RobotLibraryParameter.ROBOT_OUT_DATA_MAX ] OF BYTE;
/// Robot Task
RobotTask : MC_RobotTaskFB;
/// User data stored on the PLC.
UserData : UserData;
/// ToolData stored on PLC.
ToolData : ARRAY[0..RobotLibraryParameter.TOOL_MAX -1 ] OF Tool;
/// LoadData stored on PLC.
FrameData : ARRAY[0..RobotLibraryParameter.FRAME_MAX -1 ] OF Frame;
/// LoadData stored on PLC.
LoadData : ARRAY[0..RobotLibraryParameter.LOAD_MAX -1 ] OF Load;
/// Work areas stored on PLC.
WorkAreas : ARRAY[0..RobotLibraryParameter.WORK_AREAS_MAX -1] OF RobotWorkArea;
/// Software limits stored on PLC
SWLimits : SWLimits;
/// Default dynamics stored on PLC.
DefaultDynamics : DefaultDynamics;
/// Reference dynamics stored on PLC.
ReferenceDynamics : ReferenceDynamics;
/// System log on PLC
SystemLog : ARRAY[0..RobotLibraryParameter.SYSTEM_LOG_MAX ] OF STRING(RobotLibraryParameter.MESSAGE_TEXT_LEN);
/// Message buffer on the PLC - For more information refer to 5.5.11
MessageLog : ARRAY[0..RobotLibraryParameter.MESSAGE_LOG_MAX] OF AlarmMessage;
/// Robot assignment of function
AxesGroup : AxesGroup;
END_VAR
Parameterization
// Communication settings
RobotTask.ParCfg.Com.LifeSignTimeOut := T#100MS;
RobotTask.ParCfg.Com.TelegramLengthPlcToRob := 256;
RobotTask.ParCfg.Com.TelegramLengthRobToPlc := 256;
// PLC settings
RobotTask.ParCfg.PLC.CycleTime := REAL_TO_TIME(UDINT_TO_REAL(TwinCAT_SystemInfoVarList._TaskInfo[1].CycleTime)/10000);
RobotTask.ParCfg.PLC.Parameter.ManufacturedID := 99;
RobotTask.ParCfg.PLC.Parameter.OrderID := '12345678901234567890';
RobotTask.ParCfg.PLC.Parameter.SerialNumber := '1234567890123456';
RobotTask.ParCfg.PLC.Parameter.FirmwareVersion := '12345678';
RobotTask.ParCfg.PLC.Parameter.InterfaceVersion := '1.3';
// PLC synchronization settings
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Tool [SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Tool [SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Frame [SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Frame [SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Load [SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.Load [SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.WorkAreas [SyncTime.DURING_START_UP] := SyncMode.NO_SYNCHRONIZATION;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.WorkAreas [SyncTime. AFTER_START_UP] := SyncMode.NO_SYNCHRONIZATION;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.SWLimits [SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.SWLimits [SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.DefaultDynamics [SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.DefaultDynamics [SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.ReferenceDynamics[SyncTime.DURING_START_UP] := SyncMode.SERVER_TO_CLIENT;
RobotTask.ParCfg.PLC.Parameter.SynchronizationModes.ReferenceDynamics[SyncTime. AFTER_START_UP] := SyncMode.AUTOMATIC;
// PLC optional cyclic settings
RobotTask.ParCfg.PLC.OptionalCyclic.UseCallSubprogram := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseCartesianPosition := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseJointPosition := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseForce := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit04 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit05 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit06 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit07 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseTwoSequences := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseCartesianPositionExt := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.UseJointPositionExt := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit11 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit12 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit13 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit14 := FALSE;
RobotTask.ParCfg.PLC.OptionalCyclic.Bit15 := FALSE;
// Robot settings
RobotTask.ParCfg.Rob.Parameter.WaitAtBlendingZone := FALSE;
RobotTask.ParCfg.Rob.Parameter.AllowSecSeqWhileSubprogram := FALSE;
RobotTask.ParCfg.Rob.Parameter.AllowDynamicBlending := FALSE;
RobotTask.ParCfg.Rob.Parameter.DelayTime := 0;
RobotTask.ParCfg.Rob.Parameter.WaitForNrOfCmd := 1;
RobotTask.ParCfg.Rob.Parameter.SyncDelay := 0;
RobotTask.ParCfg.Rob.Parameter.SyncReaction := SyncReaction.NO_REACTION;
RobotTask.ParCfg.Rob.Parameter.MessageLevel := MessageLevel.WARNING;
// Robot optional cyclic settings
RobotTask.ParCfg.Rob.OptionalCyclic.UseCallSubprogram := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseCartesianPosition := TRUE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseJointPosition := TRUE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseForce := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseCurrent := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit05 := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit06 := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit07 := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseTwoSequences := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseCartesianPositionExt := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseJointPositionExt := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseForceExt := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.UseCurrentExt := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit13 := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit14 := FALSE;
RobotTask.ParCfg.Rob.OptionalCyclic.Bit15 := FALSE;
Call
// Call Robot Task
RobotTask( RobotName := 'SRCI_Robot',
Enable := Main.SystemReady ,
SystemTime := Main.SysTime,
OnlineChange := Main.OnlineChange,
RobotInData := RobotInData,
RobotOutData := RobotOutData,
UserData := UserData,
ToolData := ToolData,
FrameData := FrameData,
LoadData := LoadData,
WorkAreas := WorkAreas,
SWLimits := SWLimits,
DefaultDynamics := DefaultDynamics,
ReferenceDynamics := ReferenceDynamics,
SystemLog := SystemLog,
MessageLog := ClientDefines.MessageLog,
AxesGroup := AxesGroup,
LogLevel := LogLevelEnum.DEBUG
);