de:project_s7:s7_tia_scalance_diag_1

Scalance Modul diagnose (s7-1500, TIA-portal)

english Siemens has released its own diagnosis library for Scalances (109753067_PNDateRecord_LIB_TIA_V21). It works very well, its show the used ports and it can read the IP, MAC address. If – on the other hand – the module shuts down (fails, loses power), the library will it not notify, as far as I know. I have fixed this problem with the program below. It can query any number of Scalance modules and gives only one bit of information about them: faulty or working. This information is usually sufficient for HMIs or SCADAs. In addition, the program reads the status of the ports from the units.

Note: I only had one Scalance module available for testing, so I entered the same HW_ID (260) 3 times and one wrong HW_ID (255) once in the sample program (see image below). The number of Scalances in the program can be set with the constant maxScalNr. HW_IDs must be specified in the “scalanceHwIds” array after specifying the constant.

deutsch Siemens hat eine eigene Diagnosebibliothek für Scalances veröffentlicht (109753067_PNDateRecord_LIB_TIA_V21). Dies funktioniert sehr gut, es liest die verwendeten Ports aus und es kann die IP- und MAC-Adresse lesen. Wenn andererseits das Modul heruntergefahren wird (ausfällt, Strom verliert), benachrichtigt die Bibliothek meines Wissens nicht. Ich habe dieses Problem mit dem folgenden Programm behoben. Es kann eine beliebige Anzahl von Scalance-Modulen abfragen und gibt nur eine Information darüber: fehlerhaft oder funktionsfähig. Diese Informationen sind normalerweise für HMIs oder SCADAs ausreichend. Zusätzlich liest das Programm den Status der Ports von den Einheiten.

Hinweis: Ich hatte nur ein Scalance-Modul zum Testen zur Verfügung, daher habe ich dreimal dieselbe HW_ID (260) und einmal eine falsche HW_ID (255) im Beispielprogramm eingegeben (siehe Abbildung unten). Die Anzahl der Scalances im Programm kann mit der Konstanten maxScalNr eingestellt werden. HW_IDs müssen nach Angabe der Konstante im Array scalanceHwIds angegeben werden.

magyar A Siemens a Scalancekhez kiadott egy saját diagnózis könyvtárat (109753067_PNDateRecord_LIB_TIA_V21). Ez nagyon jól működik, kiadja a használt portokat és kiolvasható belőle az IP, MAC cím. Amennyiben viszont a modul lekapcsolódik (meghibásodik, megszűnik az áramellátása), arról a könyvtár – ismereteim szerint -nem értesít. Ezt a problémát küszöböltem ki az alábbi programmal. Ez tetszőleges számú Scalance modult tud lekérdezni, és csak egy bit információt ad róluk: hibás vagy működik. Ez az információ általában elég a HMI-k vagy SCADA-k felé. Ezen kívül a program beolvassa a portok státuszát az egységekről.

Megjegyzés: A teszteléeshez csak egy Scalance modul állt rendelkezésemre, ezért 3-szor ugyanazt a HW_ID-t (260) és egyszer egy rossz HW_ID-t (255) adtam meg a példaprogramban (lásd a lenti képen). A Scalance-k száma a programban a „maxScalNr” konstanssal állítható. A HW_ID-ket a „scalanceHwIds” tömbben kell megadni, a konstans megadását követően.

[Status of the diagnostic program at runtime. HW_ID 255 is incorrect, this is indicated by the program, as is the failure of that unit.][Scalance XC206-2 and S7-1513]

SCL-Programm download : diagScalances.scl

Siemens Library (and documentation) download: https://support.industry.siemens.com/cs/document/109753067/bibliothek-f%C3%BCr-profinet-datens%C3%A4tze?dti=0&lc=de-WW

deutsch Der Quellcode enthält einen scl-Code (dieser kann auch unten angezeigt werden). Der Code kann im TIA-Portal (16.0) geöffnet und kompiliert werden. Ich habe den Code mit einer Simatic S7-1513 und einer Scalance XC206-2 getestet.

english The source code contains a scl code (this can also be viewed below). The code can be opened and compiled on the TIA portal (16.0). I tested the code with a Simatic S7-1513 and a Scalance XC206-2.

magyar A forráskód egy scl-kódot tartalmaz (ez lent is megtekinthető). A kód a TIA portálon (16.0) nyitható és fordítható. A kódot egy Simatic S7-1513-mal és egy Scalance XC206-2-vel teszteltem.

From file (from 2020.10.30) downloads.

Klicken Sie hier, um den Code anzuzeigen - Click here to view the code

