3. Instruction Set Program Example 1: COM2 RS-485 1. Write the data to be transmitted in advance into registers starting from D100 and set M1122 (Sending request) as ON. 2. When X10 = ON, RS instruction executes and PLC is ready for communication. D100 will then start to send out 10 data continuously. When data sending is over, M1122 will be automatically reset. (DO NOT apply RST M1122 in program). After approximate 1ms, PLC will start to receive 10 data and store the data in 10 consecutive registers starting from D120. 3. When data receiving is completed, M1123 will automatically be ON.
When data processing on the received data is completed, M1123 has to be reset (OFF) and the PLC will be ready for communication again. However, DO NOT continuously execute RST M1123, i.e. it is suggested to connect the RST M1123 instruction after the drive contact M1123. M1002 Set up communication protocol as 9600, 7, E, 1 Retain communication protocol Set up communication time-out as 100ms Pulses for sending request Pulse Write transmitting data in advance Sending request X0 Receiving completed Processing received data M1123 Reset M1123 Program Example 2: COM2 RS-485 Switching between 8-bit mode (M1161 = ON) and 16-bit mode (M1161 = OFF) 8-bit mode: 1.
STX (Start of Text) and ETX (End of text) are set up by M1126 and M1130 together with D1124~D1126. When PLC executed RS instruction, STX and ETX will be sent out automatically. 2. When M1161 = ON, only the low byte (lower 8 bits) is valid for data communication, i.e. high byte will be ignored and low byte will be received and transmitted. M1000 M1161 X0 3-221 MOV H86 D1120 SET M1120 MOV K100 D1129 SET M1122 RS D100 K10 D120 K10 RST M1123 RS D100 K4 D120 K7