Rockwell Allen Bradley

For Allen Bradley and Rockwell Automation controllers, SQL4automation provides the SQL4RSLogix Add-On Instruction and sample projects for ControlLogix and CompactLogix systems. Communication is via Ethernet/IP socket. Sample projects are available in both Ladder and Structured Text.

Connecting Rockwell Allen Bradley PLC to SQL Databases, MES, ERP

SQL4RSLogix  uses an Ethernet/IP socket connection to the SQL4automation Connector.  Supported Ethernet communication modules include 1756-EWEB, 1756-EN2Txx, and  1768-EWEB (CompactLogix). Controllers with integrated Ethernet/IP interfaces  on the CPU are also supported. Sample projects are provided for ControlLogix  (1756-L63) and CompactLogix (1769-L18ER-BB1B) and can be adapted to other  controller types by changing the controller settings.

The  SQL4RSLogix Add-On is imported via Import Add-On Instruction in the  Controller Organizer. Tags are imported separately via Tool > Import >  Tags and Comments. Data types (REQUEST, COLUMN, VALUE, PARAMETER) are  configured under Controller Organizer > Data Types and can be resized  based on the expected data volume. Note: CompactLogix controllers support  only Unconnected connections; ControlLogix controllers also support Connected  and Large Connection types.

The following Rockwell Allen-Bradley PLC controllers and communication modules can establish TCP socket connections and are therefore compatible with SQL4automation:

Project-Specific Adjustments

The following project-specific adjustments must be made to the SQL4automation function block:

SQL4automation Link Settings

The  SQL4automation Connector is operated with the target setting  "Standard" for Allen Bradley / Rockwell controllers. The  destination is passed as a string: e.g., '192.168.1.202 ?port=11001'. The  configuration is completed in just a few clicks.

FAQ’s

Frequently Asked Questions to Rockwell Allen Bradley

Which Allen Bradley controllers are compatible with SQL4automation?

SQL4automation supports ControlLogix and CompactLogix controllers equipped with Ethernet/IP socket-capable modules (1756-EWEB, 1756-EN2Txx, 1768-EWEB) or an integrated Ethernet/IP CPU interface. Sample projects are provided for the 1756-L63 ControlLogix5563 and 1769-L18ER-BB1B CompactLogix, and can be easily adapted to other models by changing the controller settings.

What is the difference between ControlLogix and CompactLogix integration?

CompactLogix controllers support only Unconnected connections. ControlLogix controllers also support Connected connections and Large Connections (on 1756-EN2xx modules with RSLogix 5000 v20+). For CompactLogix, select the CompactLogix sample project; for ControlLogix, use the ControlLogix sample project. Both are available in Ladder and Structured Text.

How is the SQL query assembled and sent from an Allen Bradley PLC?

The SQL query is built as a string and placed in the saRequest REQUEST array. The function block is called with the destination string ('192.168.1.202 ?port=11001') and the Ethernet module path (EWEB_PATH). Setting xExecute to 1 triggers the request; xStart can be used for automated repeated execution. Results are stored in saTableValue (VALUES array).

What programming languages are supported in the sample projects?

Sample projects are provided in both Ladder Diagram and Structured Text for both ControlLogix and CompactLogix. There are four sample files in total: Sample_S4A_CompactLogix_Ladder.ACD, Sample_S4A_CompactLogix_ST.ACD, Sample_S4A_ControlLogix_Ladder.ACD, and Sample_S4A_ControlLogix_ST.ACD.

Which SQL databases can be connected to an Allen Bradley PLC via SQL4automation?

All ODBC-compatible databases are supported, including Microsoft SQL Server, MySQL, MariaDB, PostgreSQL, Oracle, and SQLite. The database is configured in the SQL4automation Connector on the Windows PC. No changes to the RSLogix project are required when switching databases.

Which Allen Bradley / Rockwell controllers has SQL4automation been tested on?

