SlideShare a Scribd company logo
1 of 2
Download to read offline
Tony Bell SIMATIC Page 1
Page 1 of 2
FUNCTION_BLOCK FB86
TITLE =
//Must be called from OB86!
//Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block
//for evalutation
AUTHOR : 'T-Bell'
VERSION : 1.1
Know_How_Protect
VAR
Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events
UDT1;
END_VAR
VAR_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_VAR
BEGIN
NETWORK
TITLE =
L P##POINTER1; // FIND THE ADDRESS OF POINTER1
LAR1; // STRORE IN AR1
L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0
T 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 slave
Stp3: 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 FB86
TITLE =
//Must be called from OB86!
//Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block
//for evalutation
AUTHOR : 'T-Bell'
VERSION : 1.1
Know_How_Protect
VAR
Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events
UDT1;
END_VAR
VAR_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_VAR
BEGIN
NETWORK
TITLE =
L P##POINTER1; // FIND THE ADDRESS OF POINTER1
LAR1; // STRORE IN AR1
L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0
T 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 slave
Stp3: 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

More Related Content

Viewers also liked

ONLINE QUALIFICATION SYBASE
ONLINE QUALIFICATION SYBASEONLINE QUALIFICATION SYBASE
ONLINE QUALIFICATION SYBASEAlessandra Paes
 
CERTIFICADO - MARKETING SAP
CERTIFICADO - MARKETING SAPCERTIFICADO - MARKETING SAP
CERTIFICADO - MARKETING SAPAlessandra Paes
 
THE RED ONE DOLLAR COFFEE BALLOON
THE RED ONE DOLLAR COFFEE BALLOONTHE RED ONE DOLLAR COFFEE BALLOON
THE RED ONE DOLLAR COFFEE BALLOONSusan DeVore
 
First Friday August 2015
First Friday August 2015First Friday August 2015
First Friday August 2015JCianciolo
 
Kraft Growth Award Tombstone
Kraft Growth Award TombstoneKraft Growth Award Tombstone
Kraft Growth Award TombstonePreston Whitfield
 
Donna - McCormick C Day Congrats
Donna - McCormick C Day CongratsDonna - McCormick C Day Congrats
Donna - McCormick C Day CongratsDonna Sherman
 
1 conseils généraux
1 conseils généraux1 conseils généraux
1 conseils générauxXavier Larvor
 
제주랜트카『BU797』.『COM』거제도호텔
제주랜트카『BU797』.『COM』거제도호텔제주랜트카『BU797』.『COM』거제도호텔
제주랜트카『BU797』.『COM』거제도호텔sjkdkfsd
 
Campos de la psicologia
Campos de la psicologiaCampos de la psicologia
Campos de la psicologiaGabriel Manzo
 

Viewers also liked (14)

ONLINE QUALIFICATION SYBASE
ONLINE QUALIFICATION SYBASEONLINE QUALIFICATION SYBASE
ONLINE QUALIFICATION SYBASE
 
CERTIFICADO - MARKETING SAP
CERTIFICADO - MARKETING SAPCERTIFICADO - MARKETING SAP
CERTIFICADO - MARKETING SAP
 
THE RED ONE DOLLAR COFFEE BALLOON
THE RED ONE DOLLAR COFFEE BALLOONTHE RED ONE DOLLAR COFFEE BALLOON
THE RED ONE DOLLAR COFFEE BALLOON
 
Ordinario19
Ordinario19Ordinario19
Ordinario19
 
First Friday August 2015
First Friday August 2015First Friday August 2015
First Friday August 2015
 
Kraft Growth Award Tombstone
Kraft Growth Award TombstoneKraft Growth Award Tombstone
Kraft Growth Award Tombstone
 
Jpg2pdf
Jpg2pdfJpg2pdf
Jpg2pdf
 
Donna - McCormick C Day Congrats
Donna - McCormick C Day CongratsDonna - McCormick C Day Congrats
Donna - McCormick C Day Congrats
 
245 tenth avenue 005
245 tenth avenue 005245 tenth avenue 005
245 tenth avenue 005
 
1 conseils généraux
1 conseils généraux1 conseils généraux
1 conseils généraux
 
Doc1
Doc1Doc1
Doc1
 
WASEEM AKRAM CV 2016
WASEEM AKRAM CV 2016WASEEM AKRAM CV 2016
WASEEM AKRAM CV 2016
 
제주랜트카『BU797』.『COM』거제도호텔
제주랜트카『BU797』.『COM』거제도호텔제주랜트카『BU797』.『COM』거제도호텔
제주랜트카『BU797』.『COM』거제도호텔
 
Campos de la psicologia
Campos de la psicologiaCampos de la psicologia
Campos de la psicologia
 

