PtP: Point-to-Point communication instructions (5 from 11 sources)

: 2016-09-13

: komatic

: SCL



ptp



STEP 7 has extended instructions that the user program can use for point-to-point communication via a protocol specified in the user program.

Hardware - ET 200MP/ET 200SP (S7300/400)
● CM PtP RS232 BA (6ES7540-1AD00-0AA0) communication module
● CM PtP RS422/485 BA (6ES7540-1AB00-0AA0) communication module
● CM PtP RS232 HF (6ES7541-1AD00-0AB0) communication module
● CM PtP RS422/485 HF (6ES7541-1AB00-0AB0) communication module
● CM PtP (6ES7137-6AA00-0BA0) communication module





Block list:



FB610 - Port_Config



Name: PortConf
Symbolic Name: Port_Config
Symbol Comment: Port configuration
Family: Freeport
Version: 1.0
Author: SIMATIC
Last modified: 09/28/2012
Use: SFB52,SFB53
Size in work memory: 854 bytes
Object name: Port_Config
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.06.00_01.03.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'n' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'n' ;
Scl_CreateDebugInfo := 'n' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}
FUNCTION_BLOCK FB1610
TITLE ='Port Configuration'
AUTHOR : SIMATIC
FAMILY : Freeport
NAME : PortConf
VERSION : '1.0'
 
 
VAR_INPUT
REQ : BOOL ; //Activates configuration of the port on rising edge
PORT : WORD ; //Communication port, Hardware Identifier
PROTOCOL : WORD ; //Protocol selection: 0=Freeport, 1=3964(R)
BAUD : WORD ; //Transmission rate
PARITY : WORD ; //Parity
DATABITS : WORD ; //Number of data bits
STOPBITS : WORD ; //Number of stop bits
FLOWCTRL : WORD ; //Enable flow control
XONCHAR : CHAR ; //XON character
XOFFCHAR : CHAR ; //XOFF character
WAITTIME : WORD := W#16#7D0; //Time to wait for XON/RTS after receiving XOFF/CTS (ms)
MODE : BYTE ; //Duplex operation mode
LINE_PRE : BYTE ; //Presetting of the receive line
BRK_DET : BYTE ; //RS232 BREAK Handling
END_VAR
VAR_OUTPUT
DONE : BOOL ; //Instruction finished without error
ERROR : BOOL ; //Instruction finished with error
STATUS : WORD := W#16#7000; //Detailed error information
END_VAR
VAR_IN_OUT
COM_RST : BOOL ; //Complete restart
END_VAR
VAR
b_e_REQ : BOOL ; //Edge flag for REQ
y_state : BYTE ; //State of instruction
WRREC : SFB53; //Local instance of instruction WRREC
RDREC : SFB52; //Local instance of instruction RDREC
END_VAR
VAR_TEMP
tmpSTATUS : WORD ; //Status, when Error occured
w_record : STRUCT
header : STRUCT
block_type : WORD ;
block_len : WORD ;
block_ver : WORD ;
res : WORD ;
END_STRUCT ;
net_data : STRUCT
PROTOCOL : WORD ; //Protocol selections: 0=Freeport
BAUD : WORD ; //Baud rate of the port
PARITY : WORD ; //Parity of the port
DATABITS : WORD ; //Number of data bits
STOPBITS : WORD ; //Number of stop bits
FLOWCTRL : WORD ; //enables or disables flow control
XONCHAR : CHAR ; //Actual XON character.
XOFFCHAR : CHAR ; //Actual XOFF character
WAITTIME : WORD ; //Amount of time to wait for XON after receiving XOFF or CTS after enabling RTS
MODE : BYTE ; //0 = RS422; 1 = RS485
LINE_PRE : BYTE ; //Presetting of the receive line
BRK_DET : BYTE ; //RS232 BREAK Handling
LibSupport : BYTE ; //Library Support
res : BYTE ; //reserved
END_STRUCT ;
END_STRUCT ;
r_record : STRUCT
header : STRUCT
block_type : WORD ;
block_len : WORD ;
block_ver : WORD ;
res : WORD ;
END_STRUCT ;
e1 : WORD ;
porterr : WORD ;
END_STRUCT ;
END_VAR
BEGIN
IF COM_RST THEN (*A7d0*)
b_e_REQ:=FALSE;
y_state:=B#16#0;
WRREC.BUSY:=FALSE;
RDREC.BUSY:=FALSE;
COM_RST:=FALSE;
END_IF; (*A7d0*)
ERROR:=FALSE;
DONE:=FALSE;
IF ((NOT(b_e_REQ)) AND REQ) AND (y_state=B#16#0) THEN (*A7d1*)
y_state:=B#16#1;
END_IF; (*A7d1*)
b_e_REQ:=REQ;
IF y_state=B#16#1 THEN (*A7d2*)
IF NOT(WRREC.BUSY) THEN (*A7d3*)
tmpSTATUS:=W#16#7001;
w_record.header.block_type:=W#16#39;
w_record.header.block_len:=W#16#18;
w_record.header.block_ver:=W#16#100;
w_record.header.res:=W#16#0;
w_record.net_data.PROTOCOL:=PROTOCOL;
w_record.net_data.BAUD:=BAUD;
w_record.net_data.PARITY:=PARITY;
w_record.net_data.DATABITS:=DATABITS;
w_record.net_data.STOPBITS:=STOPBITS;
w_record.net_data.FLOWCTRL:=FLOWCTRL;
w_record.net_data.XONCHAR:=XONCHAR;
w_record.net_data.XOFFCHAR:=XOFFCHAR;
w_record.net_data.WAITTIME:=WAITTIME;
w_record.net_data.MODE:=MODE;
w_record.net_data.LINE_PRE:=LINE_PRE;
w_record.net_data.BRK_DET:=BRK_DET;
w_record.net_data.LibSupport:=B#16#0;
w_record.net_data.res:=B#16#0;
ELSE (*A7d3*)
tmpSTATUS:=W#16#7002;
END_IF; (*A7d4*)
WRREC(REQ := NOT(WRREC.BUSY)
,ID := PORT// IN: DWORD
,INDEX := 57 // IN: INT
,LEN := 28 // IN: INT
,RECORD := w_record // INOUT: ANY
);
IF WRREC.ERROR THEN (*A7d5*)
IF (WRREC.STATUS AND DW#16#FFFF00)=DW#16#80E100 THEN (*A7d6*)
y_state:=B#16#2;
ELSIF (WRREC.STATUS AND DW#16#F500)=DW#16#C500 THEN (*A7d8*)
ERROR:=TRUE;
tmpSTATUS:=W#16#8282;
y_state:=B#16#0;
ELSIF (WRREC.STATUS AND DW#16#F000)<>DW#16#C000 THEN (*A7db*)
ERROR:=TRUE;
tmpSTATUS:=W#16#8281;
y_state:=B#16#0;
END_IF; (*A7d7*)
ELSIF NOT(WRREC.BUSY) THEN (*A7db*)
tmpSTATUS:=W#16#0;
y_state:=B#16#0;
DONE:=TRUE;
END_IF; (*A7db*)
STATUS:=tmpSTATUS;
ELSIF y_state=B#16#2 THEN (*A7dd*)
RDREC(REQ := NOT(RDREC.BUSY) // IN: BOOL
,ID := PORT // IN: DWORD
,INDEX := 55 // IN: INT
,MLEN := 12 // IN: INT
,RECORD := r_record // INOUT: ANY
);
IF RDREC.ERROR THEN (*A7de*)
IF (RDREC.STATUS AND DW#16#F500)=DW#16#C500 THEN (*A7df*)
ERROR:=TRUE;
tmpSTATUS:=W#16#8282;
y_state:=B#16#0;
ELSIF (RDREC.STATUS AND DW#16#F000)<>DW#16#C000 THEN (*A7dc*)
ERROR:=TRUE;
STATUS:=W#16#8280;
y_state:=B#16#0;
END_IF; (*A7e0*)
ELSIF NOT(RDREC.BUSY) THEN (*A7e3*)
STATUS:=r_record.porterr;
y_state:=B#16#0;
ERROR:=TRUE;
ELSE (*A7e3*)
STATUS:=W#16#7002;
END_IF;
ELSE (*A7dd*)
STATUS:=W#16#7000;
END_IF; (*A7dc*)
IF ERROR THEN (*A7e4*)
OK:=FALSE;
END_IF; (*A7e4*)
END_FUNCTION_BLOCK



ptp

Block checksum , ,
, .





FB611 (Send_Config) V1.0



Name: SendConf
Symbolic Name: Send_Config
Symbol Comment: Send configuration
Family: Freeport
Version: 1.0
Author: SIMATIC
Last modified: 10/30/2012
Use: SFB52,SFB53
Size in work memory: 928 bytes
Object name: Send_Config
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.06.00_01.03.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'n' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'n' ;
Scl_CreateDebugInfo := 'n' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}
FUNCTION_BLOCK FB1611
TITLE ='Send Configuration'
AUTHOR : SIMATIC
FAMILY : Freeport
NAME : SendConf
VERSION : '1.0'
 
 
VAR_INPUT
REQ : BOOL ; //Activates the configuration for sending on rising edge
PORT : WORD ; //Communication port, Hardware Identifier
RTSONDLY : WORD ; //Time to wait after activating RTS before transmission will be initiated (ms)
RTSOFFDLY : WORD ; //Time to wait before de-activating RTS once transmission has been completed (ms)
BREAK : WORD ; //On start of a message, a break will be sent for the specified no. of bit times
IDLELINE : WORD ; //Number of bits times the line will be idle before the next transmission
USR_END : STRING [2 ]; //Number of characters in the end delimiter
USR_END_c AT USR_END : ARRAY[0..3] OF BYTE;
APP_END : STRING [5 ]; //Number of characters to be appended to the transmitted message
APP_END_c AT APP_END : ARRAY[0..6] OF BYTE;
END_VAR
VAR_OUTPUT
DONE : BOOL ; //Instruction finished without error
ERROR : BOOL ; //Instruction finished with error
STATUS : WORD := W#16#7000; //Detailed error information
END_VAR
VAR_IN_OUT
COM_RST : BOOL ; //Complete restart
END_VAR
VAR
b_e_REQ : BOOL ; //Edge flag for REQ
y_state : BYTE ; //State of instruction
WRREC : SFB53; //Local instance of instruction WRREC
RDREC : SFB52; //Local instance of instruction RDREC
END_VAR
VAR_TEMP
tmpSTATUS : WORD ; //Status, when Error occured
w_record : STRUCT
header : STRUCT
block_type : WORD ;
block_len : WORD ;
block_ver : WORD ;
res : WORD ;
END_STRUCT ;
net_data : STRUCT
RTSONDLY : WORD ; //Time to wait after activating RTS before transmission will be initiated
RTSOFFDLY : WORD ; //Time to wait before de-activating RTS once transmission has been completed
BREAK : WORD ; //On start of a message, a break will be sent for the specified no. of bit times
IDLELINE : WORD ; //Number of bits times the line will be idle after the break on start of message
Conditions : WORD ; //unused by FB
USR_ECHR_MAX : BYTE ; //Max String length
USR_ECHR_CNT : BYTE ; //number of characters in the end delimiter
USR_END_CHR1 : CHAR ; //value of the first character in the end delimiter
USR_END_CHR2 : CHAR ; //value of the second character in the end delimiter
APP_ECHR_MAX : BYTE ; //Max String length
APP_ECHR_CNT : BYTE ; //number of end characters to be appended to the transmitted message
APP_END_CHR1 : CHAR ; //value of the first end character to be appended to the transmitted message
APP_END_CHR2 : CHAR ; //value of the second end character to be appended to the transmitted message
APP_END_CHR3 : CHAR ; //value of the third end character to be appended to the transmitted message
APP_END_CHR4 : CHAR ; //value of the fourth end character to be appended to the transmitted message
APP_END_CHR5 : CHAR ; //value of the fifth end character to be appended to the transmitted message
reserved : BYTE ;
reserved1 : BYTE ;
reserved2 : BYTE ;
END_STRUCT ;
END_STRUCT ;
w_record_ar AT w_record : ARRAY[0..13] OF BYTE;

END_VAR
BEGIN
IF COM_RST THEN (*A7d0*)
b_e_REQ:=FALSE;
y_state:=B#16#0;
WRREC.BUSY:=FALSE;
RDREC.BUSY:=FALSE;
COM_RST:=FALSE;
END_IF; (*A7d0*)
ERROR:=FALSE;
DONE:=FALSE;
IF ((NOT(b_e_REQ)) AND REQ) AND (y_state=B#16#0) THEN (*A7d1*)
y_state:=B#16#1;
END_IF; (*A7d1*)
b_e_REQ:=REQ;
IF y_state=B#16#1 THEN (*A7d2*)
IF NOT(WRREC.BUSY) THEN (*A7d3*)
tmpSTATUS:=W#16#7001;
w_record.header.block_type:=W#16#3B;
w_record.header.block_len:=W#16#1C;
w_record.header.block_ver:=W#16#100;
w_record.header.res:=W#16#0;
w_record.net_data.RTSONDLY:=RTSONDLY;
w_record.net_data.RTSOFFDLY:=RTSOFFDLY;
w_record.net_data.BREAK:=BREAK;
w_record.net_data.IDLELINE:=IDLELINE;
w_record.net_data.Conditions:=W#16#0;
w_record.net_data.USR_ECHR_MAX:=B#16#2;
w_record.net_data.USR_ECHR_CNT:=USR_END_c[1];
w_record.net_data.USR_END_CHR1:=BYTE_TO_CHAR(USR_END_c[2]);
w_record.net_data.USR_END_CHR2:=BYTE_TO_CHAR(USR_END_c[3]);
w_record.net_data.APP_ECHR_MAX:=B#16#5;
w_record.net_data.APP_ECHR_CNT:=APP_END_c[1];
w_record.net_data.APP_END_CHR1:=BYTE_TO_CHAR(APP_END_c[2]);
w_record.net_data.APP_END_CHR2:=BYTE_TO_CHAR(APP_END_c[3]);
w_record.net_data.APP_END_CHR3:=BYTE_TO_CHAR(APP_END_c[4]);
w_record.net_data.APP_END_CHR4:=BYTE_TO_CHAR(APP_END_c[5]);
w_record.net_data.APP_END_CHR5:=BYTE_TO_CHAR(APP_END_c[6]);
w_record.net_data.reserved:=B#16#0;
w_record.net_data.reserved1:=B#16#0;
w_record.net_data.reserved2:=B#16#0;
ELSE (*A7d3*)
tmpSTATUS:=W#16#7002;
END_IF; (*A7d4*)
WRREC(REQ := NOT(WRREC.BUSY)
,ID := PORT
,INDEX := 59 // IN: INT
,LEN := 32 // IN: INT
,RECORD := w_record // INOUT: ANY
);
IF WRREC.ERROR THEN (*A7d5*)
IF (WRREC.STATUS AND DW#16#FFFF00)=DW#16#80E100 THEN (*A7d6*)
y_state:=B#16#2;
ELSIF (WRREC.STATUS AND DW#16#F500)=DW#16#C500 THEN (*A7d8*)
ERROR:=TRUE;
tmpSTATUS:=W#16#8282;
y_state:=B#16#0;
ELSIF (WRREC.STATUS AND DW#16#F000)<>DW#16#C000 THEN (*A7db*)
ERROR:=TRUE;
tmpSTATUS:=W#16#8281;
y_state:=B#16#0;
END_IF; (*A7d7*)
ELSIF NOT(WRREC.BUSY) THEN (*A7db*)
tmpSTATUS:=W#16#0;
y_state:=B#16#0;
DONE:=TRUE;
END_IF; (*A7db*)
STATUS:=tmpSTATUS;
ELSIF y_state=B#16#2 THEN (*A7dd*)
RDREC(REQ := NOT(RDREC.BUSY) // IN: BOOL
,ID := PORT // IN: DWORD
,INDEX := 55 // IN: INT
,MLEN := 14 // IN: INT
,RECORD := w_record_ar // INOUT: ANY
);
IF RDREC.ERROR THEN (*A7de*)
IF (RDREC.STATUS AND DW#16#F500)=DW#16#C500 THEN (*A7df*)
ERROR:=TRUE;
STATUS:=W#16#8282;
y_state:=B#16#0;
ELSIF (RDREC.STATUS AND DW#16#F000)<>DW#16#C000 THEN (*A7dc*)
ERROR:=TRUE;
STATUS:=W#16#8280;
y_state:=B#16#0;
END_IF; (*A7e0*)
ELSIF NOT(RDREC.BUSY) THEN (*A7e3*)
STATUS:=w_record.net_data.BREAK;
y_state:=B#16#0;
ERROR:=TRUE;
ELSE (*A7e3*)
STATUS:=W#16#7002;
END_IF;
ELSE (*A7dd*)
STATUS:=W#16#7000;
END_IF; (*A7dc*)
IF ERROR THEN (*A7e4*)
OK:=FALSE;
END_IF; (*A7e4*)
 
END_FUNCTION_BLOCK



ptp

Block checksum , ,
, .



FB612 (Receive_Config) V1.0 / UDT580 (Receive_Conditions) V1.0











FB613 (Send_P2P) V1.2











FB614 (Receive_P2P) V1.1











FB615 (Signal_Get) V1.0



Name: SgnGet
Symbolic Name: Signal_Get
Symbol Comment: Get RS-232 signals
Family: Freeport
Version: 1.0
Author: SIMATIC
Last modified: 09/28/2012
Use: SFB52,SFB53
Size in work memory: 250 bytes
Object name: Signal_Get
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.06.00_01.03.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'n' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'n' ;
Scl_CreateDebugInfo := 'y' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}
FUNCTION_BLOCK FB1615
TITLE ='Get RS-232 signals'
AUTHOR : SIMATIC
FAMILY : Freeport
NAME : SgnGet
VERSION : '1.0'
 
 
VAR_INPUT
REQ : BOOL ; //Reads the RS 232 signals on rising edge
PORT : WORD ; //Communication port, Hardware Identifier
END_VAR
VAR_OUTPUT
NDR : BOOL ; //Instruction finished without error
ERROR : BOOL ; //Instruction finished with error
STATUS : WORD := W#16#7000; //Detailed error information
DTR : BOOL ; //Data terminal ready, module ready
DSR : BOOL ; //Data set ready, communication partner ready
RTS : BOOL ; //Request to send, module ready to send
CTS : BOOL ; //Clear to send, communication partner can receive data from the module
DCD : BOOL ; //Data carrier detect, receive signal level
RING : BOOL ; //Ring indicator, indication of incoming call
END_VAR
VAR
b_e_REQ : BOOL ; //edge flag for REQ
END_VAR
VAR_TEMP
net_data : STRUCT
V24signals : BYTE ; //V24 signals
res : BYTE ;
END_STRUCT ;
V24signals_b AT net_data : ARRAY[0..7] OF BOOL;
END_VAR
BEGIN
ERROR:=FALSE;
NDR:=FALSE;
IF (NOT(b_e_REQ)) AND REQ THEN (*A7d0*)
net_data.V24signals:=PIB[WORD_TO_DINT(PORT)+0];
IF V24signals_b[7] THEN (*A7d1*)
DTR:=V24signals_b[0];
DSR:=V24signals_b[1];
RTS:=V24signals_b[2];
CTS:=V24signals_b[3];
DCD:=V24signals_b[4];
RING:=V24signals_b[5];
NDR:=TRUE;
STATUS:=W#16#0;
ELSE (*A7d1*)
ERROR:=TRUE;
STATUS:=W#16#81F0;
END_IF;
ELSE (*A7d0*)
STATUS:=W#16#7000;
END_IF; (*A7d3*)
b_e_REQ:=REQ;
IF ERROR THEN (*A7d4*)
OK:=FALSE;
END_IF; (*A7d4*)
END_FUNCTION_BLOCK



ptp

Block checksum , ,
, .



FB616 (Signal_Set) V1.0



Name: SgnSet
Symbolic Name: Signal_Set
Symbol Comment: Set RS-232 signals
Family: Freeport
Version: 1.0
Author: SIMATIC
Last modified: 09/28/2012
Use: SFB52,SFB53
Size in work memory: 780 bytes
Object name: Port_Config
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.06.00_01.03.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'n' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'n' ;
Scl_CreateDebugInfo := 'n' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}
FUNCTION_BLOCK FB1616
TITLE = 'Set RS-232 signals'
AUTHOR : SIMATIC
FAMILY : Freeport
NAME : SgnSet
VERSION : '1.0'
 
VAR_INPUT
REQ : BOOL ; //Sets the RS 232 signals on rising edge
PORT : WORD ; //Communication port, Hardware Identifier
SIGNAL : BYTE ; //Selects the signals to be set; bit 1H=RTS; 2H=DTR; 4H=DSR; 7H=select all
RTS : BOOL ; //Specifies the level (ON/OFF) of the RTS output
DTR : BOOL ; //Specifies the level (ON/OFF) of the DTR output
DSR : BOOL ; //Specifies the level (ON/OFF) of the DSR output
END_VAR
VAR_OUTPUT
DONE : BOOL ; //Instruction finished without error
ERROR : BOOL ; //Instruction finished with error
STATUS : WORD := W#16#7000; //Detailed error information
END_VAR
VAR_IN_OUT
COM_RST : BOOL ; //Complete restart
END_VAR
VAR
b_e_REQ : BOOL ; //Edge flag for REQ
y_state : BYTE ; //State of instruction
WRREC : "WRREC"; //Local instance of instruction WRREC
RDREC : "RDREC"; //Local instance of instruction RDREC
END_VAR
VAR_TEMP
tmpSTATUS : WORD ; //Status, when Error occured
r_record : STRUCT
header : STRUCT
block_type : WORD ;
block_len : WORD ;
block_ver : WORD ;
res : WORD ;
END_STRUCT ;
e1 : WORD ;
e2 : WORD ;
e3 : WORD ;
e4 : WORD ;
sgnseterr : WORD ;
END_STRUCT ;
r_record_b1 AT r_record : STRUCT
a : ARRAY[0..10] OF BYTE;
END_STRUCT;
r_record_b2 AT r_record : STRUCT
a : ARRAY[0..120] OF BOOL;
END_STRUCT;
 
END_VAR
 
IF COM_RST THEN
b_e_REQ := false;
y_state := b#16#0;
WRREC.BUSY := false;
RDREC.BUSY := false;
COM_RST := false;
END_IF;
 
ERROR := false;
DONE := false;
 
IF NOT b_e_REQ AND REQ AND (y_state = B#16#0) THEN
y_state := B#16#1;
END_IF;
 
b_e_REQ := REQ;
 
IF y_state = b#16#1 THEN

IF NOT WRREC.BUSY THEN
tmpSTATUS := w#16#7001;
r_record.header.block_type := w#16#35;
r_record.header.block_len := W#16#8;
r_record.header.block_ver := W#16#100;
r_record.header.res := W#16#0;
r_record_b1.a[8]:=SIGNAL;
r_record_b2.a[72]:=RTS;
r_record_b2.a[73]:=DTR;
r_record_b2.a[74]:=DSR;
ELSE
tmpSTATUS := w#16#7002;
END_IF;
WRREC(REQ := NOT(WRREC.BUSY)
,ID := PORT// IN: DWORD
,INDEX := 53 // IN: INT
,LEN := 12 // IN: INT
,RECORD := r_record_b1 // INOUT: ANY
);
IF WRREC.ERROR THEN
IF (WRREC.STATUS AND DW#16#FFFF00) = DW#16#80E100 THEN
y_state := b#16#2;
ELSIF (WRREC.STATUS AND DW#16#F500) = DW#16#C500 THEN
ERROR := true;
tmpSTATUS := w#16#8282;
y_state := b#16#0;
ELSIF (WRREC.STATUS AND DW#16#F000) <> DW#16#C000 THEN
ERROR := true;
tmpSTATUS := w#16#8281;
y_state := b#16#0;
END_IF;
ELSIF NOT WRREC.BUSY THEN // possible here is :: ELSE IF NOT WRREC.BUSY
tmpSTATUS := w#16#0;
y_state := b#16#0;
DONE := true;
END_IF;

STATUS := tmpSTATUS;

ELSIF y_state = b#16#2 THEN
RDREC(REQ := NOT(RDREC.BUSY) // IN: BOOL
,ID := PORT // IN: DWORD
,INDEX := 55 // IN: INT
,MLEN := 18 // IN: INT
,RECORD := r_record // INOUT: ANY
);
 
IF RDREC.ERROR THEN
IF (RDREC.STATUS AND DW#16#F500) = DW#16#C500 THEN
ERROR := true;
STATUS := W#16#8282;
y_state := b#16#0;
ELSIF (RDREC.STATUS AND DW#16#F000) <> DW#16#C000 THEN
ERROR := true;
STATUS := W#16#8280;
y_state := b#16#0;
END_IF;
ELSIF NOT RDREC.BUSY THEN
y_state := b#16#0;
STATUS := r_record.sgnseterr;
ERROR := true;
ELSE
STATUS := w#16#7002;
END_IF;
ELSE
STATUS := w#16#7000;
END_IF;
 
IF ERROR THEN
OK := false;
END_IF;

END_FUNCTION_BLOCK



ptp

Block checksum , ,
, .



FB617 (Receive_Reset) V1.0











FB618 (Get_Features) V2.0











FB619 (Set_Features) V2.0











FB620 (P3964_Config) V1.1



Name: P3964CFG
Symbolic Name: P3964_Config
Symbol Comment: 3964 configuration
Family: Freeport
Version: 1.1
Author: SIMATIC
Last modified: 07/31/2013
Use: SFB52,SFB53
Size in work memory: 796 bytes
Object name: Signal_Get
Signature: generiert vom SCL Übersetzer Version: SCLCOMP K05.03.06.00_01.03.00.01 release





{
Scl_ResetOptions ;
Scl_OverwriteBlocks:= 'y' ;
Scl_GenerateReferenceData := 'y' ;
Scl_S7ServerActive:= 'n' ;
Scl_CreateObjectCode:= 'y' ;
Scl_OptimizeObjectCode:= 'y' ;
Scl_MonitorArrayLimits:= 'n' ;
Scl_CreateDebugInfo := 'n' ;
Scl_SetOKFlag:= 'n' ;
Scl_SetMaximumStringLength:= '254'
}
FUNCTION_BLOCK FB1620
TITLE = '3964 Configuration'
AUTHOR : SIMATIC
FAMILY : Freeport
NAME : P3964CFG
VERSION : '1.1'
 
VAR_INPUT
REQ : BOOL ; //Activates configuration of 3964 on rising edge
PORT : WORD ; //Communication port, Hardware Identifier
BCC : BYTE := B#16#1; //Enable Block check character; 0 = without, 1 = with
Priority : BYTE ; //Priority, when initialization conflict occured
CharacterDelayTime : WORD := W#16#DC; //Character delay time (bittimes)
AcknDelayTime : WORD := W#16#7D0; //Acknowledgment delay time
BuildupAttempts : BYTE := B#16#6; //Acknowledgment delay time (bittimes)
RepetitionAttempts : BYTE := B#16#6; //Maximal number of setup attempts
END_VAR
VAR_OUTPUT
DONE : BOOL ; //Instruction finished without error
ERROR : BOOL ; //Instruction finished with error
STATUS : WORD := W#16#7000; //Detailed error information
END_VAR
VAR_IN_OUT
COM_RST : BOOL ; //Complete restart
END_VAR
VAR
b_e_REQ : BOOL ; //Edge flag for REQ
y_state : BYTE ; //State of instruction
WRREC : SFB53; //Local instance of instruction WRREC
RDREC : SFB52; //Local instance of instruction RDREC
END_VAR
VAR_TEMP
tmpSTATUS : WORD ; //Status, when Error occured
r_record : STRUCT
header : STRUCT
block_type : WORD ;
block_len : WORD ;
block_ver : WORD ;
res : WORD ;
END_STRUCT ;
e1 : WORD ;
e2 : WORD ;
e3 : WORD ;
e4 : WORD ;
e5 : WORD ;
r3964err : WORD ;
END_STRUCT ;
r_record_b AT r_record : ARRAY[0..19] OF BYTE;
r_record_b1 AT r_record : ARRAY[0..15] OF BYTE;
END_VAR
 
IF COM_RST THEN (*M001*)
b_e_REQ:=FALSE;
y_state:=B#16#0;
WRREC.BUSY:=FALSE;
RDREC.BUSY:=FALSE;
COM_RST:=FALSE;
END_IF; (*M001*)
 
ERROR:=FALSE;
DONE:=FALSE;
 
IF NOT b_e_REQ AND REQ AND y_state = B#16#0 THEN
y_state:= B#16#1;
END_IF;
 
b_e_REQ:= REQ;
 
IF y_state = B#16#1 THEN
IF NOT WRREC.BUSY THEN
tmpSTATUS:= W#16#7001;
r_record.header.block_type:= W#16#3D;
r_record.header.block_len:= W#16#C;
r_record.header.block_ver:= W#16#100;
r_record.header.res:= W#16#0;
r_record_b[8]:= BCC;
r_record_b[9]:=Priority;
r_record.e2:= CharacterDelayTime;
r_record.e3:= AcknDelayTime;
r_record_b[14]:=BuildupAttempts;
r_record_b[15]:= RepetitionAttempts;
ELSE
tmpSTATUS:= W#16#7002;
END_IF;
WRREC(REQ := NOT(WRREC.BUSY)
,ID := PORT// IN: DWORD
,INDEX := 61 // IN: INT
,LEN := 16 // IN: INT
,RECORD := r_record_b1 // INOUT: ANY
);

IF WRREC.ERROR THEN
IF (WRREC.STATUS AND DW#16#FFFF00) = DW#16#80E100 THEN
y_state:= B#16#2;
ELSIF (WRREC.STATUS AND DW#16#F500) = DW#16#C500 THEN
ERROR:= TRUE;
tmpSTATUS:= W#16#8282;
y_state:= B#16#0;
ELSIF (WRREC.STATUS AND DW#16#F000) <> DW#16#C000 THEN
ERROR:= TRUE;
tmpSTATUS:= W#16#8281;
y_state:= B#16#0;
END_IF;
ELSIF NOT WRREC.BUSY THEN
tmpSTATUS:=W#16#0;
y_state:=B#16#0;
DONE:=TRUE;
END_IF;
STATUS:=tmpSTATUS;

ELSIF y_state = B#16#2 THEN
RDREC(REQ := NOT(RDREC.BUSY)
,ID := PORT// IN: DWORD
,INDEX := 55 // IN: INT
,MLEN := 20 // IN: INT
,RECORD := r_record // INOUT: ANY
);
IF RDREC.ERROR THEN (*M00d*)
IF (RDREC.STATUS AND DW#16#F500)=DW#16#C500 THEN
ERROR:= TRUE;
STATUS:= W#16#8282;
y_state:= B#16#0;
ELSIF (RDREC.STATUS AND DW#16#F000) <> DW#16#C000 THEN
ERROR:= TRUE;
STATUS:= W#16#8280;
y_state:= B#16#0;
END_IF;
ELSIF NOT RDREC.BUSY THEN
STATUS:= r_record.r3964err;
y_state:= B#16#0;
ERROR:= TRUE;
ELSE
STATUS:= W#16#7002;
END_IF;
ELSE
STATUS:=W#16#7000;
END_IF;
 
IF ERROR THEN
OK := false;
END_IF;
 
END_FUNCTION_BLOCK



ptp

Block checksum , ,
, .
.
, .





PtP communication instructions from PtP Communication (zip, 56Kb)

Manual (zip, 1.3Mb)

Original link support.industry.siemens







: 2925

:     : 2016-09-13

! .

:     : 2016-11-26

, FB613 (Send_P2P)V1.2 ,
FB614 (Receive_P2P)V1.1 SCL

:     : 2017-02-17

. ET200MP 1200/1500. FB619 (Set_Features) CRC Modbus .

:

(4000 max):

: