12. Communication Design Examples M0 Read the target value and the present value of the TC and store them in D1073~D1076 M1 M2 Set target value as 26 ℃ Set output mode of alarm 1 as the 1st alarm type M3 Set upper/lower limit of temperature range M4 Set the upper/lower limit of alarm 1 M1127 C0 counts once when data receiving is completed. Reset M1127 M1129 C0 counts once when communication timeout occurs. Reset M1129 M1140 C0 counts once when data receiving errors occurs. Reset M1140 M1141 C0 counts once when parameter error occurs. Program Description: z Initialize PLC RS-485 communication port and set the communication format as MODBUS RTU, 9800, 8, N, 2.
The RS-485 communication format of TC should be the same with PLC.. z There are only 4 situations for MODBUS communication: flag M1127 for normal communication and M1129, M1140, M1141 for communication errors. Counter C0 counts once when any of the 4 flags is ON. Therefore, the program assures the communication reliability by monitoring the On/Off status of the 4 flags and performs 5 MODBUS instructions in order by the value in counter C0. z Since DTB series TC supports the function code 10H, the program uses MODRW instruction to write multiple words. z Once PLC starts running, the read/write actions for TC will be performed repeatedly according to [LD=] instructions.
DVP-PLC Application Examples 12-27 MODRD K1 H1000 K2 MODWR K1 H1001 K260 MODWR K1 H1020 K1 MODRW K1 K16 H1002 D0 K2 MODRW K1 K16 H1024 D2 K2 CNT C0 K10 RST M1127 CNT C0 K10 RST M1129 CNT C0 K10 RST M1140 CNT C0 K10 RST M1141