Similar to FB86 Logs Slave Events

EMBEDDED SYSTEMS 2&3
EMBEDDED SYSTEMS 2&3EMBEDDED SYSTEMS 2&3
EMBEDDED SYSTEMS 2&3PRADEEP
 
Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsCorrado Santoro
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Kaku Tomohiro
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051SARITHA REDDY
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)Mashood
 
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxproject4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxwkyra78
 
Csa ic
Csa icCsa ic
Csa icPCTE
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdfShashiKiran664181
 

Similar to FB86 Logs Slave Events (15)

Code 8051
Code 8051Code 8051
Code 8051
 
EMBEDDED SYSTEMS 2&3
EMBEDDED SYSTEMS 2&3EMBEDDED SYSTEMS 2&3
EMBEDDED SYSTEMS 2&3
 
Handling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUsHandling Asynchronous Events in MCUs
Handling Asynchronous Events in MCUs
 
4.Timer_1.ppt
4.Timer_1.ppt4.Timer_1.ppt
4.Timer_1.ppt
 
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
Nefrock勉強会 in大岡山「FPGAでゲーム機を作ろう!の会」Day4
 
BScPLSQL.pdf
BScPLSQL.pdfBScPLSQL.pdf
BScPLSQL.pdf
 
6.pptx
6.pptx6.pptx
6.pptx
 
I o ports and timers of 8051
I o ports and timers of 8051I o ports and timers of 8051
I o ports and timers of 8051
 
Micro c lab7(timers)
Micro c lab7(timers)Micro c lab7(timers)
Micro c lab7(timers)
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docxproject4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
project4-ast.DS_Storeproject4-astast.c#include symbolTa.docx
 
8051 Inturrpt
8051 Inturrpt8051 Inturrpt
8051 Inturrpt
 
8155 GPPI
8155 GPPI8155 GPPI
8155 GPPI
 
Csa ic
Csa icCsa ic
Csa ic
 
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
8051 TIMER COUNTER SERIAL COMM. INTERUPT PROGRAMMING.pdf
 

More from Tony Bell

Bahamas Project
Bahamas ProjectBahamas Project
Bahamas ProjectTony Bell
 
WWTP Profibus Report
WWTP Profibus ReportWWTP Profibus Report
WWTP Profibus ReportTony Bell
 
VBScript HMI
VBScript HMIVBScript HMI
VBScript HMITony Bell
 
Lad VFD Control
Lad VFD ControlLad VFD Control
Lad VFD ControlTony Bell
 
SCL Analog_Scale_Filter
SCL Analog_Scale_FilterSCL Analog_Scale_Filter
SCL Analog_Scale_FilterTony Bell
 

More from Tony Bell (7)

Anguilla 1
Anguilla 1Anguilla 1
Anguilla 1
 
Bahamas Project
Bahamas ProjectBahamas Project
Bahamas Project
 
WWTP Profibus Report
WWTP Profibus ReportWWTP Profibus Report
WWTP Profibus Report
 
HMI Design
HMI DesignHMI Design
HMI Design
 
VBScript HMI
VBScript HMIVBScript HMI
VBScript HMI
 
Lad VFD Control
Lad VFD ControlLad VFD Control
Lad VFD Control
 
SCL Analog_Scale_Filter
SCL Analog_Scale_FilterSCL Analog_Scale_Filter
SCL Analog_Scale_Filter
 

FB86 Logs Slave Events

  • 1. Tony Bell SIMATIC Page 1 Page 1 of 2 FUNCTION_BLOCK FB86 TITLE = //Must be called from OB86! //Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block //for evalutation AUTHOR : 'T-Bell' VERSION : 1.1 Know_How_Protect VAR Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events UDT1; END_VAR VAR_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_VAR BEGIN NETWORK TITLE = L P##POINTER1; // FIND THE ADDRESS OF POINTER1 LAR1; // STRORE IN AR1 L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0 T 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 slave Stp3: 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 FB86 TITLE = //Must be called from OB86! //Logs 100 PN or DP Slave communication errors/events with time stamp info into its instance Data block //for evalutation AUTHOR : 'T-Bell' VERSION : 1.1 Know_How_Protect VAR Slave_Event_Number : ARRAY [1 .. 100 ] OF //////Begin Profibus Slave Communication Events UDT1; END_VAR VAR_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_VAR BEGIN NETWORK TITLE = L P##POINTER1; // FIND THE ADDRESS OF POINTER1 LAR1; // STRORE IN AR1 L B#16#87; //INITIALIZE POINTER1 WITH A POINTER TO FATHER MEMORY 0.0 T 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 slave Stp3: 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];
  • 2. 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