发布于 2008-03-24 15:54:18
0楼
DATA_BLOCK DB 13
VERSION : 0.1
STRUCT
COME : ARRAY [1 .. 16 ] OF BYTE ;
GO : ARRAY [1 .. 16 ] OF BYTE ;
END_STRUCT ;
BEGIN
COME[1] := B#16#0;
COME[2] := B#16#0;
COME[3] := B#16#0;
COME[4] := B#16#0;
COME[5] := B#16#0;
COME[6] := B#16#0;
COME[7] := B#16#0;
COME[8] := B#16#0;
COME[9] := B#16#0;
COME[10] := B#16#0;
COME[11] := B#16#0;
COME[12] := B#16#0;
COME[13] := B#16#0;
COME[14] := B#16#0;
COME[15] := B#16#0;
COME[16] := B#16#0;
GO[1] := B#16#0;
GO[2] := B#16#0;
GO[3] := B#16#0;
GO[4] := B#16#0;
GO[5] := B#16#0;
GO[6] := B#16#0;
GO[7] := B#16#0;
GO[8] := B#16#0;
GO[9] := B#16#0;
GO[10] := B#16#0;
GO[11] := B#16#0;
GO[12] := B#16#0;
GO[13] := B#16#0;
GO[14] := B#16#0;
GO[15] := B#16#0;
GO[16] := B#16#0;
END_DATA_BLOCK
ORGANIZATION_BLOCK OB 82
TITLE = "I/O Point Fault"
VERSION : 0.1
VAR_TEMP
OB82_EV_CLASS : BYTE ; //16#39, Event class 3, Entering event state,
//Internal fault event
OB82_FLT_ID : BYTE ; //16#XX, Fault identification code
OB82_PRIORITY : BYTE ; //26/28 (Priority of 1 is lowest)
OB82_OB_NUMBR : BYTE ; //82 (Organization block 82, OB82)
OB82_RESERVED_1 : BYTE ; //Reserved for system
OB82_IO_FLAG : BYTE ; //Input (01010100), Output (01010101)
OB82_MDL_ADDR : INT ; //Base address of module with fault
OB82_MDL_DEFECT : BOOL ; //Module defective
OB82_INT_FAULT : BOOL ; //Internal fault
OB82_EXT_FAULT : BOOL ; //External fault
OB82_PNT_INFO : BOOL ; //Point information
OB82_EXT_VOLTAGE : BOOL ; //External voltage low
OB82_FLD_CONNCTR : BOOL ; //Field wiring connector missing
OB82_NO_CONFIG : BOOL ; //Module has no configuration data
OB82_CONFIG_ERR : BOOL ; //Module has configuration error
OB82_MDL_TYPE : BYTE ; //Type of module
OB82_SUB_NDL_ERR : BOOL ; //Sub-Module is missing or has error
OB82_COMM_FAULT : BOOL ; //Communication fault
OB82_MDL_STOP : BOOL ; //Module is stopped
OB82_WTCH_DOG_FLT : BOOL ; //Watch dog timer stopped module
OB82_INT_PS_FLT : BOOL ; //Internal power supply fault
OB82_PRIM_BATT_FLT : BOOL ; //Primary battery is in fault
OB82_BCKUP_BATT_FLT : BOOL ; //Backup battery is in fault
OB82_RESERVED_2 : BOOL ; //Reserved for system
OB82_RACK_FLT : BOOL ; //Rack fault, only for bus interface module
OB82_PROC_FLT : BOOL ; //Processor fault
OB82_EPROM_FLT : BOOL ; //EPROM fault
OB82_RAM_FLT : BOOL ; //RAM fault
OB82_ADU_FLT : BOOL ; //ADU fault
OB82_FUSE_FLT : BOOL ; //Fuse fault
OB82_HW_INTR_FLT : BOOL ; //Hardware interrupt input in fault
OB82_RESERVED_3 : BOOL ; //Reserved for system
OB82_DATE_TIME : DATE_AND_TIME ; //Date and time OB82 started
SZL_HEADER : STRUCT
LENTHDR : WORD ;
N_DR : WORD ;
END_STRUCT ;
END_VAR
BEGIN
NETWORK
TITLE =
//Form parameter INDEX for SFC 51 call: Bit 15 should be set in
//#OB82_MDL_ADDR if //a diagnostic interrupt was requested
//by an output channel
L #OB82_IO_FLAG ;
L B#16#54 ;
==I ; //Input?
JC go ; //Bit 15 remains unchanged if input present
L #OB82_MDL_ADDR ;
L W#16#8000;
OW ; //Set bit 15
T #OB82_MDL_ADDR ;
//Determine whether incoming or outgoing event present
go: L #OB82_EV_CLASS ; //Event class and IDs
L B#16#39 ;
==I ; //Incoming event?
JC come ;
//Read out and save diagnostic information
L #OB82_MDL_ADDR;
T MW 30;
CALL SFC 51 //Outgoing event
(REQ := TRUE,
SZL_ID := W#16#00B3,
INDEX := MW 30,
RET_VAL := MW 102 ,
BUSY := M 101.7 ,
SZL_HEADER := #SZL_HEADER,
DR := DB13.GO) ;
BEU ;
come: CALL SFC 51 //Incoming event
(REQ := TRUE,
SZL_ID := W#16#00B3,
INDEX := MW 30,
RET_VAL := MW 102,
BUSY := M 101.7,
SZL_HEADER := #SZL_HEADER,
DR := DB13.COME);
BEU ;
END_ORGANIZATION_BLOCK
ORGANIZATION_BLOCK OB 1
TITLE = "Main Program Sweep (Cycle)"
VERSION : 0.1
VAR_TEMP
OB1_EV_CLASS : BYTE ; //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)
OB1_SCAN_1 : BYTE ; //1 (Cold restart scan 1 of OB 1), 3 (Scan 2-n of OB 1)
OB1_PRIORITY : BYTE ; //1 (Priority of 1 is lowest)
OB1_OB_NUMBR : BYTE ; //1 (Organization block 1, OB1)
OB1_RESERVED_1 : BYTE ; //Reserved for system
OB1_RESERVED_2 : BYTE ; //Reserved for system
OB1_PREV_CYCLE : INT ; //Cycle time of previous OB1 scan (milliseconds)
OB1_MIN_CYCLE : INT ; //Minimum cycle time of OB1 (milliseconds)
OB1_MAX_CYCLE : INT ; //Maximum cycle time of OB1 (milliseconds)
OB1_DATE_TIME : DATE_AND_TIME ; //Date and time OB1 started
END_VAR
BEGIN
NETWORK
TITLE =
NOP 0;
END_ORGANIZATION_BLOCK
活到老,学到老!为了生活学习吧!