Getting Data from SQL Database to the PLC

For me the most interesting thing about to access a SQL server directly from the PLC would be to execute DB Stored Procedures on the server, it is something that I would like to study

.... maybe I should open a new thread
 
For me the most interesting thing about to access a SQL server directly from the PLC would be to execute DB Stored Procedures on the server, it is something that I would like to study

.... maybe I should open a new thread


With SQL4automation you can communicate directly from the PLC to SQL database. Yes, there is a small service between, but you only have to configure the connection in this service. The whole programming is in the PLC and you have all the possibilites of the SQL language. Also executing stored procedures. For a lot of PLCs SQL4automation provides sample projects. As for Allen Bradley, Siemens S7, Beckhoff TwinCAT or CODESYS.
 
Maybe in the next ten years, Rockwell will get the hint and provide SQL connections on their PLCs.

But, I kind of understand why they don’t offer it.
If the query does not need to be dynamic or you are only writing a few values to SQL server, it makes sense to just handle it on the PLC.

Otherwise, if you need many queries that may need to change over time, need the ability to add more queries, or are writing a lot of values to SQL server. Then it is best done in a middleware application. Granted, more queries generally means a change in tag structure.

Executing a stored procedure on a plc is also a good example for doing it. Allows some customization on the sql side without needing to update the plc code. Unless it’s a major change.
 
We currently use Ignition SCADA software to interface between our SQL server on our automation network and our PLCs on the plant floor. We write python scripts on the tags that we pull into ignition from the plc and read information from SQL and put it back into the PLC tags.
 
We know very well that there are software solutions installed on a PC or other external hardware to execute SQL from a PLC

But the goal would be for the PLC to do it by itself, and better using stored procedures.

Since these procedures run very fast on the server side, they can be changed online without altering the PLC program and can be very elaborated and long SQL queries that would be close to impossible to create and maintain on the PLC program.

I think this is a key piece thinking about the evolution towards Industry 4.0
 
We know very well that there are software solutions installed on a PC or other external hardware to execute SQL from a PLC

But the goal would be for the PLC to do it by itself, and better using stored procedures.

Since these procedures run very fast on the server side, they can be changed online without altering the PLC program and can be very elaborated and long SQL queries that would be close to impossible to create and maintain on the PLC program.

I think this is a key piece thinking about the evolution towards Industry 4.0
A number of years ago I installed a system that was just a small step from the PLC directly executing SQL. In Beckoff TwinCAT there is a function block called NT_StartProcess. This is used to launch remote applications. By having an application on the server that accepted SQL as startup parameters, TwinCAT could launch the application and pass SQL statements to it. The application would run the SQL, return the results to TwinCAT, then close itself.

In the PLC program it looked very much like the function block was executing SQL.
 
Interesting find. I see there are libraries for both MySQL and Microsoft SQL Server on the Wago web site. Since Wago is Codesys based, the libraries should work on any Codesys based system. I tried pulling the MS SQL library into TwinCAT and it at least references it. I haven't actually tried to use it in a real program yet.
 

Similar Topics

So i have a tag in wincc and when i run the projeckt the tag has different values. I created an arhive for the tag but in sql i dont find the...
Replies
3
Views
3,316
How can i get out the data from sqserver 2000. I have some tags and i want there values. In what intervals is the program stores the value of the...
Replies
2
Views
6,826
All, I have a CompactLogix L33 and would like to get data from a height gauge. The gauge is a Fowler Sylac Mark VI with RS232 output. I can...
Replies
8
Views
2,575
Hello I am hoping someone here can maybe at least tell me what I shlould read up on or if this is even possible. Rockwell Studio 5000 is my...
Replies
12
Views
4,224
Hi, Guys I'm trying to upgrade a device witch comms is thru a RS232. The PLC is a Compactlogix L16ER to a remote PIO 1734-AENT then on this PIO a...
Replies
22
Views
8,157
Back
Top Bottom