S7-1200, python and TSAP

babido10

Member
Join Date
Nov 2017
Location
rabat
Posts
28
I'm currently struggling to make libnodave work with my S7-1200 plc over ethernet. The testISO_TCP.exe makes a connection and gets some info out of it, but I cannot for the life of me reproduce this. Every setting I try I get a -1 from libnodave.daveConnectPLC(dc).

My code:
debugEnable = True
def debug(string):
if(debugEnable):
print string
import ctypes
import os
daveProtoPPI = 10 # PPI for S7 200
daveProtoAS511 = 20 # S5 programming port protocol
daveProtoS7online = 50 # use s7onlinx.dll for transport
daveProtoISOTCP = 122 # ISO over TCP */
daveProtoISOTCP243 = 123 # ISO over TCP with CP243 */
daveProtoISOTCPR = 124 # ISO over TCP with Routing */
daveSpeed9k = 0
daveSpeed19k = 1
daveSpeed187k = 2
daveSpeed500k = 3
daveSpeed1500k = 4
daveSpeed45k = 5
daveSpeed93k = 6
daveBlockType_OB = '8'
daveBlockType_DB = 'A'
daveBlockType_SDB = 'B'
daveBlockType_FC = 'C'
daveBlockType_SFC = 'D'
daveBlockType_FB = 'E'
daveBlockType_SFB = 'F'
class daveOSserialType(ctypes.Structure):
_fields_ = [("rfd", ctypes.c_int),
("wfd", ctypes.c_int)]
debug("Starter script")
debug("Laster inn dll")
libnodave = ctypes.windll.LoadLibrary("libnodave_jfkmod.dll")
fds = daveOSserialType()
debug("Prover a koble til")
fds.rdf = libnodave.openSocket(102,'192.168.0.1')
fds.wdf = fds.rdf
if(fds.rfd >= 0):

di = libnodave.daveNewInterface(fds, 'IF1', 0 ,daveProtoISOTCP ,daveSpeed187k)
libnodave.daveSetTimeout(di, 500000000)
res = libnodave.daveInitAdapter(di)
debug ("InitAdapter: " + str(res))

dc = libnodave.daveNewConnection(di,2,10,0)
res = libnodave.daveConnectPLC(dc)
debug( "ConnectPLC: " + str(res))
 
There might be more errors but i think the connection line is wrong

Try
dc = New libnodave.daveConnection(di, 0, 0, 0)
MPI shall be zero for IsoOnTCP and also rack and slot for S71200 and S71500.
 
Honest question, is the slot on the new family of PLC's starting at 0 instead of the 2 (for 300) and 3 (for 400)?

For the protocol at least. I can successfully connect to S7-1500 using rack 0 slot 0. I don't have a 1200 but according to others on the web it should work with 0,0 for 1200 also.

Maybe this example can help you
 
Last edited:
Snap 7 manual but its the same settings for libnodave
Sharp7.jpg

I have switched from Libnodave to Snap7 because its more actively developed and documented. You might want consider trying Snap7 instead
 
Last edited:
Other things to consider with 1200. (Snippet from Snap7 manual)

S7 1200/1500 Notes An external equipment can access to S71200/1500 CPU using the S7 “base” protocol, only working as an HMI, i.e. only basic data transfer are allowed.
All other PG operations (control/directory/etc..) must follow the extended protocol, not (yet) covered by Snap7.
Particularly to access a DB in S71500 some additional setting plc-side are needed.
1. Only global DBs can be accessed.
2. The optimized block access must be turned off.
3. The access level must be “full” and the “connection mechanism” must allow GET/PUT.
 
Last edited:

Similar Topics

Hi all, Currently having trouble getting a speed reference to write over modbus to an Omron M1... I can successfully write a run command and...
Replies
6
Views
252
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
81
Hi, I have attached herewith one image which our programmer has been used in S7 1500 PLC. Now we need to use the same instructions in S7 1200 PLC...
Replies
4
Views
118
commentaire communiqué siemens s7-1200 avec vfd delta ? (cablage et sur tia portal )
Replies
0
Views
127
Hi, I have a 1214 on ip 192.168.0.100. This is connected to other modules through a switch on same network. I need to connect this to a company...
Replies
1
Views
179
Back
Top Bottom