neues Modul: SIEMENS Anbindung / S7 / Siemens Logo

Begonnen von charlie71, 12 August 2014, 15:33:23

Vorheriges Thema - Nächstes Thema

pc1246

#105
Hallo Karl
Jetzt funzt es! Du bist mein Held! Ich weiss jetzt auch, welchen DB man fuer Ein- und Ausgaenge angeben muss! Man nimmt einfach die "0"! Jetzt kann ich endlich fhem und die S7 verheiraten, ohne den riesigen Modbus overhead und auch noch die Programmiererei dafuer!
I am very happy! :) :) :) :)

Gruss Christoph
HP T610
Onkyo_AVR;3 Enigma2; SB_Server ; SB_Player; HM-USB mit 15 HM-CC-RT-DN, 3 HM_WDS10_TH_O, 6 HM-Sec-SCo, 4 HM-Sec-MDIR-2, 1 HM-Sen-MDIR-O-2, 8 Ferion 5000 OW ; PhilipsTV; 4 harmony hub; Jeelink mit 9 PCA301; Somfy; S7-300; 3 LGW; HUE; HM-IP auf Charly

Porsti

Hallo Charlie71,

hier der log aus dem Test

Konfig:

define mylogo S7 2 0 192.168.105.15 0 0 102 2 960
attr mylogo ReadDB-Config 0 1064 2 10
define mylogo_Q1 S7_DRead DB 0 8512
define mylogo_Q2 S7_DRead DB 0 8513
define mylogo_Q3 S7_DRead DB 0 8514
define mylogo_Q4 S7_DRead DB 0 8515


Auszug aus dem Test:

set debug level
debug level is: 0
port handle: 3
di: DaveInterface=SCALAR(0x108c7e0) ok 5
res: 0 ok 6
connect to PLC. function result: 0
read from PLC. function result: 0
IB1: 00000000
IB2: 00000000
IB3: 00000000
IB1: 00000000
IB2: 00000000
IB3: 00000000
IB2: 00000000
IB3: 00000000
AI1: 0
AI2: 0
AI3: 0
AI4: 0
QB1: 00000000
QB2: 00000000
AM1: 0
AM16: 0
Testing multiple item read
function result:0=ok
function result:0=ok
QB1: 00000000
QB2: 00000000
function result:0=ok
AI1: 0
AI2: 0
AI3: 0
AI4: 0
function result:0=ok
AM16: 0
function result:0=ok
function result:0=ok
QB1: 00000000
QB2: 00000000
function result:0=ok
AI1: 0
AI2: 0
AI3: 0
AI4: 0
function result:0=ok
AM16: 0


Ausschnitt aus der Log-Datei:

2014.12.09 08:03:02 4: S7: GetUpdate called ...
2014.12.09 08:03:02 4: S7: GetUpdate called ...
2014.12.09 08:03:02 4: S7: GetUpdate called ...
2014.12.09 08:03:02 4: S7: GetUpdate called ...
2014.12.09 08:03:02 4: S7: readFromPLC  132,0,1064,2
2014.12.09 08:03:02 3: S7: reading error from PLC errorcode -1025
2014.12.09 08:03:02 4: S7 Connect: plcMPI=2, localMPI=0, ip_address=192.168.105.15,rack=0, slot=0, ip_port=102, PDULength= 960
2014.12.09 08:03:02 3: maxPDUlength was set to: 960
2014.12.09 08:03:02 3: Communicationtype was set to 2
2014.12.09 08:03:02 3: connect to PLC: 0
2014.12.09 08:03:02 1: returnmessage PLC: 0=ok


Gruß
Porsti
____________________________________
fhem 6.2  auf Raspberry 3b
Homematic HM-CC-RT-DN / HM-TC-IT-WM-W-EU / HM-SEC-SCo / HM-LC-SW1-PL2
SIGNALduino, KNX (Merten, MDT, Siemens, ABB)

charlie71

Hallo Porsti

irgentwie kommen wir nicht weiter, darum noch einen Test:
Mir ist wichtig, dass nicht nur 2 Bytes gelesen werden, und dass sonst nichts anderes von der SPS gelesen wird:
Bitte die SPS einmal durchstarten (Stromlos machen).

