{"id":364318,"date":"2024-05-21T02:14:33","date_gmt":"2024-05-21T02:14:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=364318"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T02:14:33","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=364318","title":{"rendered":"<span>PLC Allen Bradley \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c!<\/p>\n<p>\u0425\u043e\u0447\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0430\u0442\u044c \u0442\u0435\u0431\u0435 \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 Python \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a PLC \u043e\u0442 Allen Bradley.<\/p>\n<p>\u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0442\u0430 \u0441\u0430\u043c\u0430\u044f &#171;pycomm3&#187;.<\/p>\n<p>\u0418 \u0442\u0430\u043a, PyComm3 \u0438\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430: SLCDriver, LogixDriver \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 CIPDriver. (\u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u043e CIP, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0444\u0444 \u0441\u0430\u0439\u0442\u0435)<\/p>\n<p>\u041c\u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0438 \u043c\u043e\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0430\u043b\u0430\u0441\u044c \u043d\u0430 &#171;LogixDriver&#187;.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 PyComm3 \u0447\u0435\u0440\u0435\u0437 pip:<\/p>\n<blockquote>\n<p>pip install pycomm3<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 <a href=\"http:\/\/main.py\" rel=\"noopener noreferrer nofollow\">main.py<\/a> \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<p><code>from pycomm3 import LogixDriver<\/code><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e PLC \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435 &#8212; LogixDriver(&#8216;IP \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043b\u043a \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438&#8217;)<\/p>\n<p><code>plc = LogixDriver('192.168.0.1')<\/code><\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 PLC:<\/p>\n<pre><code class=\"python\">def Connection_to_plc():     try:         plc.open() #\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435         print(plc) #\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 PLC     except:         print('Error')         pass<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e Connection_to_plc() \u0438 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d IP-\u0430\u0434\u0440\u0435\u0441, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0442\u0432\u0435\u0442 (\u0418\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u044e):<\/p>\n<blockquote>\n<p>Program Name: CONTROL_8510, Revision: {&#8216;major&#8217;: 32, &#8216;minor&#8217;: 11}<\/p>\n<\/blockquote>\n<p><strong>\u0412\u0410\u0416\u041d\u041e!<\/strong><\/p>\n<p>\u0414<em>\u043b\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0435\u0433\u043e\u0432 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0442 PLC \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435!<\/em><\/p>\n<p><em>\u041d\u0435 \u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u043e\u0432 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u0445!<\/em><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u043e\u0441\u0430 \u0442\u044d\u0433\u0430:<code> <\/code><\/p>\n<pre><code class=\"python\">def PollingTag():     resultRead = plc.read('AL_POS[17].6')     result = resultRead[1]<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 &#171;resultRead&#187; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0438\u0434\u0430:<\/p>\n<blockquote>\n<p>{&#8216;value=TRUE&#8217;, &#8216;tag=&#8217;AL_POS[17].6&#187;, &#8216;type=&#8217;BOOL&#187;, &#8216;error=None&#8217;}<\/p>\n<\/blockquote>\n<p> \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439 \u043b\u0438\u0431\u043e \u043b\u043e\u0433\u0438\u043a\u0438 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;value&#187;, \u0435\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u044b\u0434\u0435\u0440\u0433\u0438\u0432\u0430\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c:<\/p>\n<p><code>print(result)<\/code><\/p>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;TRUE&#187;!<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e\u0433\u043e \u0431\u0430\u0437\u0438\u0441\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432.<\/p>\n<p>\u041a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c:<\/p>\n<pre><code class=\"python\">from pycomm3 import LogixDriver import time plc = LogixDriver('IP \u0442\u0432\u043e\u0435\u0433\u043e PLC')  def Connection_to_plc():     try:         plc.open()         print(plc)         time.sleep(10)     except:         print('Error')         pass  def PollingTag():     resultRead = plc.read('\u0412\u0441\u0442\u0430\u0432\u044c \u0441\u0432\u043e\u0439 \u0442\u0435\u0433 \u0441\u044e\u0434\u0430!')     result = resultRead[1]     print(result)     time.sleep(10)  def main():     Connection_to_plc()     while True:         PollingTag()  main()<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0422\u0413 \u0431\u043e\u0442\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#171;plc.write&#187; \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u043e\u0432 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/783908\/\"> https:\/\/habr.com\/ru\/articles\/783908\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0443\u0432\u0430\u0436\u0430\u0435\u043c\u044b\u0439 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c!<\/p>\n<p>\u0425\u043e\u0447\u0443 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u0432\u0435\u0434\u0430\u0442\u044c \u0442\u0435\u0431\u0435 \u043a\u0430\u043a \u0447\u0435\u0440\u0435\u0437 Python \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c\u0441\u044f \u043a PLC \u043e\u0442 Allen Bradley.<\/p>\n<p>\u0412 \u0441\u0432\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u0435\u0440\u0435\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u043b \u043a\u0443\u0447\u0443 \u0440\u0430\u0437\u043d\u044b\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a, \u043d\u043e \u0432 \u043e\u0434\u0438\u043d \u043f\u0440\u0435\u043a\u0440\u0430\u0441\u043d\u044b\u0439 \u0434\u0435\u043d\u044c \u043d\u0430\u0448\u043b\u0430\u0441\u044c \u0442\u0430 \u0441\u0430\u043c\u0430\u044f &#171;pycomm3&#187;.<\/p>\n<p>\u0418 \u0442\u0430\u043a, PyComm3 \u0438\u043c\u0435\u0435\u0442 \u0442\u0440\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430: SLCDriver, LogixDriver \u0438 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 CIPDriver. (\u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u0430 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0430\u044e\u0442\u0441\u044f \u043f\u043e CIP, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a\u043e\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u043d\u0430 \u043e\u0444\u0444 \u0441\u0430\u0439\u0442\u0435)<\/p>\n<p>\u041c\u043d\u0435 \u043f\u043e\u0432\u0435\u0437\u043b\u043e \u0438 \u043c\u043e\u0435 \u0441\u0435\u043c\u0435\u0439\u0441\u0442\u0432\u043e \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432 \u043e\u0431\u0449\u0430\u043b\u0430\u0441\u044c \u043d\u0430 &#171;LogixDriver&#187;.<\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0447\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 PyComm3 \u0447\u0435\u0440\u0435\u0437 pip:<\/p>\n<blockquote>\n<p>pip install pycomm3<\/p>\n<\/blockquote>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0448 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442 <a href=\"http:\/\/main.py\" rel=\"noopener noreferrer nofollow\">main.py<\/a> \u0438 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u043d\u0430\u0448\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443:<\/p>\n<p><code>from pycomm3 import LogixDriver<\/code><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e PLC \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c \u0435\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435 &#8212; LogixDriver(&#8216;IP \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u043b\u043a \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0441\u0435\u0442\u0438&#8217;)<\/p>\n<p><code>plc = LogixDriver('192.168.0.1')<\/code><\/p>\n<p>\u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 PLC:<\/p>\n<pre><code class=\"python\">def Connection_to_plc():     try:         plc.open() #\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435         print(plc) #\u0412\u044b\u0432\u043e\u0434\u0438\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 PLC     except:         print('Error')         pass<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e Connection_to_plc() \u0438 \u0443 \u043d\u0430\u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u043d IP-\u0430\u0434\u0440\u0435\u0441, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0442\u0432\u0435\u0442 (\u0418\u043c\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b \u0438 \u0440\u0435\u0434\u0430\u043a\u0446\u0438\u044e):<\/p>\n<blockquote>\n<p>Program Name: CONTROL_8510, Revision: {&#8216;major&#8217;: 32, &#8216;minor&#8217;: 11}<\/p>\n<\/blockquote>\n<p><strong>\u0412\u0410\u0416\u041d\u041e!<\/strong><\/p>\n<p>\u0414<em>\u043b\u044f \u043e\u043f\u0440\u043e\u0441\u0430 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0442\u0435\u0433\u043e\u0432 \u0432\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0442 PLC \u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435!<\/em><\/p>\n<p><em>\u041d\u0435 \u043f\u044b\u0442\u0430\u0439\u0442\u0435\u0441\u044c \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u043e\u0432 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0443\u0432\u0435\u0440\u0435\u043d\u044b \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u044f\u0445!<\/em><\/p>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u043e\u043f\u0440\u043e\u0441\u0430 \u0442\u044d\u0433\u0430:<code> <\/code><\/p>\n<pre><code class=\"python\">def PollingTag():     resultRead = plc.read('AL_POS[17].6')     result = resultRead[1]<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0435\u0435 \u0432\u044b\u0437\u043e\u0432\u0435 \u0432 &#171;resultRead&#187; \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0432\u0438\u0434\u0430:<\/p>\n<blockquote>\n<p>{&#8216;value=TRUE&#8217;, &#8216;tag=&#8217;AL_POS[17].6&#187;, &#8216;type=&#8217;BOOL&#187;, &#8216;error=None&#8217;}<\/p>\n<\/blockquote>\n<p> \u0414\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u043a\u0430\u043a\u043e\u0439 \u043b\u0438\u0431\u043e \u043b\u043e\u0433\u0438\u043a\u0438 \u043d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;value&#187;, \u0435\u0433\u043e \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u044b\u0434\u0435\u0440\u0433\u0438\u0432\u0430\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u043c\u044b \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u043c:<\/p>\n<p><code>print(result)<\/code><\/p>\n<p>\u041c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 &#171;TRUE&#187;!<\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c, \u044d\u0442\u043e\u0433\u043e \u0431\u0430\u0437\u0438\u0441\u0430 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f \u043e\u0441\u043d\u043e\u0432.<\/p>\n<p>\u041a\u043e\u0434 \u0446\u0435\u043b\u0438\u043a\u043e\u043c:<\/p>\n<pre><code class=\"python\">from pycomm3 import LogixDriver import time plc = LogixDriver('IP \u0442\u0432\u043e\u0435\u0433\u043e PLC')  def Connection_to_plc():     try:         plc.open()         print(plc)         time.sleep(10)     except:         print('Error')         pass  def PollingTag():     resultRead = plc.read('\u0412\u0441\u0442\u0430\u0432\u044c \u0441\u0432\u043e\u0439 \u0442\u0435\u0433 \u0441\u044e\u0434\u0430!')     result = resultRead[1]     print(result)     time.sleep(10)  def main():     Connection_to_plc()     while True:         PollingTag()  main()<\/code><\/pre>\n<p>\u0414\u0430\u043d\u043d\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u043a\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435, \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 \u0422\u0413 \u0431\u043e\u0442\u043e\u043c.<\/p>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 &#171;plc.write&#187; \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0442\u0435\u0433\u043e\u0432 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u043d\u043e \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e.<\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u043f\u0440\u043e\u0447\u0442\u0435\u043d\u0438\u0435!<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/783908\/\"> https:\/\/habr.com\/ru\/articles\/783908\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-364318","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=364318"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/364318\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=364318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=364318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=364318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}