SQL4automation has been tested on the Allen Bradley ControlLogix 1756-L63 (ControlLogix5563) and the CompactLogix 1769-L18ER-BB1B (CompactLogix5318ERM-BB1B). Both Ladder and Structured Text sample projects are verified for each platform. Any ControlLogix or CompactLogix controller with a compatible Ethernet module (1756-EWEB, 1756-EN2Txx, 1768-EWEB) or an integrated Ethernet/IP CPU interface can be used.

Technical Data

REQUIREMENTS & VERSION INFO
Add-On file AddOn_SQL4automation_v3.x.x.x.L5X (import via Controller Organizer)
Connection type CompactLogix: Unconnected only. ControlLogix: Connected, Unconnected, or Large Connection.
Large Connection Supported only on 1756-EN2xx ControlLogix modules in RSLogix 5000 v20 or later.
Add-On V2+ From Add-On V2, partial read/write is supported, enabling large data transfers even with smaller TCP buffers.
REQUIRED BLOCKS / LIBRARIES
  • AddOn_SQL4automation_v3.x.x.x.L5X (Add-On Instruction)
  • Controller Tags: Client_DATA, Connect_MSG, Create_MSG, Delete_All_MSG, Delete_MSG, Read_MSG, Write_MSG
  • Program Tags: saRequest (REQUEST), saTableValue (VALUES), EWEB_PATH (STRING), sDestination (STRING), SQL4RSLogix instance
  • Data Types: REQUEST, COLUMN, VALUE, PARAMETER, SOCK_DATA_CLIENT and related socket types
FUNCTION BLOCK PARAMETERS
Parameter Type Description
xExecute BOOL Triggers the database request
xAbort BOOL Resets the connection
xHoldConnection BOOL Keeps the socket connection open after a database request
xReadNoColumnNames BOOL Reads no column names
xReadNoReturnParameters BOOL Reads no return parameters (set TRUE for Connector < V4)
iLocalPort INT Port number of the controller (0 = default)
diTimeout DINT Request timeout in milliseconds
sDestination STRING Connector destination: e.g., '192.168.1.202 ?port=11001'
EWEB_PATH STRING Ethernet module slot path: e.g., '$01$03' for Backplane 1, Slot 3
xReady BOOL Output: ready for a new database request
xBusy BOOL Output: database request in progress
xDone BOOL Output: database request completed successfully
xError BOOL Output: database request ended with an error
diResultState DINT Output: status / error code (0 = no error)
diResultRows DINT Output: number of rows returned
diResultColumns DINT Output: number of columns returned
ERROR CODES (diResultState)
Error Code Description
1 Unknown SQL command
2 Query returns more records than MaxRows. Adjust query or increase MaxRows.
3 Query returns more columns than MaxColumns. Adjust query or increase MaxColumns.
4 Query returns more data than the defined buffer size. Adjust query or increase STRING_READBUFFER_COMPLETE.
5 Query returns at least one value larger than MaxStringLength. Adjust query or increase MaxStringLength.
10 Internal Connector error
11 Internal Connector error; database cannot be opened
22 No target address defined for Connector (sDestination = '')
28 Request string is empty (saRequest.REQUEST[0] = '')
40 Error creating socket. No connection to SQL4automation Connector. Check firewall.
41 Error connecting to SQL4automation Connector. Check firewall.
50 Sending complete request string failed. Check connection or TCP buffer.
51 Request string larger than send buffer. Increase STRING_WRITEBUFFER_COMPLETE.
61 Error reading data from SQL4automation Connector. Possible cause: too much data.
62 Error reading data. Increase STRING_READBUFFER_COMPLETE. (Update Connector to >= V3.4.1.0 for error code 4 instead.)
71 Error closing connection to SQL4automation Connector
99 Timeout: no response from Connector within the time window
>100 ODBC database connection error codes
40002 General error in SQL query; request string is invalid

Switch to SQL4automation Now.

Connect industrial controllers directly with SQL databases. Field-proven since 2007 for maximum performance and security, completely without middleware.

Rockwell Allen Bradley
by Industry.