Deine SPS sollte eine 0BA8 sein.

define mylogo S7 2 0 192.168.10.50 0 0 102 2 960
attr mylogo ReadDB-Config 0 1064 8 10
define mylogo_Q1 S7_DRead DB 0 8512
define mylogo_Q2 S7_DRead DB 0 8513
define mylogo_Q3 S7_DRead DB 0 8514
define mylogo_Q4 S7_DRead DB 0 8515


lG
Charlie71

pc1246

@Porsti & Karl
Nur mal so von aussen gefragt! Die Antwort sieht irgendwie verdaechtig nach 1024er Grenze aus! Hat das schon jemand anderes am Laufen? Ist es auch wirklich eine 0BA8? Kann das in der libnodave abgeklemmt sein?
Gruss Christoph
HP T610
Onkyo_AVR;3 Enigma2; SB_Server ; SB_Player; HM-USB mit 15 HM-CC-RT-DN, 3 HM_WDS10_TH_O, 6 HM-Sec-SCo, 4 HM-Sec-MDIR-2, 1 HM-Sen-MDIR-O-2, 8 Ferion 5000 OW ; PhilipsTV; 4 harmony hub; Jeelink mit 9 PCA301; Somfy; S7-300; 3 LGW; HUE; HM-IP auf Charly

pc1246

Hallo Karl
Das man nur einen Bereich schreiben kann ist gewollt! Willst und kannst du das noch aendern? Es ist kein Problem, nur anders waere es einfacher!
Gruss Christoph
HP T610
Onkyo_AVR;3 Enigma2; SB_Server ; SB_Player; HM-USB mit 15 HM-CC-RT-DN, 3 HM_WDS10_TH_O, 6 HM-Sec-SCo, 4 HM-Sec-MDIR-2, 1 HM-Sen-MDIR-O-2, 8 Ferion 5000 OW ; PhilipsTV; 4 harmony hub; Jeelink mit 9 PCA301; Somfy; S7-300; 3 LGW; HUE; HM-IP auf Charly

charlie71

Hallo Christoph,

das mit den Schreiben in nur einen Bereich ist gewollt.
Ich denke dass ich es ändern kann, wird aber noch ein wenig dauern.
Ich schreib es mal auf die Wunschliste.

lG
Charlie71

Zitat von: pc1246 am 09 Dezember 2014, 12:31:52
Hallo Karl
Das man nur einen Bereich schreiben kann ist gewollt! Willst und kannst du das noch aendern? Es ist kein Problem, nur anders waere es einfacher!
Gruss Christoph

Porsti

Hallo zusammen,

hier noch einmal das Ergebnis aus dem Test:

Konfig:

attr global userattr devStateIcon devStateStyle icon sortby webCmd widgetOverride
attr global autoload_undefined_devices 1
attr global logfile ./log/fhem-%Y-%m.log
attr global modpath .
attr global motd SecurityCheck:\
\
WEBphone,WEBtablet,fhemweb has no basicAuth attribute.\
telnetPort has no password/globalpassword attribute.\
\
Restart FHEM for a new check if the problem is fixed,\
or set the global attribute motd to none to supress this message.\

attr global statefile ./log/fhem.save
attr global updateInBackground 1
attr global verbose 3

define telnetPort telnet 7072 global
define fhemweb FHEMWEB 8083 global
attr fhemweb stylesheetPrefix dark

define WEBphone FHEMWEB 8084 global

define WEBtablet FHEMWEB 8085 global

# Fake FileLog entry, to access the fhem log from FHEMWEB
define Logfile FileLog ./log/fhem-%Y-%m.log fakelog

define autocreate autocreate
attr autocreate filelog ./log/%NAME-%Y.log

define eventTypes eventTypes ./log/eventTypes.txt

# Disable this to avoid looking for new USB devices on startup
define initialUsbCheck notify global:INITIALIZED usb create

define mylogo S7 2 0 192.168.105.15 0 0 102 2 960
attr mylogo ReadDB-Config 0 1064 8 10
define mylogo_Q1 S7_DRead DB 0 8512
define mylogo_Q2 S7_DRead DB 0 8513
define mylogo_Q3 S7_DRead DB 0 8514
define mylogo_Q4 S7_DRead DB 0 8515


