Mitsubishi — Chapter 8 Application Instructions API 100-149

9 Application Instructions API 150-199 Program Example 1: 1. Sending the function code K2 (H02) through COM2 (RS-485): Read many bit devices. The read communication code will be placed in the register designated by the 4 th operand of the instruction. In the example below, K6 refers to the data length (bit). Assume Y2=Y4=Y5=Y11=Y14=On for Y0 ~ Y16 status. Set up communication protocol to 9600,8,E,1 M1002 Retain communication protocol Set up communication time-out: 100ms X10 M1143 Set up RTU mode X0 Set up sending request X0 Address of communi- cation device K1 Function code K2: reads many bit data Data address: H0500 PLC device:

Y0 Data register Read/write data length (word) M1127 Process of received data ASCII mode: The received data are stored in special registers starting from D0 in ASCII format. PLC will automatically convert the data into hex and store them in D1296 ~ D1311. RTU mode: The received data are stored in special registers starting from D0 designated by the user in hex format. Sending/receiving of data is completed. The flag is reset. 2. ASCII Mode: When PLC1 is connected to PLC2 When X0 = On, function code 02 of MODRW instrruction will start to be executed. PLC1  PLC2, PLC1 sends: “ 01 02 0500 0010 E8 ” PLC2  PLC1, PLC1 receives:

“ 01 02 02 34 12 B5 ” Registers for PLC1 sent data (sending messages) DVP-PLC Application Manual 9-4 MOV H87 D1120 SET M1120 MOV K100 D1129 SET M1122 MODRW K1 K2 H0500 D0 K6 RST M1127 Register DATA Explanation D1256 Low ‘0’ 30 H ADR 1 ADR 0 Address of connected device: ADR (1,0) D1256 High ‘1’ 31 H D1257 Low ‘0’ 30 H CMD 1 CMD 0 Command code: CMD (1,0) D1257 High ‘2’ 32 H D1258 Low ‘0’ 30 H Starting Data Address D1258 High ‘5’ 35 H D1259 Low ‘0’ 30 H D1259 High ‘0’ 30 H D1260 Low ‘0’ 30 H Number of Data (counted by bits) D1260 High ‘0’ 30 H D1261 Low ‘1’ 31 H D1261 High ‘0’ 30 H D1262 Low ‘E’ 45 H LRC CHK 1 Error checksum: LRC CHK (0,1) D1262 High ‘8’ 38 H LRC CHK 0