plc-python-snap7

babido10

Member
Join Date
Nov 2017
Location
rabat
Posts
28
i started running this code python but give me errors

code python:
import snap7
import struct
import time
from snap7.snap7exceptions import Snap7Exception
import re
from ctypes import c_int, c_char_p, byref, sizeof, c_uint16, c_int32, c_byte
from ctypes import c_void_p
from time import sleep
import snap7.client as c


plc = snap7.client.Client()
plc.connect ('192.168.0.1',0,1,tcpport=135)



plc.writeMem('QX0.0',True) # write Q0.0 to be true, which will only turn on the output if it isn't connected to any rung in your ladder code
print plc.getMem('MX0.1') # read memory bit M0.1
print plc.getMem('IX0.0') # read input bit I0.0
plc.plc.disconnect()
////
errors:
C:\Python27\python.exe C:/Users/simo/PycharmProjects/untitled2/SNAPP.py
No handlers could be found for logger "snap7.common"
Traceback (most recent call last):
File "C:/Users/simo/PycharmProjects/untitled2/SNAPP.py", line 13, in <module>
plc.connect ('192.168.0.1',0,1,tcpport=135)
File "C:\Python27\lib\site-packages\snap7\client.py", line 25, in f
check_error(code, context="client")
File "C:\Python27\lib\site-packages\snap7\common.py", line 65, in check_error
raise Snap7Exception(error)
snap7.snap7exceptions.Snap7Exception: ISO : An error occurred during recv TCP : Connection timed out

any ideas??
 

Similar Topics

how can i do to write into plc using script python (library snap7) some here have simple exemple to write a bit into plc Regards !!
Replies
0
Views
1,499
I'm currently a senior in college working on a senior design project involving PLCs and Raspberry Pi. We have data taken using the PLC that we...
Replies
14
Views
3,998
It is pretty easy to read data from xml, json or .csv files using python. Can Rockwell and/or Siemens trends be saved in any of these formats...
Replies
9
Views
3,034
Hello everybody! I found option for creating communication with Q series via python. But can't find any tips for connecting with PLC FX series...
Replies
3
Views
5,241
I'm working on an DELTA PLC project and I'm trying to use modbus library to connect to plc My first test is with a Delta DVP-12SE11R PLC and the...
Replies
4
Views
4,272
Back
Top Bottom