Klicken Sie hier, um den Code anzuzeigen - Click here to view the code

FUNCTION_BLOCK "diagScalances"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR 
      scalanceHwIds : Array[0..#maxScalNr] of UInt := [4(260)];
      scalanceErr : Array[0..#maxScalNr] of Bool;
      portLinkState : Array[1..8] of Byte;
      hwId : UInt;
      step3TON {InstructionName := 'TON_TIME'; LibVersion := '1.0'; S7_SetPoint := 'False'} : TON_TIME;
      exec : Bool;
      busy : Bool;
      done : Bool;
      error : Bool;
      status : Word;
      portInfo { S7_SetPoint := 'False'} : Array[1..8] of "LPNDR_typePortInformation";
      step { S7_SetPoint := 'True'} : Int;
      scalNr : Int;
      i : Int;
   END_VAR
 
   VAR CONSTANT 
      maxScalNr : Int := 3;
   END_VAR
 
 
BEGIN
	// Vamos, OB121
	// tested with TIA 16.0
 
	// NEED stetting:
	// maxScaleNr : number of scalances
	// scalanceHwIds : array of HWIDs (scalance HW ID interfaces from :
	// Devices & networks / Scalance / Properties / System constans / ~SCALANCE_interface_1 )
 
	// step0 : init (only one times after newstart)
	// step1 : set hw_id
	// step2 : exec set to 1
	// step3 : wait for answer
	// step4 : exec back to 0, error? write portLinkState array
	// step5 : next scalance nr -> step1
 
	// time functions
	// 
	#step3TON(IN:=(#step = 3),  // wait in step3, 2sec can modify
	          PT:=t#2s);
 
	IF #step = 0 THEN   // newstart, init
	    #scalNr := 0;   // start with first scalance
	    #step := 1;     // next step
	    #exec := false; // execute <- false
	    GOTO eof;
	END_IF;
 
	IF #step = 1 THEN // step1 : set hw_id
	    #hwId := #scalanceHwIds[#scalNr];  // hd id for scalance
	    #step := 2;
	    GOTO eof;
	END_IF;
 
	IF #step = 2 THEN   // step2 : exec set to 1
	    #exec := true; // execute <- true: start read process
	    #step := 3;
	    GOTO eof;
	END_IF;
 
	IF #step = 3 THEN        // step3 : wait for answer; wait 2sec (can modify)
	    IF #step3TON.Q THEN
	        #step := 4;
	    END_IF;
	    GOTO eof;
	END_IF;
 
	// portLinkState status:
	// 
	// 1 - Link is up
	// 2 - Link is down
	// 3 - port is in "testing" #status
	// 4 - Link #status is unknown
	// 5 - port is in "demand" mode
	// 6 - Link #status is NOT available
	// 7 - port #status is "LowerLayerDown"
 
	IF #step = 4 THEN  // step4 : exec back to 0, error? write portLinkState array
	    #exec := false; // execute <- false: stop read process
	    FOR #i := 1 TO 8 DO
	        #portLinkState[#i] := #portInfo[#i].portDiagnostic.portLinkState;
	    END_FOR;
	    #scalanceErr[#scalNr] := #done = false OR #error = true;
	    #step := 5;
	    GOTO eof;
	END_IF;
 
	IF #step = 5 THEN  // step5 : next scalance nr -> step1   
	    #step := 1;
	    #scalNr := #scalNr + 1;
	    IF #scalNr > #maxScalNr THEN
	        #scalNr := 0;
	    END_IF;
	    GOTO eof;
	END_IF;
 
	eof:
	;
 
	// 1: Interface information,
	// 2: MRP information,
	// 3: PORT information,
	// 4: PORT link status,
	// 5: PORT statistics
 
	// LPNDR software (and documentation) can download from:
	// https://support.industry.siemens.com/cs/document/109753067/bibliothek-f%C3%BCr-profinet-datens%C3%A4tze?dti=0&lc=de-WW
 
	"LPNDR_ReadGlobalInfo_DB"(execute:=#exec,
	                          hwId:=#hwId,
	                          mode:=3,
	                          busy=>#busy,
	                          done=>#done,
	                          error=>#error,
	                          status=>#status,
	                          DataRecord:=#portInfo);
 
 
 
 
END_FUNCTION_BLOCK

Donate

If you have any further questions or have any issues that you can't handle, please contact me! » Impressum

~~socialite~~

2022/04/21 15:01
  • de/project_s7/s7_tia_scalance_diag_1.txt
  • 2022/04/21 15:01
  • ()