Networking and fieldbuses - file writing services
Below are the main services for writing configuration files for networking or fieldbus I/O drivers. Files are open using specific functions. When complete, they must be closed by calling the paFileClose function.
- Functions for MODBUS configuration:
paFileOpenWriteModbus - Open the MODBUS
configuration for writing
paFModbusSlave - Configurate the MODBUS
slave connection
paFModbusMaster - Create a MODBUS master
connection
paFModbusRequestSlave - Add a MODBUS
request on the slave connection
paFModbusRequestMaster - Add a MODBUS
request on a master connection
paFModbusVariable - Add a MODBUS variable
to the last declared request
- Functions for AS-i configuration:
paFileOpenWriteASi - Open the AS-i
configuration for writing
paFAsiApplyConfig - Set main flag
paFAsiMaster - Add a master device
paFAsiMasterDiag - Add a diagnostic
variable on the last declared master
paFAsiSlave - Add a slave device
paFAsiSlaveDiag - Add a diagnostic
variable on the last declared slave
paFAsiInput - Add an input variable on the
last declared slave
paFAsiOutput - Add an output variable on
the last declared slave
- Functions for other fieldbus drivers:
paFileOpenWriteFieldbus - Open a feldbus
configuration for writing
paFfbCreateMaster - Add a "master"
node
paFfbCreateSlave - Add a "slave" node
paFfbCreateVar - Add a "variable node
paFfbSetProperty - Set the the value of a
property
paFfbSelectRoot - Select the root node
paFfbSelectMaster - Select a "master"
node
paFfbSelectSlave - Select a "slave"
node
paFfbSelectVar - Select a "variable
node
- Functions for the binding configuration:
paFileOpenWriteBinding - Open the binding
configuration for writing
paFbindPublicVar - Add a public
variable
paFbindExternPort - Add an
extern port
paFbindCnxStatus - Add a connection status
variable
paFbindExternVar - Add an
extern variable
paFbindVarStatus - Add a status
variable
paFbindVarDateStamp - Add
a date stamp variable
paFbindVarTimeStamp - Add a time stamp
variable
FID := paFileOpenWriteModbus ()
Parameters:
FID : DINT; | File identifier or 0 if fail |
Description:
This function opens the MODBUS configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.
OK := paFModbusSlave (FID, SLAVENO)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function |
SLAVENO : DINT; | Default slave number for the MODBUS Slave server |
OK : BOOL; | TRUE if successful |
Description:
This function defines the slave number used for the MODBUS slave server.
OK := paFModbusMaster (FID, OPENMODBUS, ADDRESS, PORT, RECONNECT)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function |
OPENMODBUS : BOOL; | TRUE = Open Modbus protocol / FALSE = RTU protocol |
ADDRESS : STRING; | Configuration of the port or IP address |
PORT : DINT; | IP port number in case of MODBUS on ETHERNET |
RECONNECT : BOOL; | Option: tries to reconnect after error |
OK : BOOL; | TRUE if successful |
Description:
This function adds a new MODBUS master connection to the configuration.
OK := paFModbusRequestSlave (FID, REQUEST, ADDRESS, NBITEM, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function |
REQUEST : STRING; | Type of request (see notes) |
ADDRESS : DINT; | Base MODBUS address |
NBITEM : DINT; | Number of items (bits or words) |
NAME : STRING; | Optionnal description text |
OK : BOOL; | TRUE if successful |
Description:
This function adds a new MODBUS slave request. You can define variables of the request just after calling this function.
Warning: This function does not take care of address offsets defined by MODBUS. The first available address is always 0.
The following values are possible for the REQUEST parameter:
_MB_I_REG | Input registers |
_MB_H_REG | Holding registers |
_MB_I_BIT | Input bits |
_MB_C_BIT | Coil bits |
OK := paFModbusRequestMaster (FID,
MODE, REQUEST, SLAVENO, ADDRESS, NBITEM,
PERIOD, TIMEOUT, TRIALS, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function |
MODE : STRING; | Activation mode (see notes) |
REQUEST : STRING; | Type of request (see notes) |
SLAVENO : DINT; | Slave number of the device |
ADDRESS : DINT; | Base MODBUS address |
NBITEM : DINT; | Number of items (bits or words) |
PERIOD : TIME; | Activation period (for periodic requests) |
TIMEOUT : TIME; | Exchange timeout |
TRIALS : DINT; | Number of successive trials |
NAME : STRING; | Optionnal description text |
OK : BOOL; | TRUE if successful |
Description:
This function adds a new MODBUS master request. You can define variables of the request just after calling this function.
Warning: This function does not take care of address offsets defined by MODBUS. The first available address is always 0.
The following values are possible for the MODE parameter:
_MB_PERIODIC | Request activated periodically |
_MB_ONCALL | Request activated by a variable |
_MB_ONCHANGE | Request activated on a change of data (for "write" requests) |
The following values are possible for the REQUEST parameter:
_MB_READ_I_REG | Read Input registers |
_MB_READ_H_REG | Read Holding registers |
_MB_WRITE_H_REG | Write Holding registers |
_MB_READ_I_BIT | Read Input bits |
_MB_READ_C_BIT | Read Coil bits |
_MB_WRITE_C_BIT | Write Coil bits |
OK := paFModbusVariable (FID, MODE, OFFSET, MASK, TWOWORDS, SYMBOL)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteModbus function |
MODE : STRING; | Exchange mode (see notes) |
OFFSET : DINT; | Offset in the request |
MASK : DINT; | Mask for data exchange |
TWOWORDS : BOOL; | TRUE if data stored on 2 consecutive words |
SYMBOL : STRING; | Symbol of the variable |
OK : BOOL; | TRUE if successful |
Description:
This function connects a variable to the request defined by the last call to paFileModbusRequestSlave or paFileModbusRequestMaster functions.
The following values are possible for the MODE parameter:
_MB_DATA | Data exchange |
_MB_STATUS | The variable receives the connection status |
_MB_COMMAND | The variable is used for activating the request |
_MB_TRIAL | The variable receives the current trial number |
FID := paFileOpenWriteASi ()
Parameters:
FID : DINT; | File identifier or 0 if fail |
Description:
This function opens the AS-i configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.
OK := paFAsiApplyConfig (FID, APPLY)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
APPLY : BOOL; | If TRUE, the AS-i configuration is applied when the runtime stats |
OK : BOOL; | TRUE if successful |
Description:
This function sets the main AS-i configuration flags for applying the AS-i configuration at runtime.
OK := paFAsiMaster (FID, NAME, SETTINGS)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Description text |
SETTINGS : STRING; | AS-i controiller configuration string |
OK : BOOL; | TRUE if successful |
Description:
This function adds a master device to the AS-i configuration. AS-i slaves and diagnostic variables for this master must be added just after calling this function.
OK := paFAsiMasterDiag (FID, NAME, DIAG)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Symbol of the variable |
DIAG : DINT; | Wished diagnostic information |
OK : BOOL; | TRUE if successful |
Description:
This function adds a diagnostic variable to the last declared AS-i master.
The possible values are available for the DIAG parameter:
_ASI_M_CONFOK | Configuration OK |
_ASI_M_SLV0 | Slave detected at address 0 |
_ASI_M_AUTOACT | Auto-addressing is active |
_ASI_M_AUTOAV | Auto-addressing is available |
_ASI_M_CNFACT | Configuration is active |
_ASI_M_NORMAL | Normal mode |
_ASI_M_PWFAIL | Power fail detected |
_ASI_M_OFFLINE | Off Line mode |
_ASI_M_PERIPHOK | Periphery OK |
OK := paFAsiSlave (FID, NAME, ADDRESS, PROFILE)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Description text |
ADDRESS : DINT; | AS-i slave address |
PROFILE : STRING; | Slave profile written in AS-i convention: 'H.H.H.H' (hexadecimal digits) |
OK : BOOL; | TRUE if successful |
Description:
This function adds a slave device under the last declared AS-i master. AS-i variables for this master must be added for this slave just after calling this function.
OK := paFAsiSlaveDiag (FID, NAME, DIAG)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Symbol of the variable |
DIAG : DINT; | Wished diagnostic information |
OK : BOOL; | TRUE if successful |
Description:
This function adds a diagnostic variable to the last declared AS-i slave.
The possible values are available for the DIAG parameter:
_ASI_S_ACT | Slave active |
_ASI_S_DET | Slave detected |
_ASI_S_PRJ | Slave projected |
_ASI_S_COR | Slave corrupted |
_ASI_S_FLT | Periphery fault |
OK := paFAsiInput (FID, NAME, OFFSET)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Symbol of the variable |
OFFSET : DINT; | Input number (1 to 4) or 0 for all inputs in a byte |
OK : BOOL; | TRUE if successful |
Description:
This function adds an input variable to the last declared AS-i slave.
OK := paFAsiOutput (FID, NAME, OFFSET)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteASi function |
NAME : STRING; | Symbol of the variable |
OFFSET : DINT; | Output number (1 to 4) or 0 for all inputs in a byte |
OK : BOOL; | TRUE if successful |
Description:
This function adds an output variable to the last declared AS-i slave.
FID := paFileOpenWriteFieldbus (CONFIG)
Parameters:
CONFIG : STRING | Type of fieldbus - see notes |
FID : DINT; | File identifier or 0 if fail |
Description:
This function opens the selected fieldbus configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.
The "CONFIG" string is the prefix of the wizard DLL used for configuration. Available DLLs are stored in the "\IOD" folder where the Workbench is installed. You can also get the list of available configurations from the "Prompt" tab in the output window. For that, enter the following "?FB" command. Below is an example:
>?FB Fieldbus configuration wizards: K5BusAppIO: ApplicomIO configuration K5BusCAN: CAN bus K5BusHMS: Anybus configuration K5BusINTERBUS: Interbus-S K5BusIOTools: Brodersen IOTOOLS K5BusProfDP: Hilscher CIF Profibus K5BusProfNetIO: PROFINET IO K5BusShm: Win32 Shared memory K5BusSoftNet: SoftNet ProfibusDP K5BusSycon: Hilscher SYCON configuration K5BusXFLOW: XFlow K5ThinkIO: ThinkIO/IOSystem 758 K5ZenOnRT: Runtime to zenOn RT connection |
OK := paFfbCreateMaster (FID)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
OK : BOOL; | TRUE if successful |
Description:
This function adds a "master" node to the configuration.
OK := paFfbCreateSlave (FID)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
OK : BOOL; | TRUE if successful |
Description:
This function adds a "slave" node to the configuration. The node is added under the last created or selected "master" node.
OK := paFfbCreateVar (FID)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
OK : BOOL; | TRUE if successful |
Description:
This function adds a "variable" node to the configuration. The node is added under the last created or selected "slave" node.
OK := paFfbSetProperty (FID, PROP, VALUE)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
PROP : STRING | Internal name of the property - see notes |
VALUE : STRING | Value of the propery in neutral format - see notes |
OK : BOOL; | TRUE if successful |
Description:
This function adds a "variable" node to the configuration. The node is added under the last created or selected "slave" node.
The name of the property must be entered in "neutral" form, independently from the language selected for the Workbench. Also, for a check box or a drop-list property, you need to enter the value in neutral form, and not as displayed in the fieldbus configuration tool. To know the relationship in between neutral and displayed names and values, go to the "Prompt" tab in the output window and hit the "?FB" Command followed by the name of the configuration. This command lists all properties for each level of the selected configuration tree, giving neutral names and readable names, and lists all possible neutral values for boolean and enumerated properties. Example of syntax:
>?FB K5BusCan |
OK := paFfbSelectRoot (FID)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
OK : BOOL; | TRUE if successful |
Description:
This function selects the root node of the configuration tree. The root node is automatically selected when the file is open. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.
OK := paFfbSelectMaster (FID, MASTER)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
MASTER : DINT | 1-based index in the list of master nodes |
OK : BOOL; | TRUE if successful |
Description:
This function selects a "master" in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.
OK := paFfbSelectSlave (FID, MASTER, SLAVE)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
MASTER : DINT | 1-based index of the parent master node |
SLAVE : DINT | 1-based index in the list of slave nodes for the selected parent master |
OK : BOOL; | TRUE if successful |
Description:
This function selects a "slave" in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.
OK := paFfbSelectVar (FID, MASTER, SLAVE, VARIABLE)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteFieldbus function |
MASTER : DINT | 1-based index of the parent master node |
SLAVE : DINT | 1-based index of the parent slave node |
VARIABLE : DINT | 1-based index in the list of variable nodes for the selected parent slave |
OK : BOOL; | TRUE if successful |
Description:
This function selects a "variable" in the configuration tree. Selecting a node is required for setting its properties or adding child nodes. It is not work to select a node immediately after its creation.
FID := paFileOpenWriteBinding ()
Parameters:
FID : DINT; | File identifier or 0 if fail |
Description:
This function opens the binding configuration file for writing. This functions removes the contents of the configuration if it already exist. When written, the file must be closed by calling the paFileClose function.
FID := paFbindPubilcVar (FID, ID, NAME, HYSTP, HYSTN)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ID : DINT; | ID of the binding link |
NAME : STRING; | Symbol of the variable |
HYSTP : STRING; | Positive hysteresis in IEC syntax (or empty string) |
HYSTN : STRING; | Negative hysteresis in IEC syntax (or empty string) |
OK : BOOL; | TRUE if successful |
Description:
This function adds a public variable in the binding configuration.
FID := paFbindExternPort (FID, ADDR, PORT, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ADDR : STRING; | IP address |
PORT : DINT; | IP port number |
NAME : STRING | Optional description text |
OK : BOOL; | TRUE if successful |
Description:
This function adds a public variable in the binding configuration. Immediately after calling this function, you can use other functions to declare external bound variables.
FID := paFbindCnxStatus (FID, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
NAME : STRING; | Symbol of the bound variable |
OK : BOOL; | TRUE if successful |
Description:
This function binds a variable for getting the connection status. The variable is bound to external port declared by the last call to the paFbindExternPort function.
FID := paFbindExternVar (FID, ID, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ID : DINT; | ID of the binding link |
NAME : STRING; | Symbol of the bound variable |
OK : BOOL; | TRUE if successful |
Description:
This function binds a variable for data exchange. The variable is bound to external port declared by the last call to the paFbindExternPort function.
FID := paFbindVarStatus (FID, ID, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ID : DINT; | ID of the binding link |
NAME : STRING; | Symbol of the bound variable |
OK : BOOL; | TRUE if successful |
Description:
This function binds a variable for getting the status of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.
FID := paFbindVarDateStamp (FID, ID, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ID : DINT; | ID of the binding link |
NAME : STRING; | Symbol of the bound variable |
OK : BOOL; | TRUE if successful |
Description:
This function binds a variable for getting the date stamp of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.
FID := paFbindVarTimeStamp (FID, ID, NAME)
Parameters:
FID : DINT; | File identifier returned by the paFileOpenWriteBinding function |
ID : DINT; | ID of the binding link |
NAME : STRING; | Symbol of the bound variable |
OK : BOOL; | TRUE if successful |
Description:
This function binds a variable for getting the time stamp of a binding link. The variable is bound to external port declared by the last call to the paFbindExternPort function.