IOF_SER_DRIVE_BackupEx
The function block "IOF_SER_DRIVE_Backup" allows to create and restore a binary backup file from within the PLC containing all S- and P-Parameters of the SERCOS. The parameter list IDN192 contains a list of all backup parameters of the drive and is used by default. Backup and restore require SERCOS to be in parameter mode (phase 2).
If bStdBackupList = TRUE (default setting) then parameter list IDN192 is used for the backup.
If bUserBackupList = TRUE then userdefined parameter list arrList is used for the backup.
Otherwise the parameter list IDN17, the list of all parameters, is used for the backup.
Restore requires a backup file that was created with the standard backup list (IDN192) or with a userdefined list. Some parameters of the parameter list IDN17 are write protected.
Backup and restore can create a CRC16-CCITT and a 16 bit check sum and store this in IDN142, if available. The option bCRCEnable is per default FALSE.
Internally, instances of the function blocks IOF_SER_IDN_Read, IOF_SER_IDN_Write, FB_FileOpen, FB_FileClose, FB_FileRead, FB_FileWrite are called.
The file format of the backup file is described in Backup-Fileformat.
A demo project for Backup/Restore with IOF_SER_DRIVE_BackupEx is in Sample03.
VAR_INPUT
VAR_INPUT
bCheck : BOOL;
bBackup : BOOL;
bRestore : BOOL;
bCRCEnable : BOOL;
bStdBackupList : BOOL := TRUE;
bUserBackupList : BOOL;
sNetId : T_AmsNetId;
nPort : UINT;
sComment : T_MaxString;
ePath : E_OpenPath := PATH_BOOTPATH;
sPathName : T_MaxString := 'DRIVEPAR.BIN';
tTimeout : TIME;
bIgnoreParamErr : BOOL;
END_VAR
bCheck: The check of the CRC and the checksum is activated by a positive edge at this input. The CRC and the checksum are stored in IDN142 and persistent in the IOF_SER_DRIVE_Backup. If the value of IDN142 and the persistent saved value are the same, then the output bCheckOK is set to TRUE, otherwise bCheckOK is set to FALSE.
bBackup: The backup is activated by a positive edge at this input.
bRestore: The restore is activated by a positive edge at this input.
bCRCEnable: The CRC16-CCITT and the 16 bit checksum are enabled with a steady TRUE at this input. The CRC and the checksum are stored in IDN142, if bCRCEnable = TRUE.
bStdBackupList: Determines if the backup list IDN192 (bStdBackupList = TRUE) is used for the backup or if the parameter list of all parameters IDN017(bStdBackupList = FALSE) is used for the backup. Restore requires a backup file created with list IDN192.
bUserBackupList: determines if the userdefined backup list arrList is used for the backup. By default the IDN192 is used for the backup. If bStdBackupList = FALSE and bUserBackupList = TRUE then the userdefined list arrList is used for the backup. Restore requires a backup file created with list IDN192 or with a user defined parameter list.
sNetId: It is possible here to provide the AmsNetId of the TwinCAT computer on which the ADS command is to be executed. If it is to be run on the local computer, an empty string can be entered.
nPort: The port number nPort is specified by the TwinCAT System Manager during the hardware configuration.
sComment: sComment is a comment that is written to/read from the file header of the backup file.
ePath: Determines the path of the backup and restore file. If ePath = PATH_BOOTPATH then the file is located in the TwinCAT boot folder, if ePath = PATH_GENERIC then the file is located in the folder specified in sPathName.
sPathName: Contains the path name or the file name of the backup and restore file, depending on ePath. If the boot path is used, then only the file name has to be set in sPathName. If the generic path is used, then sPathName has to contain the complete pathe and the file name.
tTimeout: States the length of the timeout that may not be exceeded by execution of the ADS command.
bIgnoreParamErr: Determines if Backup/Restore aborts or continues in case of parameter read/write errors. By default it is aborted (bIgnoreParamErr = FALSE). If ignore of errors is activated (bIgnoreParamErr = TRUE), then the skipped parameters are stored in the list arrSkippedList (parameter numbers and error numbers).
VAR_IN_OUT
VAR_IN_OUT
arrList : ST_SercosParamList;
arrSkippedList : ST_SercosParamErrList;
END_VAR
arrList: In case of backup via IDN192 (bStdBackupList = TRUE) the list arrList contains after the backup the list of the backup parameters from IDN192.
In case of userdefined backup (bUserBackupList = TRUE and bStdBackupList = FALSE) the list arrList has to contain the list of parameters before the backup is started.
In case of backup via IDN17 (bStdBackupList = FALSE and bUserBackupList = FALSE) the list arrList contains after the backup the list all parameters from IDN17.
arrSkippedList: Contains the list of skipped parameters (the parameter numbers and the error numbers).
See structure definitions below.
VAR_OUTPUT
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
bCheckOK : BOOL;
iSkippedParams : UINT;
iHandledParams : UINT;
END_VAR
bBusy: When the function block is activated this output is set. It remains set until and acknowledgement is received.
bError: If an ADS error should occur during the transfer of the command, then this output is set once the bBusy output is reset.
nErrId: Supplies the ADS error number or function block specific error code when the bError output is set.
bCheckOk: Is TRUE, if bCheck was successful.
iSkippedParams: Contains the number of skipped parameters (see arrSkippedList), if ignoring of parameter faults is active (bIgnoreParamErr = TRUE).
iHandledParams: Contains the number of successfully backuped/restored parameters.
Structure definitions
TYPE ST_SercosParamList :
STRUCT
iActCount : UINT;
iMaxCount : UINT;
iList : ARRAY [0..2047] OF UINT;
END_STRUCT
END_TYPE
iActCount: is the current number of parameters of a list * 2. Sercos stores the number of bytes here and a parameter number needs 2 bytes, f.i. the value 6 means 3 parameters.
iMaxCount: is the max. number of parameters of a list * 2. Sercos stores the number of bytes here and a parameter number needs 2 bytes, f.i. the value 6 means 3 parameters.
iList: is an array of up to 2048 parameter numbers.
TYPE ST_SercosParamErrList :
STRUCT
iActCount : UINT;
iMaxCount : UINT;
iList : ARRAY [0..2047] OF UINT;
iError : ARRAY [0..2047] OF UDINT;
END_STRUCT
END_TYPE
iActCount: is the number of skipped parameters (here 3 means 3 parameter faults)
iMaxCount: is the number of skipped parameters (here 3 means 3 parameter faults)
iList: is an array of up to 2048 parameter numbers, which where skipped because of parameter faults during access.
iError: is an array of up to 2048 error numbers, which occured during parameter access.
Function block specific error codes | Description |
---|---|
0x1003 | Wrong parameter mode |
0x1004 | Data parameter wrong value size |
0x1005 | False backup parameter type |
0x1006 | Backup list was not IDN 192 |
Requirements
Development environment | Target system type | IO hardware | PLC libraries to include |
---|---|---|---|
TwinCAT v2.8.0 Build > 735 | PC (i386) | Sercans SCS-P ISA; Sercans SCS-P PCI; | TcIoFunctions.Lib ( Standard.Lib; TcBase.Lib; TcSystem.Lib; TcUtilities.Lib are included automatically ) |