9 Application Instructions API 150-199 Program Example 5: 1. Sending the function code K5(H05) through COM2 (RS-485): Write status of single bit device. In the example below, Set K1 to bit On, K0 to bit Off. M1002 Set up communication protocol to 9600,8,E,1 Retain communication protocol Set up communication time-out: 100ms M10 M1143 Set up RTU mode M0 Set up sending request M0 M0 Address of communi- cation device K1 Function code K15: sets single point On/Off Data address: H0500 PLC device: Y0 Set On M0 Set Off M1127 ASCII mode: RTU mode: The received data are stored in special registers D1070 ~ D1076 in ASCII format.
The received data are stored in special registers D1070 ~ D1077 in hex format. Sending/receiving of data is completed. The flag is reset. 2. ASCII Mode: When PLC1 is connected to PLC2 When M0 = On, function code 05 (bit On) of MODRW instruction will start to be executed. PLC1 PLC2, PLC1 sends: “ 01 05 0500 FF00 F6 ” PLC2 PLC1, PLC1 receives: “ 01 05 0500 FF00 F6 ” Registers for PLC1 sent data (sending messages): DVP-PLC Application Manual 9-13 MOV H87 D1120 SET M1120 MOV K100 D1129 SET M1122 MODRW K1 K5 H0500 D0 K1 MODRW K1 K5 H0500 D0 K0 Process of received data 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 ‘5’ 35 H D1258 low ‘0’ 30 H Starting data address D1258 high ‘5’ 35 H D1259 low ‘0’ 30 H D1259 high ‘0’ 30 H