- Created by Luke Cerwin , last modified on Jun 29, 2022
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 3 Next »
This manual describes the various I/O drivers available for the Tsentry system. Both W32 and RTSS versions of most of the drivers are available.
Supported drivers include the following:
Allen Bradley PLC 2, PLC 3, and PLC 5
Nattional Instruments Process I/O controllers
GE 9030 / 9070 PLC
TCP/IP Generic Driver
Lantronix Terminal Server
Generalized Remote Device Connection Driver
Allen-Bradley Control Logic PLC
Allen-Bradley Process I/O Server
Communicates with Allen-Bradley PLC 5 systems
TCP/IP Communications over:
Standard Ethernet network connection
High Speed dedicated process I/O network with deterministic network performance
Software implemented as a C++ Class
Multiple PLC support
Supports:
Read Variables
Write variables
Integer Files
Floating Point Files
Capable of running 100ms Input and Output scan rep rates
The A-B 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.
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:
File Name | Description | Modifications |
---|---|---|
ABPlc.cpp | Driver mainline function | Modify configuration class calls for specific PLC configuration. Modify locations to read and write data. Modify input and output datagram structure definition |
ABPlcIn.cpp | ABPlc driver initialization | Insert required global common areas. |
PlcUsr.cpp | Process received values from PLC datagram and place in user data variables. Get application variables and store in datagra for transmission to PLC | Change as required |
tpriABPlc Class Descriptions
Summary - 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.
The following public member functions are provided as part of the tpriABPlc class:
tpriABPlc *pABPlc = new tpriABPlc;
Allocate a new tpriABplc object
destroy (tpriABPlcPlc *)pABPlc();
Destroy the tpriABPlc class object.
int Config (char *pHostName, int timeout);
where:
char *pHostName= host name or IP address
int timeout = time value for read and write operation in milliseconds
This function stores new configuration information for use by class functions
int GetConnStatus (void);
where:
return status = connection status
0 = unconnected
1 = connected
This function returns the status of the connection between the Compute system and the PLC
int SetReadFile(char *file, int offset, int num);
where:
char *file = PLC file name from which to read data
int offset = byte offset from start of ‘filename’ from which to read data
int num = number of data items to read
This function stores the PLC read control information for use by the ScanIO class member
int SetWriteFile(char *file, int offset, int num);
where:
char *file = PLC file name where to write data
int offset = byte offset from start of ‘filename’ to write data
int num = number of data items to write
This function stores the PLC read control information for use by the ScanIO class member
int Connect (void);
This function establishes a connection between the computer system and the PLC
int Disconnect (void);
This function breaks a connection between the computer system and the PLC
int ScanIO (int *igram, int *ogram, int *ipsta);
where:
int *igram = user memory address where PLC read data will be returned
int *ogram = user memory address where PLC write will be obtained
int *ipsta = addr of an integer variable where I/O status will be returned
This function first reads a single data block of 16 bit integers values from the PLC user register memory and then writes a block of 16 bit integers to the PLC memory. The plc locations for the read and write are obtained from prior calls to the SetReadFile90 and SetWriteFile() functions.
Some comments on the driver program 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
National Instruments Process I/O Driver
Handles National Instruments E-Series Boards
Direct program control over all I/O
Process I/O includes
12-bit A/I channels
12-bit A/O channels
Digital Inputs
Digital Outputs
High Speed bus access
A/I at 300KHZ sample rate
Software implemented as a C++ Class
Capable of running 1ms Input and Output scan rep rates
RTP (CPI) Process I/O Driver
The RTP (formerly CPI) process I/O driver will communicate with one or more chassis of process I/O interface cards via a UDP interface. The RTP 6700 is an intelligent controller and is located in one of the chassis. The process I/O controller and driver has the following characteristics:
Handles RTP / Computer Products Process I/O
Connection to RTP rack via Ethernet UDP
UDP/IP Communications over:
Standard Ethernet network connection
High Speed dedicated process I/O network with deterministic network performance
Process I/O includes:
12-bit & 14-bit A/I channels
12-bit A/O channels
Digital Inputs
Digital Outputs
Software implemented as a C++ Class
Capable of running 20ms Input and Output scan rep rates
The core of the driver is provided as a C++ class which implements the initialization, communications, and data conversion functions. A sample process is provided which calls the appropriate class members.
The configuration of the RTP control cards is specified in an .ini file which is read at driver startup. An example of this file is also included.
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:
File Name | Description | Modifications |
---|---|---|
sysRtp.ini | Initialization file that contains the configuration of the RTP racks and control cards. The file is stored in the application \pif directory | Accurately describe the process I/O cards to be scanned |
TsysPioCpi.cpp | Driver mainline function | Insert required global common areas |
PioAiConvert.cpp | Convert analog input values and store in appropriate application variables | Change as required |
PioAoConvert.cpp | Get application variables and store in buffer for transmission to hardware analog output channels | Change as required |
PioDiConvert.cpp | Convert digital input values (as bits in words) and store in appropriate application variables | Change as required |
PioDoConvert.cpp | Get application variables, convert to appropriate bits values, and store in buffer for transmission to hardware analog output channels | Change as required |
AiCntsToVolts | Convert a single analog input count value to a floating point volts value | Function set up to handle 14 bit A/D with 10.24 biploar input. Change if required to support other A/D hardware ranges |
AoVoltsToCnts | Convert a single volts value to counts for analog output | Function set up to handle 12 bit A/O with 10.24 biploar output. Change if required to support other A/O hardware ranges |
The RTP 6700 controller requires a set of configuration parameters for proper operation. To configure the 6700, connect the console port of the 6700 to a terminal or a PC running a terminal emulator (such as HyperTerminal). Terminal characteristics are 9600, 8, None, 1. Switch on the power to the 6700 and enter a “3” to the first prompt after power up. The following is an example of reasonable configuration process and parameters for the RTP 6700 controller:
A:\>echo off Datalight is a registered trademark of Datalight, Inc. CardTrick is a registered trademark of Datalight, Inc. ROM-DOS is a trademark of Datalight, Inc. Copyright 1989-1994 Datalight, Inc., All Rights Reserved Bad command or filename Loading the Ethernet Packet Driver smc9192 0x62 0x7 0x300 0x604 ... Current settings follow : Twisted pair interface, using select # 2 for interrupt & 6 packets reserved for Tx My Ethernet address is 00:80:F9:03:04:EC *********************************************** RTP Corp. * Pompano Beach, Florida. * Ethernet IO Bus Controller Version F.0.0 * ***********************************************
************************ PROTOCOL=TCP LINK=ETHERNET MAX_CONNECTIONS=1 CONNECTION_TIMEOUT=3 SERVICE_ACCESS_POINT=0 IP_ADDRESS=89.89.89.121 SUBNET_MASK=255.0.0.0 CMD_BUF_SIZE=1464 RESP_BUF_SIZE=1464 BAUD_RATE=38400 BPS MESSAGE_TRACE=OFF MAX_TRACE_BUFF_SIZE=1 CONNECTION_WIRING=TWISTED ************************ 1.- Revert Back to Default Configuration 2.- Continue with Saved Configuration 3.- Modify Configuration No input is necesary, if no change is desired 3 Select Protocol: [Current - 1] [Default - 0] 0 <Enter> - UDP 1 <Enter> - TCP 2 <Enter> - 802.2 <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 0 Select Link: [Current - 0] [Default - 0] 0 <Enter> - ETHERNET 1 <Enter> - SERIAL <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 0 Enter Maximum Number of Connections (1 - 4): [Current - 1] [Default - 1] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 1 Enter the Connection Timeout (0 - 600 seconds): [Current - 3] [Default - 3] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 3 Enter the Service Access Point (SAP) (0 - 254 even only): [Current - 0] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 0 Enter the IP Address (dotted decimal notation e.g. 255.2.3.3): [Current - 89.89.89.121] 10.0.0.2 Enter the Subnet Mask (dotted decimal notation e.g. 255.0.0.0): [Current - 255.0.0.0] 255.0.0.0 Enter the Command Buffer Size (1464 - 32727): [Current - 1464] [Default - 1464] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 1464 Enter the Response Buffer Size (1464 - 32727): [Current - 1464] [Default - 1464] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 1464 Select Baud Rate: [Current - 2] [Default - 2] 0 <Enter> - 9.60 KBPS 1 <Enter> - 19.2 KBPS 2 <Enter> - 38.4 KBPS 3 <Enter> - 57.6 KBPS 4 <Enter> - 115.2 KBPS <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 0 Select Trace: [Current - 0] [Default - 0] 0 <Enter> - OFF 1 <Enter> - ON <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 0 Enter the Trace Buffer size (1-63 KBytes): [Current - 1] [Default - 1] <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 1 Select the Connection Wiring [Current - 1] [Default - 0] 0 <Enter> - COAX 1 <Enter> - TWISTED <Enter> - Keep Current Value <Esc> - Exit Configuration without Saving S<Enter> - Save Configuration Selection: 1 Configuration Complete. ************************ PROTOCOL=UDP LINK=ETHERNET MAX_CONNECTIONS=1 CONNECTION_TIMEOUT=3 SERVICE_ACCESS_POINT=0 IP_ADDRESS=10.0.10.11 SUBNET_MASK=255.0.0.0 CMD_BUF_SIZE=1464 RESP_BUF_SIZE=1464 BAUD_RATE=9600 BPS MESSAGE_TRACE=OFF MAX_TRACE_BUFF_SIZE=1 CONNECTION_WIRING=TWISTED ************************
Enter Y to Accept Configuration, N to Modify it
Y
EIOBC Ethernet Address: 00-80-F9-03-04-EC
After the configuration is accepted, it will be stored on the controller. Cycling the power on the card will initialize the card to use these parameters.
The following is an example of a operational RTP initialization file. It describes a system with 16 Analog inputs (1 A/D card and 2 mux cards), 4 Digital input cards (64 bits), 32 Analog output channels (8 cards), and 4 digital output cards (64 bits) in two (2) RTP chassises. The RTP 6700 is set up for IP address 10.0.10.11
# --------------------------------------------------------------------------- # Cold Mill RTP Control Table # # This table defines the configuration information for the # RTP (Real Time Products) Process I/O system # It assumes connection via an Ethernet network and a RTP 6700 interface # # Section [SYSTEM] defines system wide parameters # Section [AI] defines Analog Inputs # Section [AO] defines Analog Outputs # Section [DI] defines Digital Inputs # Section [DO] defines Digital Outputs # # -------------------------------------------------------------------------------------- # [SYSTEM] # IPAddr: IP address of 6700 controller # #AI: Number of AI channels # #AO: Number of AO channels # #DI: Number of DI cards # #DO: Number of DO cards # #IPAddr #AI #DI #AO #DO 10.0.10.11 16 4 8 4 # [AI] # # Define analog input scan list 16 # # Field Definitions # # CORR_ID: Correlation ID. A 32 bit number that is transmitted to the # eiobc and returned from the eiobc for each I/O point. # Usually numbered sequentially. # # TYPE: An 8 bit number that defines the type of I/O to be performed. # There are currently four (4) types of I/O that can be # performed with the eiobc: # # TYPE DEFINITION # ---- ------------------- # 1 OUTPUT_BASIC # 2 OUTPUT_WITH_BIT_OPS # 3 INPUT_BASIC # 4 INPUT_WITH_BIT_OPS # # The TYPE used for analog inputs is 3, INPUT_BASIC. # # DEV_ADDRESS: Device address. An 8 bit number that defines the RTP # device address (chassis address). If the chassis address is # set to 0x31, the address used for this field should be 0x01. # # OPTION: A bit mask of options. A 16 bit value that is used as a mask # to control I/O options. For type 3 (INPUT_BASIC) I/O, the # options are defined as follows: # # Bit 15: Output command word contained in COMMAND # Bit 14: Check Test Return before writing output data # Bit 13: Wait DELAY number of microseconds for Test Return # before output. Only valid when Bit 14 is set. # Bit 12: Output data word contained in Output Data (OUT_DATA). # # Bit 11: Check Test Return before reading input data. # Bit 10: Wait Delay number of microseconds for Test Return # Only valid when Bit 11 set. # Bit 09: Perform an input operation and return data in # response. If this bit is not set, input is not # performed and only POINT_STATUS is returned # in response. # Bit 08: Perform a second input operation and return additional # data in response. Only valid if bit 09 is set. # If this bit is set and POINT_EXTENDED_INPUT return # is used. # Bit 07: Replace the Output Data (OUT_DATA) with the value # obtained from the second input operation for auto- # ranging purposes. Only valid if bit 08 is used. # # The OPTION value for analog inputs is 0x9E00. # # COMMAND: Command to the iobc. A 16 bit value that defines which # card in the chassis rack will be doing the analog # inputs. A value of 0x0500 in COMMAND indicates that # there is a analog input card in logical slot 0 # (physical slot 5) of the chassis. # # OUT_DATA: Output Data. A 16 bit value that is used to tell the # analog input card which input channel to read. Due # to the delay in reading sequential channels on the # same analog input card, it may be desirable to sequence # through all the analog input cards, reading all the # channel 0's, then all the channel 1's, etc. # # The card number and channel are defined as follows: # # bits 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 # x x x x y y y z z z z # # where xxxx defines the card number. # yyy defines the channel number. # zzzz defines the gain (0= +-10volts) # # These values go in the OUT_DATA field below # # DELAY: Delay value. A 16 bit value indicating the amount of # time after which, if the card is not ready, an error is # returned. Multiply us by 1.19 to get the proper delay. # A delay of 100 us == 100 * 1.19 = 119 (base 10) or # 77 (base 16). # # The DELAY value for analog inputs is typically 0x00FF. # # AND_VAL: A 16 bit value to logically AND with the output data # value (OUT_DATA). This value is not used for analog # inputs but must be present. # # The AND_VALUE value for analog inputs is 0x0000. # # OR_VAL: A 16 bit value to logically OR with the output data # value (OUT_DATA). This value is not used for analog # inputs but must be present. # # The OR_VALUE value for analog inputs is 0x0000. # # # DELAY is a HEX value indicating the number of microseconds to wait before # returning an error. Multiply us by 1.19 to get the proper delay. A delay # of 100 us == 100 * 1.19 = 119 (base 10) or 77 (base 16). # # # SC # LH # OA # TN # #CORR_ID TYPE DEV_ADDRESS OPTION COMMAND OUT_DATA DELAY(uS) AND_VAL XOR_VAL # 0000010 3 0x00 0x9E00 0x0500 0x0080 0x0077 0x0000 0x0000 0000011 3 0x00 0x9E00 0x0500 0x0090 0x0077 0x0000 0x0000 0000012 3 0x00 0x9E00 0x0500 0x00A0 0x0077 0x0000 0x0000 0000013 3 0x00 0x9E00 0x0500 0x00B0 0x0077 0x0000 0x0000 0000014 3 0x00 0x9E00 0x0500 0x00C0 0x0077 0x0000 0x0000 0000015 3 0x00 0x9E00 0x0500 0x00D0 0x0077 0x0000 0x0000 0000016 3 0x00 0x9E00 0x0500 0x00E0 0x0077 0x0000 0x0000 0000017 3 0x00 0x9E00 0x0500 0x00F0 0x0077 0x0000 0x0000 # 0000020 3 0x00 0x9E00 0x0500 0x0100 0x0077 0x0000 0x0000 0000021 3 0x00 0x9E00 0x0500 0x0110 0x0077 0x0000 0x0000 0000022 3 0x00 0x9E00 0x0500 0x0120 0x0077 0x0000 0x0000 0000023 3 0x00 0x9E00 0x0500 0x0130 0x0077 0x0000 0x0000 0000024 3 0x00 0x9E00 0x0500 0x0140 0x0077 0x0000 0x0000 0000025 3 0x00 0x9E00 0x0500 0x0150 0x0077 0x0000 0x0000 0000026 3 0x00 0x9E00 0x0500 0x0160 0x0077 0x0000 0x0000 0000027 3 0x00 0x9E00 0x0500 0x0170 0x0077 0x0000 0x0000 # [AO] # Define analog output scan list 8 # # Field Definitions # # CORR_ID: Correlation ID. A 32 bit number that is transmitted to the # eiobc and returned from the eiobc for each I/O point. # Usually numbered sequentially. # # TYPE: An 8 bit number that defines the type of I/O to be performed. # There are currently four (4) types of I/O that can be # performed with the eiobc: # # TYPE DEFINITION # ---- ------------------- # 1 OUTPUT_BASIC # 2 OUTPUT_WITH_BIT_OPS # 3 INPUT_BASIC # 4 INPUT_WITH_BIT_OPS # # The TYPE used for analog outputs is 2, OUTPUT_WITH_BIT_OPS. # # DEV_ADDRESS: Device address. An 8 bit number that defines the RTP # device address (chassis address). If the chassis address is # set to 0x31, the address used for this field should be 0x01. # # OPTION: A bit mask of options. A 16 bit value that is used as a mask # to control I/O options. For type 2 (OUTPUT_WITH_BIT_OPS) I/O, # the options are defined as follows: # # Bit 15: Output command word contained in COMMAND # Bit 14: Check Test Return before writing output data # Bit 13: Wait DELAY number of microseconds for Test Return # before output. Only valid when Bit 14 is set. # Bit 12: Output data word contained in Process Scan List # message. If this bit is not set then no output # word should be included in the Process # Scan List. # # The OPTION value for analog outputs is 0x9000. # # COMMAND: Command to the iobc. A 16 bit value that defines which # card in the chassis rack will be doing the analog # outputs. A value of 0x0505 in COMMAND indicates that # there is a analog output card in logical slot 5 # (physical slot 10) of the chassis. # (Note: logical slot = physical slot - 5.) # # OUT_DATA: Output Data. A 16 bit value that is used as output data # to the iobc. This value is not used for analog outputs # but must be present. # # The OUT_DATA value for analog outputs is 0x0000. # # DELAY: Delay value. A 16 bit value indicating the amount of # time after which, if the card is not ready, an error is # returned. Multiply us by 1.19 to get the proper delay. # A delay of 100 us == 100 * 1.19 = 119 (base 10) or # 77 (base 16). # # The DELAY value for analog outputs is typically 0x00FF. # # AND_VAL: A 16 bit value to logically AND with the output data # value in the Process Scan List command. Only valid when # Options Bit 12 is set. A value of 0x0FFF sends all 12 # bits of the output value to the output channel. # # The AND_VALUE value for analog outputs is 0x0FFF. # # XOR_VAL: A 16 bit value to exclusively OR with the results # obtained from ANDing the output value in the Process # Scan List command and the AND Value (AND_VAL). # Only valid when Options Bit 12 is set. This value # represents the channel number (0-4) of the analog # output card. # # #CORR_ID TYPE DEV_ADDRESS OPTION COMMAND OUT_DATA DELAY(uS) AND_VAL XOR_VAL 0000001 2 0x00 0x9000 0x0507 0x0000 0x00FF 0x0FFF 0x0000 0000002 2 0x00 0x9000 0x0507 0x0000 0x00FF 0x0FFF 0x4000 0000003 2 0x00 0x9000 0x0507 0x0000 0x00FF 0x0FFF 0x8000 0000004 2 0x00 0x9000 0x0507 0x0000 0x00FF 0x0FFF 0xC000 # 0000005 2 0x00 0x9000 0x0508 0x0000 0x00FF 0x0FFF 0x0000 0000006 2 0x00 0x9000 0x0508 0x0000 0x00FF 0x0FFF 0x4000 0000007 2 0x00 0x9000 0x0508 0x0000 0x00FF 0x0FFF 0x8000 0000008 2 0x00 0x9000 0x0508 0x0000 0x00FF 0x0FFF 0xC000 # [DI] # Define digital input scan list 4 # # Field Definitions # # CORR_ID: Correlation ID. A 32 bit number that is transmitted to the # eiobc and returned from the eiobc for each I/O point. # Usually numbered sequentially. # # TYPE: An 8 bit number that defines the type of I/O to be performed. # There are currently four (4) types of I/O that can be # performed with the eiobc: # # TYPE DEFINITION # ---- ------------------- # 1 OUTPUT_BASIC # 2 OUTPUT_WITH_BIT_OPS # 3 INPUT_BASIC # 4 INPUT_WITH_BIT_OPS # # The TYPE used for digital inputs is 3, INPUT_BASIC. # # DEV_ADDRESS: Device address. An 8 bit number that defines the RTP # device address (chassis address). If the chassis address is # set to 0x31, the address used for this field should be 0x01. # # OPTION: A bit mask of options. A 16 bit value that is used as a mask # to control I/O options. For type 3 (INPUT_BASIC) I/O, the # options are defined as follows: # # Bit 15: Output command word contained in COMMAND # Bit 14: Check Test Return before writing output data # Bit 13: Wait DELAY number of microseconds for Test Return # before output. Only valid when Bit 14 is set. # Bit 12: Output data word contained in Output Data (OUT_DATA). # Bit 11: Check Test Return before reading input data. # Bit 10: Wait Delay number of microseconds for Test Return # Only valid when Bit 11 set. # Bit 09: Perform an input operation and return data in # response. If this bit is not set, input is not # performed and onlu POINT_STATUS is returned # in response. # Bit 08: Perform a second input operation and return additional # data in response. Only valid if bit 09 is set. # If this bit is set and POINT_EXTENDED_INPUT return # is used. # Bit 07: Replace the Output Data (OUT_DATA) with the value # obtained from the second input operation for auto- # ranging purposes. Only valid if bit 08 is used. # # The OPTION value for digital inputs is 0x8A00. # # COMMAND: Command to the iobc. A 16 bit value that defines which # card in the chassis rack will be doing the digital # inputs. A value of 0x0503 in COMMAND indicates that # there is a digital input card in logical slot 3 # (physical slot 8) of the chassis. # (Note: logical slot = physical slot - 5.) # # OUT_DATA: Output Data. A 16 bit value that is used as output data # to the iobc. For digital inputs, this value is used as # an initialization value. # # The OUT_DATA value for digital inputs is 0x0000. # # DELAY: Delay value. A 16 bit value indicating the amount of # time after which, if the card is not ready, an error is # returned. Multiply us by 1.19 to get the proper delay. # A delay of 100 us == 100 * 1.19 = 119 (base 10) or # 77 (base 16). # # The DELAY value for digital inputs is typically 0x00FF. # # AND_VAL: A 16 bit value to logically AND with the output data # value (OUT_DATA). This value is not used for digital # inputs but must be present. # # The AND_VALUE value for digital inputs is 0x0000. # # OR_VAL: A 16 bit value to logically OR with the output data # value (OUT_DATA). This value is not used for digital # inputs but must be present. # # The OR_VALUE value for digital inputs is 0x0000. # # #CORR_ID TYPE DEV_ADDRESS OPTION COMMAND OUT_DATA DELAY(uS) AND_VAL XOR_VAL 0000001 3 0x01 0x8A00 0x0500 0x0000 0x00FF 0x0000 0x0000 0000002 3 0x01 0x8A00 0x0501 0x0000 0x00FF 0x0000 0x0000 0000003 3 0x01 0x8A00 0x0502 0x0000 0x00FF 0x0000 0x0000 0000004 3 0x01 0x8A00 0x0503 0x0000 0x00FF 0x0000 0x0000 # [DO] # Define digital output scan list 4 # # Field Definitions # # CORR_ID: Correlation ID. A 32 bit number that is transmitted to the # eiobc and returned from the eiobc for each I/O point. # Usually numbered sequentially. # # TYPE: An 8 bit number that defines the type of I/O to be performed. # There are currently four (4) types of I/O that can be # performed with the eiobc: # # TYPE DEFINITION # ---- ------------------- # 1 OUTPUT_BASIC # 2 OUTPUT_WITH_BIT_OPS # 3 INPUT_BASIC # 4 INPUT_WITH_BIT_OPS # # The TYPE used for digital outputs is 1, OUTPUT_BASIC. # # DEV_ADDRESS: Device address. An 8 bit number that defines the RTP # device address (chassis address). If the chassis address is # set to 0x31, the address used for this field should be 0x01. # # OPTION: A bit mask of options. A 16 bit value that is used as a mask # to control I/O options. For type 1 (OUTPUT_BASIC) I/O, the # options are defined as follows: # # Bit 15: Output command word contained in COMMAND # Bit 14: Check Test Return before writing output data # Bit 13: Wait DELAY number of microseconds for Test Return # before output. Only valid when Bit 14 is set. # Bit 12: Output data word contained in Process Scan List # message. If this bit is not set then no output # word should be included in the Process # Scan List. # # The OPTION value for digital outputs is 0xF000. # # COMMAND: Command to the iobc. A 16 bit value.... # # OUT_DATA: Output Data. A 16 bit value that is used as output data # to the iobc. This value is not used for digital outputs # but must be present. # # The OUT_DATA value for digital outputs is 0x0000. # # DELAY: Delay value. A 16 bit value indicating the amount of # time after which, if the card is not ready, an error is # returned. Multiply us by 1.19 to get the proper delay. # A delay of 100 us == 100 * 1.19 = 119 (base 10) or # 77 (base 16). # # The DELAY value for digital outputs is typically 0x00FF. # # AND_VAL: A 16 bit value to logically AND with the output data # value (OUT_DATA). This value is not used for digital # outputs but must be present. # # The AND_VALUE value for digital outputs is 0x0000. # # OR_VAL: A 16 bit value to logically OR with the output data # value (OUT_DATA). This value is not used for digital # outputs but must be present. # # The OR_VALUE value for digital outputs is 0x0000. # # # CORR_ID TYPE DEV_ADDRESS OPTION COMMAND OUT_DATA DELAY(uS) AND_VAL XOR_VAL 0000001 1 0x01 0xF000 0x0504 0x0000 0x00FF 0x0000 0x0000 0000002 1 0x01 0xF000 0x0505 0x0000 0x00FF 0x0000 0x0000 0000003 1 0x01 0xF000 0x0506 0x0000 0x00FF 0x0000 0x0000 0000004 1 0x01 0xF000 0x0507 0x0000 0x00FF 0x0000 0x0000 # End of RTP I/O Configuration File
A sample driver is provided in the examples subdirectories of the standard Tsentry distribution
GE 9030/9070 PLC Driver
Communicates with GE 9030 and GE 9070 PLC systems
TCP/IP Communications over:
Standard Ethernet network connection
High Speed dedicated process I/O network with deterministic network performance
Software implemented as a C++ Class
Multiple PLC support
Supports:
Read Variables
Write variables
Integer Files
Floating Point Files
Word (object) and bit reads and writes
Capable of running 100ms Input and Output scan rep rates
The GE 9030 / 9070 PLC must be set up with the proper IP address. This configuration is completed with the GE VersaMax 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.
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:
File Name | Description | Modifications |
---|---|---|
GePlcDrv.cpp | Driver mainline function | Insert required global common areas. Modify register files and values are required. Modify inout and output datagram structure definition |
PlcUsrInput.cpp | Process received values from PLC datagram and place in user data variables | Change as required |
PlcUsrOutput.cpp | Get application variables and store in datagra for transmission to PLC | Change as required |
GELPC Class Descriptions
The Tsentry GePlc class encapsulates the functionality required to communicate with the GE PLC (9030 and 9070) over a TCP/IP network.
The following public member functions are provided as part of the tpriGePlc class:
tpriGePlc *pGePlc = new tpriGePlc;
Allocate a new tpriGePlc object
destroy (tpriGePlc *)pGePlc();
Destroy the tpriGePlc class object.
int Init (char *piffile, char *tplcIpAddr, unsigned short tPortNo,
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
int Connect ();
Connect (using TCP/IP) to the PLC and open an application connection
int Write (char *seg, int ref, int size, int bMode, unsigned char *buffer);
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
int Read (char *seg, int ref, int size, int bMode, unsigned char *buffer);
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
int getSrpErrorCode();
Return an integer equal to the last SRTP (GE PLC protocol) error code
int Is_Connect ();
Return an integer that indicates whether the application has an open connection with the GE PLC
Some comments on the driver program below:
The global shared region addresses are normally passed to the functions PlsUsrInput and PlcUsrOutput by their calls in GePlcDrv. However, in this test/example program they have been commented out.
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 addreses, and the sizes of the blocks can be modified to fit the requirements of the application.
PlcUsrInput and PlcUsrOutput and the ‘datagram’ structures they reference should be modified as required to move appropriate variables to and from 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
TCP/IP Driver - TPRIRdcTcp
The I/O driver library includes the tpriRdcTcp class for communications across a TCP/IP link to a remote device. This class provides functions to open a connection to the device given its IP address/DNS name and the TCP/IP port number, to read and write data to and from the device, to close the connection when finished, and to listen on a port. Blocking and non-blocking modes are both supported individually for connections and reads. The library is composed of several static class functions that can be explicitly called without having to manage the underlying class itself.
Before the library functions can be used, the sockets need to be initialized using the Windows Sockets function WSAStartup. Here is an example:
WSADATA wsaData; int socketInit; // set up windows sockets socketInit = WSAStartup(0x0020, &wsaData); if (socketInit != 0) { // error initializing windows sockets std::cout << "Error initializing sockets.\n"; }
int tpriRdcTcp::open(int *devHndl, char *devName, int portNum, int blocking = -1, struct sockaddr_in *pServer = NULL) Open a connection to the specified device. Inputs: int *devHndl Pointer to device handle that will be returned from the open call. For non-blocking requests this must point to a handle equal to -1 on the first attempt and passed unchanged to subsequent open calls (made while open remains in progress). char *devName Remote device name. int portNum Remote device TCP/IP port number int blocking Flag indicating if the open should block until success/failure (1) or return immediately (0). Passing -1 indicates that the blocking state should remain unchanged from its previous value. sockaddr_in *pSvr Pointer to server structure that will be filled in by the open call. Once filled in, the same structure can be passed on subsequent blocking calls to speed up the connection process. Passing a NULL pointer will turn off this feature. Return value: Blocking calls: This function returns zero if successful or a positive integer if the open fails. If successful, the device handle will be stored in the location pointed to by devHndl. Non-Blocking calls: This function will return -1 to indicate that the open is still pending; call repeatedly until it returns a success or failure. int tpriRdcTcp::close(int devHndl) Close a connection associated with a device handle. Inputs: int devHndl Device handle as returned from the open call. Return value: Always 0. int tpriRdcTcp::read(int devHndl, char *rxBuf, int rxCnt, int blocking = -1) Read a set of data from a remote device. Inputs: int devHndl Device handle as returned from the open call. char *rxBuf Pointer to the buffer into which the received data should be placed. int rxCnt Maximum number of bytes to read. int blocking Flag indicating if the read should block until rxCnt bytes have been read (1) or return immediately (0) with whatever data is available. Passing -1 indicates that the blocking state should remain unchanged from its previous value. Return value: If successful, the number of characters successfully read is returned. 1 indicates that an error occurred, and information about that error is available through WSAGetLastError(). -99 indicates that the connection has been closed. int tpriRdcTcp::write(int devHndl, char *txBuf, int txCnt) Write a set of data to a remote device. Inputs: int devHndl Device handle as returned from the open call. char *txBuf Pointer to the buffer containing the data to be written. int txCnt Number of bytes to write. Return value: If successful, the number of characters successfully written is returned. 1 indicates an error occurred. int tpriRdcTcp::listen(int *devHndl, int *svrHndl, int portNum, int backLog, int blocking /* = -1 */, char *hostName /* = NULL */) Listen for incoming TCP/IP connections. Inputs: int *devHndl Pointer to device handle that will be returned when a remote device connects to the server. int *svrHndl Pointer to device handle associated with the server socket. This handle can be reused to accept multiple connections. This must point to a handle equal to -1 on the first attempt and passed unchanged to subsequent listen calls. int portNum Remote device TCP/IP port number. int backLog Maximum number of connections to allow. int blocking Flag indicating if the open should block until success/failure (1) or return immediately (0). Passing a -1 indicates that the blocking state should remain unchanged from its previous value. char *hostName Local device name (if desired). Return value: Blocking calls: This function returns zero if successful or a positive integer if the open fails. If successful, the device handle will be stored in the location pointed to by devHndl. Non-Blocking calls: This function will return -1 to indicate that no connections are pending; call repeatedly until it returns a success or failure.
Lantronix Terminal Server Driver - tpriRdcLts
The I/O driver library includes the tpriRdcLts class for communications through a Lantronix terminal server to a remote device. This class provides functions to open a connection to a specified port on the desired terminal server, to read and write data to and from the device attached to the terminal server, and to close the connection when finished. Blocking and non-blocking modes are both supported individually for connections and reads. The library is composed of several static class functions that can be explicitly called without having to manage the underlying class itself.
- No labels