Chapter 8 Logic Instructions
8-253
8.14.3.6 RS485 Free Protocol Example
Programming Example 1
Enabling the function of the start and end of messages
The free protocol is applied to send a standard Modbus message in ASCll mode with the starting
address %MB4000 where sent data are stored and %MB5000 where received data are stored and
receive the response data from the slave.
Message content: 01 10 15 00 00 01 02 00 08.
The checksum CF is calculated first. Then the message is converted into ASCll code.
Message content after conversion: 30 31 31 30 31 35 30 30 30 30 30 31 30 32 30 30 30 38 43 46.
If the parameters of RS485_RS instruction are configured based on variable table 1, the data in
%MB4000~%MB4019 are 30 31 31 30 31 35 30 30 30 30 30 31 30 32 30 30 30 38 43 46.
The message data on the bus: 3A 30 31 31 30 31 35 30 30 30 30 30 31 30 32 30 30 30 38 43 46 0D
0A.
Variable table 1
Variable name Address Data type Initial value
RS RS485_RS
RS_Ex BOOL FALSE
RS_Abort BOOL FALSE
RS_CyRun BOOL TRUE
RS_SBA %MB4000 USINT 16#30
RS_SL UINT 20
RS_RBA %MB5000 USINT
RS_RL UINT 23
RS_AddSE BOOL 1
RS_Tout UINT 500
RS_Done BOOL
RS_Bsy BOOL
RS_Abt BOOL
RS_Act
RS_NCyc BOOL
RS_Rec BOOL
RS_RTO BOOL
RS_RLOM BOOL
RS_RAL UINT
RS_Err BOOL
RS_ErrID WORD
Disabling the function of the start and end of messages
1. The free protocol is applied to send a standard Modbus message in ASCll mode with the
starting address %MB4000 where sent data are stored and %MB5000 where received data
are stored and receive the response data from the slave.