Python Snap7 S7 Communication with PUT/GET with Siemens PLC TIA Portal

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys today we are going to talk about another possibility of connecting to the s7 1500 plc using python and snap 7. if you haven't seen the previous video regarding python and opc ua i'm gonna link it here and today we'll talk about put get communication [Music] so let's get it started i have a project prepared uh what's important that we have to go first of all to the settings of the plc and the permit access with putcat communication from remote partner so let's let's set it on another thing is that unfortunately we are not able to access the optimized blocks so what we have to do we have our top secret data block i'm gonna create a new one it's gonna be top secret run uh what do we have in here is number of sold nintendo switches empty bit and test so in order to be able to access it using the put get we have to change the optimized block access it basically means that now we have a new tab offset in here after the compilation we are gonna see that we have some addresses available i'm compiling the hardware and software we got this warning because i have copied the block and it has the same name as the previous one regarding the db number so now it's just gonna assign the other number for it you see now we have db1 and db2 and we have our option ticked software is compiled i'm gonna download it i have an instance of plc sim running in here that's how it looks like okay i'm gonna go online i didn't download the software let's do it again okay so we are online that's a that's how it looks uh currently we have number of solar nintendos which is zero uh empty bit is false and test is false as well so uh basically everything is set up as i said we have two constraints uh we unfortunately we cannot use the optimized block access for the dbs and we have to we have to enable putcat communication at the prc [Music] i have prepared some python code let me show you how it looks it's gonna be available in the in the description so what do we have here we are importing the snap seven library so basically based on it uh we are gonna communicate to our plc first of all we are creating creating a client then we are connecting here we have to put the plc number rack and slot from the hardware so let's check if the settings are correct one nine two one six eight zero one that's correct rack and slot zero one go to the hardware zero rail zero number one should be okay next we have to define the db number so we are gonna choose our db2 so number two uh offset let's say first we would like to change the empty we would like to make it true so offset is two bit offset zero because that's a boolean and we would like to make it true so let's put one here here are those two functions with a little bit of description how it works basically we have right bull and readable what we are doing here we are writing a boolean value based on defined db number and the other data as well and then we are reading its value so let me start the console first of all we have to install the our library which is python snap7 it's really easy all we have to do is just one command so i'm gonna copy it paste it here right click install you see before i tried to start it but the the module was not not installed now it's installed successfully so now we should be able to run it so basically what should happen we should change the value of empty from false to true one more important thing we have to run our virtual ethernet adapter because we we have to be able to ping the the plc otherwise we are not able to access it so that's what i'm gonna change now okay guys so let's start the script now so i'm gonna put python read right okay now we are expecting empty to change to true yeah and it's changed we can for example change the value to false i'm gonna start it again and we have false we have uh print out here as well just to check the uh just to get the feedback uh so let's say now we would like to change the test uh to true so yeah only thing we have to do is change to change the bit offset because it's 2 2.1 so now let's run it and we would like to have it true okay oh my mistake okay see it is a change to true i'm gonna put it false again and it's false again that's it for today thank you guys for watching if you have any questions or remarks please let me know and see you next time bye bye [Music] you
Info
Channel: plcwars
Views: 25,446
Rating: undefined out of 5
Keywords:
Id: xSTfmCdepyw
Channel Id: undefined
Length: 7min 34sec (454 seconds)
Published: Mon Mar 07 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.