...
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The core of the driver is provided as a C++ class that implements the initialization and communications functions. A sample process is provided which calls the appropriate class members. The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions. The following is a list of the provided driver files. After review of the example driver, the user is required to modify the files as indicated:
|
...
TpriABPlc Class Descriptions
Expand | ||
---|---|---|
| ||
The Tsentry tpriABPlc class encapsulates the functionality required to communicate with the Allen Bradley PLC 2, PLC3, and PLC5 PLCs over a TCP/IP network. |
...
Expand | ||
---|---|---|
| ||
The custom device driver class then overrides a set of virtual functions that will be called by the base classes at the appropriate times. These virtual functions are:
|
...
Allen Bradley Control Logix PLC Driver
Expand | ||
---|---|---|
| ||
This driver:
Capable of running 500ms Input and Output scan rep rates, depending on data buffer size. |
Expand | ||
---|---|---|
| ||
The Allen Bradley PLC must be set up with the proper IP address. This configuration is completed with the A-B software. The IP must be chosen such that it lies within the subnet selected for the specific Ethernet controller used for communications. If the Ethernet controller is one that is controlled by the Windows 2000 system, the subnet is specified in the network setup utility of the control panel. If the Ethernet controller is one that is controlled by the RTX Real-Time TCP/IP controller, the IP address is specified in the file d:\LocNtRt\sys\pif\RtxTcp.ini. |
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The core of the driver is provided as a C++ class that implements the initialization and communications functions. A sample process is provided which calls the appropriate class members. The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions. The following is a list of the provided driver files. After review of the example driver, the user is required to modify the files as indicated:
|
Expand | ||
---|---|---|
| ||
The Tsentry CLeip class encapsulates the functionality required to communicate with the Allen Bradley 5500 and 5555 PLCs over a TCP/IP network. The following public member functions are provided as part of the tpriCLeip class:
where: int TraceLevel = debug trace level for class operations default value = 30 valid values range between 0 and 100, inclusive lower values produce less debug information higher values produce more debug information debug information written using LogMsg function This function stores a new value for the TraceLevel parameter
where: int port = Ethernet Port number Default value = 1 This function stores a new value for the Ethernet Port parameter. This communications parameter defines the port number for the Ethernet controller in the PLC chassis
where: int slot = Control Logix process slot number Default value = 0 This function stores a new value for the Ethernet Port parameter. This communications parameter defines the slot in which the Control Logix processor resides.
unsigned char timeoutticks, unsigned char timeoutmultiplier, unsigned long otrpi, unsigned long torpi ); where: int sTimeOut = TCP Send message timeout value in milliseconds Default value = 2000 int rTimeOut = TCP Receive message timeout value in milliseconds Default value = 2000 unsigned char ticktime = (optional) Protocol Tick time (see below) Default value = 10 unsigned char timeoutticks = (optional) TickTimes multiplier (see below) Default value = 14 Minimum value = 1 Maximum value = 255 unsigned char timeoutmultiplier = (optional) Inactivity timeout (see below) Default value = 1 Minimum value = 1 Maximum value = 255 unsigned long otrpi = (optional) Originator->Term Reqested packet interval (u-sec) Default value = 2064960 unsigned long torpi = (optional) Terminator->Orig Reqested packet interval (u-sec) Default value = 2064960
This function stores timeout parameter values for use by the member functions of the class. The values sTimeOut and rTimeOut are used to determine the maximum time that will elapse for a single user level call (read or write, respectively) to transfer data to or from the PLC. If this timeout is exceeded, the I/O request will return to the caller indicating a timeout has occurred. The remaining values are used to define the PLC’s connection session timeout information. The values ticktime and timeoutticks are used to calculate the maximum time allowed for a connection request to be serviced by the PLC. If the PLC cannot establish a connection session within this amount of time, the Connect method will return to the caller an error indicating that a timeout has occurred. This timeout value is calculated by the following formula: Connection_Timeout (ms) = 2^(ticktime) * timeoutticks
The values timeoutmultiplier otrpi (which stands for Originator->Terminator Requested Packet Interval) and torpi (Terminator->Originator Requested Packet Interval) determine the inactivity timeout of the PLC session. If this timeout is exceeded BETWEEN calls to the driver (more precisely, between protocol messages sent between the control system and the PLC), the PLC connection session will time out, and the connections to the PLC must be rebuilt. Subsequent user calls to the driver to transfer data between the control system and the PLC will find the connection destroyed and will return an error. This timeout value is calculated by the following formula:
where: unsigned int connid = Logical Connection ID Default value = 0x0b000100 This function stores a new value for the Logical Connection ID parameter
where: unsigned short connsn = Logical Connection Serial Number
This function stores a new value for the Logical Connection Serial Number
where: unsigned short vendorid = Originator (local system) vendor ID default value = 1 unsigned int sn = Originator Sequence Number default value = 0xBC1C0042 This function stores new values for the Originator (local system) information
where: char *hostname = host name, or IP addresses expressed as a character string short int port = TCP/IP port number name, or
This function establishes a connection between the computer system and the Allen-Bradley Control Logix PLC. Note that if a connection has already been established with a given connection serial number, no other connection may be made to that PLC with the same connection serial number until that connection is either gracefully disconnected or has timed out due to inactivity.
This function breaks a connection between the computer system and the Allen-Bradley Control Logix PLC
int dataType, void *buf); where: int adrType = address type void *FileName = file name within PLC from which to read data int offset = offset (in data variables) from which to start data read int noElements = number of data elements to read int dataType = type of data to be read void *buf = address of user supplied data buffer This function reads a single data block from the PLC and stores the results in a user defined buffer. Offsets may work in one of two ways. If the PLC contains a variable array called by a file name of “PLCVars”, function calls to retrieve data starting at the 61st element of this array could contain 2nd and 3rd arguments of: “PLCVars”, 60 or, “PLCVars[60]”, 0 Legal values for the dataType argument are: CL_SINT – 1-byte integers CL_INT – 2-byte integers CL_DINT – 4-byte integers CL_REAL – IEEE 4-byte floating point numbers
int dataType, void *buf); where: int adrType = address type void *FileName = file name within PLC to write user data int offset = offset (in data variables) from which to start data write int noElements = number of data elements to write int dataType = type of data to be written void *buf = address of user supplied data buffer containing write data This function writes a single data block to the PLC from the user defined buffer. Offsets may work in one of two ways. If the PLC contains a variable array called by a file name of “PLCVars”, function calls to write data starting at the 61st element of this array could contain 2nd and 3rd arguments of: “PLCVars”, 60 or, “PLCVars[60]”, 0 Legal values for the dataType argument are: CL_SINT – 1-byte integers CL_INT – 2-byte integers CL_DINT – 4-byte integers CL_REAL – IEEE 4-byte floating point numbers
where: void *FileName = file name within PLC from which to read data int offset = offset (in data variables) from which to start data read int noElements = number of data elements to read int *dataType = pointer to an integer variable where the type of the data read shall be returned void *buf = address of user supplied data buffer This function reads a single data block from the PLC and stores the results in a user defined buffer. Legal values returned in the dataType variable are: CL_SINT – 1-byte integers CL_INT – 2-byte integers CL_DINT – 4-byte integers CL_REAL – IEEE 4-byte floating point numbers
where: void *FileName = file name within PLC to write user data int offset = offset (in data variables) from which to start data write int noElements = number of data elements to write int dataType = type of data to be written void *buf = address of user supplied data buffer containing write data This function writes a single data block to the PLC from the user defined buffer. Legal values for the dataType argument are: CL_SINT – 1-byte integers CL_INT – 2-byte integers CL_DINT – 4-byte integers CL_REAL – IEEE 4-byte floating point numbers |
Expand | ||
---|---|---|
| ||
Some comments on the driver program are below: This test program, on each expiration of the process timer, writes a single block of data to the PLC and then reads a single block of data. This sequence, the number of reads and writes, their addresses, and the sizes of the blocks can be modified to fit the requirements of the application. PlcUsr and the ‘datagram’ structures they reference should be modified as required to reference appropriate variables in application variables for transfer between the PLC and the control system. A sample driver is provided in the examples subdirectories of the standard Tsentry distribution |
Modicon PLC Driver
Expand | ||
---|---|---|
| ||
This driver:
Capable of running 500ms Input and Output scan rep rates, depending on data buffer size. |
Expand | ||
---|---|---|
| ||
The Modicon PLC must be set up with the proper IP address. This configuration is completed with the Schneider Automation software. The IP must be chosen such that it lies within the subnet selected for the specific Ethernet controller used for communications. If the Ethernet controller is one that is controlled by the Windows 2000 system, the subnet is specified in the network setup utility of the control panel. If the Ethernet controller is one that is controlled by the RTX Real-Time TCP/IP controller, the IP address is specified in the file d:\LocNtRt\sys\pif\RtxTcp.ini. Enough memory must be installed in the PLC to support the data buffer size that will be requested by the software reads and writes. |
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The core of the driver is provided as a C++ class that implements the initialization and communications functions. A sample process is provided which calls the appropriate class members. The IP address, configuration information, and data areas to be read and written are passed as calling parameters to the class functions. The following is a list of the provided driver files. After review of the example driver, the user is required to modify the files as indicated:
|