3. Instruction Set Program Example 7: COM2(RS-485), Function Code H06 1. Function code K6 (H06): Write in single word device. 2. Set the value to be written into VFD-B in the register specified by operand S . 3. For ASCII or RTU mode, PLC COM2 stores the data to be sent in D1256~D1295, and received data in D1070~D1085. 4. Take the connection between PLC (PLC COM2) and VFD-B for example, the tables below explains the status when PLC reads status of VFD-B.
(M1143 = OFF, ASCII Mode) (M1143 = ON, RTU Mode) M1002 Set communication protocol as 9600, 8, E, 1 Retain communication protocol Set communication timeout as 100ms M1143 = OFF ASCII mode M1143 = ON RTU mode X0 X0 Sending request Data length Data storing register D50=H1770 Data address: H2000 Function code K6 write in single data Receiving completed Connection device address: K1 M1127 Processing received data ASCII mode: The received data is stored in D1070~D1085 in ASCII format RTU mode: The received data is stored in D1070~D1085 in Hex format Reset M1127 ASCII mode (M1143 = OFF) When X0 = ON, MODRW instruction executes the function specified by Function Code 06 PLC VFD-B, PLC sends:
“01 06 2000 1770 52” VFD-B PLC, PLC receives: “01 06 2000 1770 52” Registers for data to be sent (sending messages) 3-379 MOV H87 D1120 SET M1120 MOV K100 D1129 RST M1143 SET M1143 SET M1122 MODRW K1 K6 H2000 D50 K1 RST M1127 Register Data Descriptions D1256 Low byte ‘0’ 30 H ADR 1 ADR 0 Device address of VFD-B: ADR (1,0) D1256 High byte ‘1’ 31 H D1257 Low byte ‘0’ 30 H CMD 1 CMD 0 Control parameter: CMD (1,0) D1257 High byte ‘6’ 36 H D1258 Low byte ‘2’ 32 H Data Address D1258 High byte ‘0’ 30 H D1259 Low byte ‘0’ 30 H