(0)| 10/28/2022 10:36 PM | |
|
Joined: 10/6/2022 Last visit: 11/17/2025 Posts: 4 Rating:
|
Hi, I never connected to sql inside a PLC. But I tested this code and it works. I was able to do a test insert into a sql db. But this library still on version 1.0. What I will like to do, is to log machine events in sql table, something like (see attached file) Example fields: <newID(from sql)>,<timestamp(from sql)>, <eventname>, <event_description>,<state>,<recipe>, <batch> This structure on a db table makes possible to know when the working time (between dates, recipes), machine perfomance, state of product (shift regster status for example), cadence of production, normal stops, error stops (state of error/cause), etc... It can be possible to analyse between dates and so on using the right queries over the db. I observed the FB construction, and it's not very complicated, however it seems that to mix the DB connection TCon with the TSend on the same FB can not be very functional, Am I' wrong? If you want to report to database a lot of events I think that if we have an instance of the connection on a global db, we can reuse that connection to call a generic FC to do simultaneus inserts at a different points of the program, Mixing everything in one FB, how can we do it? Do we need to do a queue and use the fb inside a cycle to process each insert at a time? I don't understand. ------------------------------------------------------------------------------------------ Attachmentexample.xlsx (500 Downloads) |
Last edited by: MigTav at: 10/28/2022 22:39:00Last edited by: Jen_Moderator at: 11/02/2022 09:52:44New subject after splitting |
|
| 11/2/2022 11:51 AM | |
|
Posts: 10 Rating:
|
Hello, I think that now there is a version 3. Have a look at the fallowing link: https://support.industry.siemens.com/cs/document/109779336/connecting-an-s7-1500-to-an-sql-database?lc=en-ro You can only call LSql_Microsoft once. Try to Enable the function, after connection is done, create/append the command string command in different parts of program and executeCommand (TRUE) when you want. I see you are working with recipes so I guess you are using some kind of HMI. I recommend a VBscript ("ADODB.Connection") if you are using WinCC Advanced and run the script on tag event value change. Could be easier. If you still need to use the PLC, I would have inserted a CASE event_id before LSql_Microsoft call and do there the string command and executeCommand. Just an idea: |
Last edited by: fluidcontrol at: 11/02/2022 11:53:34Last edited by: fluidcontrol at: 11/02/2022 12:07:41 |
|
Follow us on