Send characters via CPU or MCU port
This instruction writes data to the send buffer and executes F159_MTRN to send the data. The data to be sent is applied at sString. The send buffer is a VAR_IN_OUT variable applied at SendBuffer. If bSuppressEndCode is set to TRUE, the end code selected in the system registers is not appended to the send string.
In contrast to the instruction SendCharactersAndClearString, the string variable applied at sString remains unchanged.
Input
Specifies the communication ports depending on the PLC type:
COM port e.g. SYS_COM0_PORT
Ethernet port e.g. SYS_ETHERNET_USER_CONNECTION_1
MCU/SCU e.g. 16#xx01 (xx = slot number) in COM01
Stores the send string
The end code selected in the system registers is not appended to the send string.
Input/output
Stores the send string temporarily
When the specified number of bytes has been sent, the "transmission done" flag turns to TRUE. New data may be sent or received. Any send instruction turns the "transmission done" flag to FALSE and no data can be received. Evaluation of the "transmission done" flag may be useful in cases where no response can be expected, e.g. with broadcast messages.
if the MCU unit does not exist in the specified slot or zero bytes should be sent.
if 16#8000 is specified in MEWTOCOL-COM Master/Slave mode
if the MCU unit does not exist in the specified slot or zero bytes should be sent.
if 16#8000 is specified in MEWTOCOL-COM Master/Slave mode
All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.
VAR
bSend: BOOL:=FALSE;
(*activates function*)
sSendData: STRING[30]:='ABCDEFGH';
(*up to 30 chars*)
awSendBuffer: ARRAY [0..15] OF WORD:=[16(0)];
(*for 30 chars + 1 word*)
bSuppressEndCode: BOOL:=FALSE;
END_VAR
If bSend changes from FALSE to TRUE, the instruction sends the characters of sSendData via the MCU port 1. The characters are copied to the array awSendBuffer. awSendBuffer[0] is reserved for the number of characters of the string to send.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 7 ;
NETWORK_BODY
B(B_CONTACT,,bSend,9,1,11,3,R);
B(B_VARIN,,1,11,2,13,4,);
B(B_VARIN,,sSendData,11,3,13,5,);
B(B_VARIN,,awSendBuffer,11,5,13,7,);
B(B_VARIN,,bSuppressEndCode,11,4,13,6,);
B(B_F,E_SendCharacters!,,13,0,24,7,,?DEN?DPort?DsString?DbSuppressEndCode?DSendBuffer?ASendBuffer?AENO);
L(1,2,9,2);
L(11,2,13,2);
L(1,0,1,7);
END_NETWORK_BODY
END_NET_WORK
END_BODY
if (DF(bSend)) then
SendCharacters(Port := 1, sString := sSendData, bSuppressEndCode := bSuppressEndCode, SendBuffer := awSendBuffer);
end_if;