9 Application Instructions API 150-199 Program Example 9: 1. Sending the function code K15 (H0F) through COM2 (RS-485): Write many bit devices. The preset bit status has to be placed in the register designated by the 4 th operand of the instruction in b0 ~ b15 order. 1 word is able to contain 16 bit status data. M1002 Set up communication protocol to 9600,8,E,1 Retain communication protocol Set up communication time-out: 100ms X10 M1143 Set up RTU mode X0 Set up sending request Set up status value to be written into device X0 Address of communi- cation device K1 Function code K15: writes 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 desiganted 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 0F of MODRW instruction will start to be executed. PLC1 PLC2, PLC sends: “ 1 0F 0500 0006 01 3F A5 ” PLC2 PLC1, PLC receives:
“ 1 0F 0500 0006 E5 ” Registers for PLC1 sent data (sending messages): DVP-PLC Application Manual 9-21 MOV H87 D1120 SET M1120 MOV K100 D1129 SET M1122 MOV HFFFF D0 MODRW K1 K15 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 ‘F’ 46 H D1258 low ‘0’ 30 H 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 ‘0’ 30H D1261 high ‘6’ 36 H D1262 low ‘0’ 30 H Byte Count D1262 high ‘1’ 31 H