...
Expand | ||
---|---|---|
| ||
Some comments on the driver program below:
|
National Instruments Process I/O Driver
Expand | ||
---|---|---|
| ||
|
...
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The core of the driver is provided as a C++ class which implements the initialization and communications functions. A sample process is provided which calls the appropriate class members. The IP address, configuration, 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:
|
GELPC Class Descriptions
Expand | ||
---|---|---|
The following public member functions are provided as part of the tpriGePlc class:
long cTimeOut, long sTimeOut, long rTimeOut); where: char *piffile = initialization file name (currently not supported) = NULL char *tplcIpAddr = IP address of the PLC in xxx.xxx.xxx.xxx format unsigned short tPortNo = port (service) number of the TCP support in the GE PLC. This value is normally fised at 18245 by GE. long cTimeOut = Connection timeout value in milliseconds long sTimeOut = Send message timeout value in milliseconds long rTimeOut = receive message timeout value in milliseconds This function stores parameter values for use by the member functions of the class
where char *seg = segment (plc memory area) type “R” = register variable "L" = Local Data Table (%L) "P" = Program Data Table (%P) "R" = Register Table (%R) "AI" = Analog Input Table (%AI) "AQ" = Analog Output Table (%AQ) "I" = Discrete Input Table, byte mode (%I) "Q" = Discrete Output Table, byte mode (%Q) "T" = Discrete Temporary Table, byte mode (%T) "M" = Discrete Internal Table, byte mode (%M) "SA" = Discrete System A Table, byte mode (%SA) "SB" = Discrete System B Table, byte mode (%SB) "SC" = Discrete System C Table, byte mode (%SC) "S" = Discrete System D Table, byte mode (%S) "G" = Genius Global Data Table, byte mode (%G) "GA" = Genius Global Data Table, byte mode (%GA) int ref = 1st variable within segment to transfer (beginning of table = 1) int size = size of transfer in number of words, bytes or bits (see bmode) int bmode = units size; 0 = words or bytes, 1 = bits unsigned char *buffer = pointer to application program data buffer This function writes an application buffer to the PLC
where char *seg = segment (plc memory area) type See definitions in the Write function int ref = 1st variable within segment to transfer (beginning of table = 1) int size = size of transfer in native units (words, bytes or bits) see bmode int bmode = transfer unit size; 0 = words or bytes, 1 = bits unsigned char *buffer = pointer to application program data buffer This function reads an application buffer from the PLC
Return an integer equal to the last SRTP (GE PLC protocol) error code
Return an integer that indicates whether the application has an open connection with the GE PLC |
...
TpriModPlc Class Descriptions
Expand | ||
---|---|---|
| ||
The Tsentry tpriModPlc class encapsulates the functionality required to communicate with the Modicon Quantum PLCs over a TCP/IP network. |
Expand | ||
---|---|---|
| ||
The following public member functions are provided as part of the tpriModPlc class:
Allocate a new tpriModPlc object
Destroy the tpriModPlc class object.
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
unsigned char timeoutticks, unsigned char timeoutmultiplier, unsigned long otrpi, unsigned long torpi ); where: int sTimeOut = Send message timeout value in milliseconds Default value = 2000 int rTimeOut = receive message timeout value in milliseconds Default value = 2000 This function stores timeout parameter values for use by the member functions of the class
where: unsigned short vendorid = Destination ID default value = 1 This function stores new values for the Destination ID
where: int noBytes = the maximum number of data bytes that will be placed in a single PDU default value = 125 a PDU is a protocol Data Unit and is equivalent to a single Ethernet frame valid values range between 2 and 125, inclusive lower values may produce more frames to transfer the same user data higher values may produce fewer frames to transfer the same user data This function sets a new value for the maximum number of user data bytes to be included in a single Ethernet frame (PDU) that is transmitted to the PLC. A value too low will increase the number of Ethernet frames that will be required to send a given number of user data bytes and reduce throughput. A number too high will not be understood or acknowledged by the PLC.
where: char *hostname = host name, or IP addresses expressed as a character string short int port = TCP/IP port number This function establishes a connection between the computer system and the Modicon PLC
This function breaks a connection between the computer system and the Modicon PLC
where: int offset = PLC memory offset in 16 bit words from which to read data int noElements = number of 16 bit integer data elements to read void *buf = address of user supplied data buffer This function reads a single data block of 16 bit integers values from the PLC user register memory starting at ‘offset’ words from 40000 and stores the results in a user defined buffer
where: int offset = PLC memory offset in 16 bit words from which to write data int noElements = number of 16 bit integer data elements to write void *buf = address of user supplied data buffer This function writes a single block of user supplied 16 bit data words to the PLC user register memory starting at ‘offset’ words after 40000 |
Expand | ||
---|---|---|
| ||
Some comments on the driver program follow: 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. |
VMIC Reflective Memory Driver
Expand | ||
---|---|---|
| ||
This driver provides an interface to an internal VMIC reflective memory card. It manages both reading and writing variables to the card’s onboard memory, which the card automatically synchronizes with all other cards on the optical network. The driver supports the following:
|
Expand | ||
---|---|---|
| ||
There is no specific card configuration required for the VMIC reflective memory driver. Simply put the card into an empty full-length PCI slot, and the software driver manages the rest. |
Expand | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||
The VMIC driver is configured by a flat ASCII file divided into [Sections]. The following sections are required in this file: [General] This section defines general parameters for the VMIC device. The parameters are specified in the standard Key=Value pair format.
Defines the device index of the card you wish to use. By default this value is 1, and unless you have more than one VMIC card, this parameter is not needed.
Defines the card type that you wish to use. Supported values are ‘PCI-5576’ and ‘PCI-5579’ (no quotes). If this parameter is not specified, the driver will search for the first supported device that it can find.
This optional flag sets whether or not the driver will check your variable list to make sure that no two variables overlap one another in the VMIC memory buffer. For instance, two variables may mistakenly both be configured to write to the same bytes on the card. If this flag is set the driver will detect this overlap and fail to initialize. A message will be logged to the console to indicate the offending variables, and the ini file will need to be corrected before the driver will work. By default this option is enabled; set the flag to 0 to turn it off.
This optional parameter specifies an output text file to which the VMIC driver will write a complete description of all variables and their associated offsets into the VMIC reflective memory buffer. This is particularly useful when transferring entire structures and you want to know the offsets for each of the constituent variables contained in those structures. [VarDef] This section defines all variables that are to be read from or written to the reflective memory segment. Each line in this section defines a single variable in a set of whitespace-delimited fields:
Empty lines or lines beginning with the ‘#’ symbol are ignored.
The fields for each variable are:
The variable name within the TSENTRY data dictionary (identical to that used by Probe, etc.). Besides individual variables, entire arrays or structures may also be specified.
Flag specifying whether the variable is to be read from the card (R) or written to the card (W).
Offset into the VMIC onboard memory where this variable is to be read from or written to. This value can be specified in hex with the ‘0x’ prefix or in decimal. The data will be reflected in the memory of all other VMIC cards in the ring at this same offset. Note that offsets 0x00-0x3F are reserved for use by the VMIC card and cannot be used for reflected data.
Optional parameter used if the data on the card should be interpreted in a format different from that inside the PC’s internal memory. Typically this is used if the internal variable is a 4-byte integer but should be read/written as a 2-byte integer. This parameter applies only if an individual variable is specified; it will not automatically convert arrays or elements inside of structures. The following remote types are supported: VT_I1 1-byte integer (C/C++ character) VT_I2 2-byte integer (C/C++ short) VT_I4 4-byte integer (C/C++ long) VT_I8 8-byte integer (C/C++ __int64) VT_R4 1-byte integer (C/C++ float) VT_R8 1-byte integer (C/C++ double) |
Expand | ||
---|---|---|
| ||
The following public member functions are provided as part of the tpriVmic class:
|
Expand | ||
---|---|---|
| ||
A sample driver is provided in the examples subdirectories of the standard TSENTRY distribution. |