Hello
I am looking to connect upto 10 PLC to a single SQL database.
Does anyone have an example of the changes required to the Python script to be able to achieve this?
Thanks
Neil
Hello
I am looking to connect upto 10 PLC to a single SQL database.
Does anyone have an example of the changes required to the Python script to be able to achieve this?
Thanks
Neil
Most likely you would not need to make any changes to the script. The script starts a HTTP server that listens to HTTP requests sent by the PLC so it should be able to handle multiple PLCs.
Other option could also be to start separate instances of the script with separate ports to have 1 instance of the python script running for one PLC. In this case you would need to modify the configurations of the PLCs to connect to the separate instance ports.
This is also suggested in the documentation here:
Connecting multiple target systems to one script
It is recommended to use one script per target system. If multiple target systems are connected to a script, the emerging queries are processed step by step and not in parallel. There may therefore be longer waiting times for a query. The script does not support multithreading.
Hello,
Some time ago I tried to accomplish what you are looking for.
Using just one script makes no sense for frequent RW operations as it takes time to free up http connection with the script - huge bottleneck.
You can either use multiple scripts on different ports or try to modify the script itself so that it can serve multiple PLC at the time. Here you can spawn multiple servers on different ports with individual DB connections or set up just one connection to DB and aggregate requests from multiple PLC in the script.
I tried this second approach using threads. I attach modified script but with no guarantees whatsoever. At the end, customer is not using it in his project. I also modified GET function so you can easily see how many threads are currently running just by navigating to script via webbrowser.
Mymappdatabaseconnector.zip (5.6 KB)
Also, I was not in a need for read operations, so I just tested write to DB.
If anyone here is better at python then it could be a nice upgrade for the future official releases maybe?
Thanks
Will give this a try
Hi Neil,
there is also the option to connect the 10 PLCs via OPC UA or ANSL and then have one PLC send the data to SQL database.
Stephan
Yes, that is good to mention and could be an easy workaround. Thanks for that, Stephan