per Test

set debug level
debug level is: 0
port handle: 3
di: DaveInterface=SCALAR(0x15917e0) ok 5
res: 0 ok 6
connect to PLC. function result: 0
read from PLC. function result: 0
IB1: 00000000
IB2: 00000000
IB3: 00000000
IB1: 00000000
IB2: 00000000
IB3: 00000000
IB2: 00000000
IB3: 00000000
AI1: 0
AI2: 0
AI3: 0
AI4: 0
QB1: 00000000
QB2: 00000000
AM1: 0
AM16: 0
Testing multiple item read
function result:0=ok
function result:0=ok
QB1: 00000000
QB2: 00000000
function result:0=ok
AI1: 0
AI2: 0
AI3: 0
AI4: 0
function result:0=ok
AM16: 0
function result:0=ok
function result:0=ok
QB1: 00000000
QB2: 00000000
function result:0=ok
AI1: 0
AI2: 0
AI3: 0
AI4: 0
function result:0=ok
AM16: 0


Log

2014.12.09 13:06:33 2: SecurityCheck:  WEBphone,WEBtablet,fhemweb has no basicAuth attribute. telnetPort has no password/globalpassword attribute.  Restart FHEM for a new check if the problem is fixed, or set the global attribute motd to none to supress this message.
2014.12.09 13:06:33 0: Server started with 14 defined entities (version $Id: fhem.pl 6913 2014-11-08 10:32:44Z rudolfkoenig $, os linux, user root, pid 6805)
2014.12.09 13:06:43 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:06:43 3: maxPDUlength was set to: 960
2014.12.09 13:06:43 3: Communicationtype was set to 2
2014.12.09 13:06:43 3: connect to PLC: 0
2014.12.09 13:06:43 1: returnmessage PLC: 0=ok
2014.12.09 13:06:53 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:06:53 3: maxPDUlength was set to: 960
2014.12.09 13:06:53 3: Communicationtype was set to 2
2014.12.09 13:06:53 3: connect to PLC: 0
2014.12.09 13:06:53 1: returnmessage PLC: 0=ok
2014.12.09 13:07:03 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:03 3: maxPDUlength was set to: 960
2014.12.09 13:07:03 3: Communicationtype was set to 2
2014.12.09 13:07:03 3: connect to PLC: 0
2014.12.09 13:07:03 1: returnmessage PLC: 0=ok
2014.12.09 13:07:13 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:13 3: maxPDUlength was set to: 960
2014.12.09 13:07:13 3: Communicationtype was set to 2
2014.12.09 13:07:13 3: connect to PLC: 0
2014.12.09 13:07:13 1: returnmessage PLC: 0=ok
2014.12.09 13:07:23 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:23 3: maxPDUlength was set to: 960
2014.12.09 13:07:23 3: Communicationtype was set to 2
2014.12.09 13:07:23 3: connect to PLC: 0
2014.12.09 13:07:23 1: returnmessage PLC: 0=ok
2014.12.09 13:07:33 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:33 3: maxPDUlength was set to: 960
2014.12.09 13:07:33 3: Communicationtype was set to 2
2014.12.09 13:07:33 3: connect to PLC: 0
2014.12.09 13:07:33 1: returnmessage PLC: 0=ok
2014.12.09 13:07:43 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:43 3: maxPDUlength was set to: 960
2014.12.09 13:07:43 3: Communicationtype was set to 2
2014.12.09 13:07:43 3: connect to PLC: 0
2014.12.09 13:07:43 1: returnmessage PLC: 0=ok
2014.12.09 13:07:53 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:53 3: maxPDUlength was set to: 960
2014.12.09 13:07:53 3: Communicationtype was set to 2
2014.12.09 13:07:53 3: connect to PLC: 0
2014.12.09 13:07:53 1: returnmessage PLC: 0=ok
2014.12.09 13:08:03 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:08:03 3: maxPDUlength was set to: 960
2014.12.09 13:08:03 3: Communicationtype was set to 2
2014.12.09 13:08:03 3: connect to PLC: 0
2014.12.09 13:08:03 1: returnmessage PLC: 0=ok
2014.12.09 13:08:13 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:08:13 3: maxPDUlength was set to: 960
2014.12.09 13:08:13 3: Communicationtype was set to 2
2014.12.09 13:08:13 3: connect to PLC: 0
2014.12.09 13:08:13 1: returnmessage PLC: 0=ok
2014.12.09 13:08:23 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:08:23 3: maxPDUlength was set to: 960
2014.12.09 13:08:23 3: Communicationtype was set to 2
2014.12.09 13:08:23 3: connect to PLC: 0
2014.12.09 13:08:23 1: returnmessage PLC: 0=ok
2014.12.09 13:08:33 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:08:33 3: maxPDUlength was set to: 960
2014.12.09 13:08:33 3: Communicationtype was set to 2
2014.12.09 13:08:33 3: connect to PLC: 0
2014.12.09 13:08:33 1: returnmessage PLC: 0=ok
2014.12.09 13:08:43 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:08:43 3: maxPDUlength was set to: 960
2014.12.09 13:08:43 3: Communicationtype was set to 2
2014.12.09 13:08:43 3: connect to PLC: 0
2014.12.09 13:08:43 1: returnmessage PLC: 0=ok


