Upload
tony-bell
View
3
Download
1
Embed Size (px)
Citation preview
Tony Bell SIMATIC Page 1
Page 1 of 2
FUNCTION_BLOCK FB86TITLE =//Must be called from OB86!//Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block//for evalutationAUTHOR : 'T-Bell'VERSION : 1.1Know_How_Protect
VAR Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events UDT1;END_VARVAR_TEMP OB86_EV_Class : BYTE ; //OB86_EV_Class POINTER1: DWORD ; Lost_Com : BOOL ; Re_Established_Com : BOOL ; OB86_Flt_Id : BYTE ; //OB86_Flt_Id Station_Number : INT ; Year : INT ; Month : INT ; Day : INT ; Hour : INT ; Minute : INT ; Second : INT ; Milisecond : INT ; Counter1 : Int ; END_VARBEGINNETWORKTITLE =
L P##POINTER1; // FIND THE ADDRESS OF POINTER1LAR1; // STRORE IN AR1
L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0T LB [AR1, P#0.0];L 0;T LB [AR1, P#1.0];T LW [AR1, P#2.0];
//Check for profibus slave communication errors and log info into INSTANCE DB//////////////////////////////////////////////////////////////////////////////////////////////////////// L POINTER1; //LOAD POINTER1 INTO AR1 LAR1; L B[AR1, P#1.0]; T #ob86_Flt_Id;
L B[AR1, P#0.0]; T #ob86_EV_Class; //Check if lost com with a slave or com re-established with a slave L 57; //57 dec (39H) Lost com with a slave ==I ; JCN Stp2; //Else, jump to Stp2 slave com re-established = #Lost_Com; //Lost slave com NOT ; = #Re_Established_Com; JU Stp3; //Jump unconditionally to Stp3
Stp2: = #Re_Established_Com; //Slave com re-established NOT ; = #Lost_Com;
// The last byte of Ob86_Racks_Fltd contains the address of the affected slaveStp3: L B[AR1, P#11.0];//Find which slave left or returned T #Station_Number; //Transfer to affected slave
// Pull the date and time the event occured, convert to integer, and store in local temp memory L B[AR1, P#12.0]; BTI ; T #Year; L B[AR1, P#13.0]; BTI ; T #Month; L B[AR1, P#14.0]; BTI ; T #Day; L B[AR1, P#15.0];
FUNCTION_BLOCK FB86TITLE =//Must be called from OB86!//Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block//for evalutationAUTHOR : 'T-Bell'VERSION : 1.1Know_How_Protect
VAR Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events UDT1;END_VARVAR_TEMP OB86_EV_Class : BYTE ; //OB86_EV_Class POINTER1: DWORD ; Lost_Com : BOOL ; Re_Established_Com : BOOL ; OB86_Flt_Id : BYTE ; //OB86_Flt_Id Station_Number : INT ; Year : INT ; Month : INT ; Day : INT ; Hour : INT ; Minute : INT ; Second : INT ; Milisecond : INT ; Counter1 : Int ; END_VARBEGINNETWORKTITLE =
L P##POINTER1; // FIND THE ADDRESS OF POINTER1LAR1; // STRORE IN AR1
L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0T LB [AR1, P#0.0];L 0;T LB [AR1, P#1.0];T LW [AR1, P#2.0];
//Check for profibus slave communication errors and log info into INSTANCE DB//////////////////////////////////////////////////////////////////////////////////////////////////////// L POINTER1; //LOAD POINTER1 INTO AR1 LAR1; L B[AR1, P#1.0]; T #ob86_Flt_Id;
L B[AR1, P#0.0]; T #ob86_EV_Class; //Check if lost com with a slave or com re-established with a slave L 57; //57 dec (39H) Lost com with a slave ==I ; JCN Stp2; //Else, jump to Stp2 slave com re-established = #Lost_Com; //Lost slave com NOT ; = #Re_Established_Com; JU Stp3; //Jump unconditionally to Stp3
Stp2: = #Re_Established_Com; //Slave com re-established NOT ; = #Lost_Com;
// The last byte of Ob86_Racks_Fltd contains the address of the affected slaveStp3: L B[AR1, P#11.0];//Find which slave left or returned T #Station_Number; //Transfer to affected slave
// Pull the date and time the event occured, convert to integer, and store in local temp memory L B[AR1, P#12.0]; BTI ; T #Year; L B[AR1, P#13.0]; BTI ; T #Month; L B[AR1, P#14.0]; BTI ; T #Day; L B[AR1, P#15.0];
Tony Bell SIMATIC Page 2
Page 2 of 2
BTI ; T #Hour;
L B[AR1, P#16.0]; BTI ; T #Minute;
L B[AR1, P#17.0]; BTI ; T #Second; L W[AR1, P#18.0]; SRW 4; BTI ; //Drop day of week T #Milisecond;
//Shift all the slave information down in the buffer data block 99 entries
LAR1 P#1764.0; //Initialize pointer
L 99; L1: T #Counter1; //Initialize the loop counter
L DID [AR1,P#0.0]; //Begin shifting values down in the buffer starting at the next to last entry T DID [AR1,P#18.0]; //The last entry will simply be overwritten
L DID [AR1,P#4.0]; T DID [AR1,P#22.0];
L DID [AR1,P#8.0]; T DID [AR1,P#26.0];
L DID [AR1,P#12.0]; T DID [AR1,P#30.0];
L DIW [AR1,P#16.0]; T DIW [AR1,P#34.0];
TAR1 ; //Subtract 18 bytes from Ar1 (The size of the slave information being stored) L P#18.0; -D ; LAR1 ;
L #Counter1; LOOP L1; //Loop until all values are shifted down
// Overwrite the first entry with the new entry
L LD 6; //Store the slave event information... Lost com, Re-established com, Slave number T DID 0;
L LD 10; //Store the integer converted date and time information T DID 4;
L LD 14; T DID 8;
L LD 18; T DID 12;
L #Milisecond; T DIW 16;
End: SET; SAVE;
END_FUNCTION_BLOCK
BTI ; T #Hour;
L B[AR1, P#16.0]; BTI ; T #Minute;
L B[AR1, P#17.0]; BTI ; T #Second; L W[AR1, P#18.0]; SRW 4; BTI ; //Drop day of week T #Milisecond;
//Shift all the slave information down in the buffer data block 99 entries
LAR1 P#1764.0; //Initialize pointer
L 99; L1: T #Counter1; //Initialize the loop counter
L DID [AR1,P#0.0]; //Begin shifting values down in the buffer starting at the next to last entry T DID [AR1,P#18.0]; //The last entry will simply be overwritten
L DID [AR1,P#4.0]; T DID [AR1,P#22.0];
L DID [AR1,P#8.0]; T DID [AR1,P#26.0];
L DID [AR1,P#12.0]; T DID [AR1,P#30.0];
L DIW [AR1,P#16.0]; T DIW [AR1,P#34.0];
TAR1 ; //Subtract 18 bytes from Ar1 (The size of the slave information being stored) L P#18.0; -D ; LAR1 ;
L #Counter1; LOOP L1; //Loop until all values are shifted down
// Overwrite the first entry with the new entry
L LD 6; //Store the slave event information... Lost com, Re-established com, Slave number T DID 0;
L LD 10; //Store the integer converted date and time information T DID 4;
L LD 14; T DID 8;
L LD 18; T DID 12;
L #Milisecond; T DIW 16;
End: SET; SAVE;
END_FUNCTION_BLOCK