6/15/2015 9:16 AM | |
Joined: 9/8/2009 Last visit: 7/17/2023 Posts: 1410 Rating:
|
I have send it over PM multiple times, now I will post it here: This is Zip of zap13, TIA13 archeive file. I have compiled it from v11, VAL_STRG, does not allow to be called directly in SCL, so there is one another function that calls VAL_STRG in LAD. Hi, I have tested this near year ago, I have used Wireshark, Heidi SQL, MySQL Workbench. First you will need to stetup MySql server, my project uses a database named scada, and it has a table named Hist consisting ten real numbers named T1, T2,....T10. Look at JPG attached. In STAT declaration of function block MySql, you will find username, password and database name, currently: username: root password: newuser database: scada Change to your wish, but don't exceed length of maximum characters (14), you may change also that if you wish, but not more than 54 chars. MySql server should use newer 4.1 authenticaion protocol, older are not implemented. Autentication is done via SHA1 function block, it time consuming so the entire autentication sequence is split in more steps, whenever SHA1 is executed means one step (thus one plc scan). The authentication loads CPU to approx 20ms, this is done anytime you connect to server, after that data are sent to server encoded with ascii characters. Before you say it doesn't work, try to send data wit some pc program (Heidi SQL), wit wireshark you will monitor traffic and see response from server or error) Best regards, Marko. I forgot to say that there are additional parameter in STAT area: net_settings of type TCON_Param is a place where you will have to set the IP addres of your server. net_settings.REM_STADDR - now you will see 192.168.1.127, change it to suit your demand net_setting.REM_TSAP_ID - port number , now 0CEA hex, means 3306 dec, this is the default port for mysql You will find meaning for others in manual for S7-1200, but I think it is nothing to change there. AttachmentMYSQL_v8_V13.zip (2445 Downloads) |
This contribution was helpful to
15 thankful Users |
6/15/2015 9:18 AM | |
Joined: 9/8/2009 Last visit: 7/17/2023 Posts: 1410 Rating:
|
this is the sql table |
This contribution was helpful to
1 thankful Users |
6/16/2015 11:03 AM | |
Posts: 6 Rating:
|
Dear Marko, thanks for sharing this app with us. I make the steps you described and i succesfull connect with Heidi to mySQL database. I make the same table as your and i check the telegrams with the wireshark. Everything its fine until now. I run the project on my CPU and when i set the connect bit to "1" after 2-3 seconds the Error bit get TRUE and the Status take value = 3. I checked the SQL code and i found in line 247 that i have "authentication failed" status. It seems strange because with Wireshark there is no telegram from CPU to mySQL server PC. The only telegrams are between CPU and TIA Portal PC (used for status program). Is there any details i can check?
Attachmentscreenshots.rar (1225 Downloads) |
Last edited by: giorgos007 at: 6/16/2015 11:04:41 AM |
|
6/18/2015 6:02 PM | |
Joined: 9/8/2009 Last visit: 7/17/2023 Posts: 1410 Rating:
|
As stated, the disconnection, error behaviour isn't 100%. But if you have time you can improve all that. Anyway, you're the first one that has sent some feedback information about this. I have never used it latter, I did just some piece of code because some of my clienet wanted some cheap variant to store data on SQL, that latter changed his mind. There are some parts of program, that they don't need to be changed at all. SHA1 function, strictly you have nothing to change, because it is complicated and well optimized. Then handshaking, encoding,...its a huge work and it works, you are the whitness that has logged in. From line 276 to 328 you can change as it suits your demand, you can even delete SQLExe command if you like to send data for logging on the server. The lines I don't like are 1 to 85 and 365-> Also I have found that you can remove copy: array[0..19] of byte and rtu :int, this because a line MOVE_BLK(IN:=#Pwd.Bytes[0],COUNT:=#Pwd.Len,OUT=>#copy[0]); does nothing (it does: consumes plc time), it is a residual from earlier versions. AttachmentMySQL_ S71200_description.doc (2067 Downloads) |
This contribution was helpful to
1 thankful Users |
6/24/2015 7:30 AM | |
Posts: 1 Rating:
|
Good day! great job, thank you.I would like to ask, can there be a project for MSSQL? |
Follow us on