Sps Programm:
Eingang I1 auf offene Klemme X1 gelegt.
Ohne Netzwerkkonfiguration

Sps Steuerung
Siehe Bild unten

Gruß & THX

Porsti
____________________________________
fhem 6.2  auf Raspberry 3b
Homematic HM-CC-RT-DN / HM-TC-IT-WM-W-EU / HM-SEC-SCo / HM-LC-SW1-PL2
SIGNALduino, KNX (Merten, MDT, Siemens, ABB)

thmarx

Hallo Porsti,

kanns Du mal im fhem-config "attr global verbose 5" eintragen, dann das Logfile löschen und fhem neu starten. Dann lass mal eine Minute laufen und poste das Logfile.

Gruß
Thomas

charlie71

Hallo Porsti

ich hab mal in einem anderen SPS- Thread gelesen dass für die Logo die Max PDU lenght auf 240 stehen soll.
(http://www.sps-forum.de/hochsprachen-opc/56582-libnodave-kompilieren-auf-raspberry-pi-6.html)

bitte versuch mal folgende konfig:
define mylogo S7 2 0 192.168.105.15 0 0 102 2 240
attr mylogo ReadDB-Config 0 1064 8 10
define mylogo_Q1 S7_DRead DB 0 8512
define mylogo_Q2 S7_DRead DB 0 8513
define mylogo_Q3 S7_DRead DB 0 8514
define mylogo_Q4 S7_DRead DB 0 8515


um sicher zustellen das es kein 1024 Problem ist versuch dann noch:
define mylogo S7 2 0 192.168.105.15 0 0 102 2 240
attr mylogo ReadDB-Config 0 0 8 10
define mylogo_Q1 S7_DRead DB 0 1
define mylogo_Q2 S7_DRead DB 0 2
define mylogo_Q3 S7_DRead DB 0 3
define mylogo_Q4 S7_DRead DB 0 4


lG
Charlie71

thmarx

Zitatum sicher zustellen das es kein 1024 Problem ist versuch dann noch:
ist es nicht, bei mir läuft inzwischen eine 0BA7 mit einer 0BA8 parallel.

Ich könnte mir noch vorstellen, dass das Netzwerk zu langsam ist.
Scheinbar ist ja hier die Verbindung hergestellt:
Zitat2014.12.09 13:06:53 3: Communicationtype was set to 2
2014.12.09 13:06:53 3: connect to PLC: 0
2014.12.09 13:06:53 1: returnmessage PLC: 0=ok
10 Sekunden später dann der Fehler:
Zitat2014.12.09 13:07:03 3: S7: reading error from PLC errorcode -1025
2014.12.09 13:07:03 3: maxPDUlength was set to: 960
2014.12.09 13:07:03 3: Communicationtype was set to 2
2014.12.09 13:07:03 3: connect to PLC: 0
2014.12.09 13:07:03 1: returnmessage PLC: 0=ok
die Frage ist für mich jetzt, wann die Anfrage an die Logo kam. Das sollte man sehen wenn der LogLevel auf 4 oder 5 steht...

Gruß
Thomas

charlie71

Hallo Porsti, hallo Thomas

ich denke das das Timeout in der selben Sekunde passiert wie der Reading call:

Ausschnitt aus dem Ersten Post von Porsti auf dieser Seite:
2014.12.09 08:03:02 4: S7: GetUpdate called ...
2014.12.09 08:03:02 4: S7: readFromPLC  132,0,1064,2
2014.12.09 08:03:02 3: S7: reading error from PLC errorcode -1025
2014.12.09 08:03:02 4: S7 Connect: plcMPI=2, localMPI=0, ip_address=192.168.105.15,rack=0, slot=0, ip_port=102, PDULength= 960
2014.12.09 08:03:02 3: maxPDUlength was set to: 960


langsam gehen mir die Ideen aus:
1) kann es sein, dass für FHEM ein anderes TCP Timeout gesetzt wurde?
2) Gibt es einen Unterschied vom Perl Testprogramm (das ja funktionert) mit dem S7 FHEM Modul.
Ich hab mehrmals gesucht aber nichts gefunden.
3) ???

lG
Charlie71

John

Vielleicht hilft das ja.

PDU ist bei der Logo 240 Byte.

Die Übertragung via MultiRead auch bei voller Nutzung der 240 Byte benötigt ca. 5 Millisekunden.

Gemessen hab ich das mit der Snap7 library.
http://snap7.sourceforge.net/

Die Netzwerkbelastung ist vernachlässigbar aufgrund des binären Protokolls.

John
CubieTruck Docker Node-Red Tasmota Shelly Homematic-IP

thmarx

Hm. Also wie gesagt laufen bei mir je eine Logo7 und eine Logo8. Den Fehler -1025 kann ich provozieren, wenn ich im Betrieb das Netzwerkkabel aus der Logo ziehe, sonst habe ich den Fehler bei mir noch nicht gesehen. Was mich stört ist, dass das perl-Testprogramm durchläuft. D.h. ja irgendwie muss libnodave schon laufen. Ich sehe aber im Moment den Unterschied Testprogramm/S7-Modul noch nicht.

Porsti

Hallo zusammen,

habe in den letzten Tagen leider nicht so viel Zeit gehabt.
Wenn ich die logo auf Logo 240 Byte setzte sind die ansteuerungen der Netzwerkeingänge der Logo im Eimer.
Wenn ich den ersten ansteuer und den wird der zweite mit angesteuert.
Wenn ich nur die länge wieder auf auf 960 setzte klappt die ansteuerung wieder ohne Probleme.

Gruß
Thomas
____________________________________
fhem 6.2  auf Raspberry 3b
Homematic HM-CC-RT-DN / HM-TC-IT-WM-W-EU / HM-SEC-SCo / HM-LC-SW1-PL2
SIGNALduino, KNX (Merten, MDT, Siemens, ABB)

goerdi

Zitat von: charlie71 am 02 Dezember 2014, 21:44:37
Hallo

vielen Dank Christian, ich hab nun deine fixes in eine Version V1.2 gemerged.
Versionsinfo:

1) Auto Reconnect: dh wenn ein Reading von der PLC fehlschlägt versucht das Modul automatisch eine neue Verbindung aufzubauen (reconnect).

Charlie71

Hi !

Ich hab mal ausgiebig getestet.... funktioniert mit meinern 0BA7 tadellos... bis den reconnect..
wenn ich z.B. die Logo lade (dann ist sie logischerweise ein paar Sekunden offline und dann steht das im log
2014.12.11 22:11:30 2: USBWX in Mode LogView found. rmsg=Mode:LogView
2014.12.11 22:13:03 3: SPS2: reading error from PLC errorcode -1025
2014.12.11 22:13:03 3: maxPDUlength was set to: 960
2014.12.11 22:13:03 3: Communicationtype was set to 2
2014.12.11 22:13:03 3: connect to PLC: -1
2014.12.11 22:13:03 1: returnmessage PLC: -1=no message defined!


fhem.pl "goennt" sich dann nahezu 100% CPU und das Webif reagiert nicht mehr.... und wieder zum leben erwacht sie nicht...

Gruss Gerd