Delta DVP — 6.6 XCH - Exchanging the Upper and Lower 8 bits in a Register

6. Data Transmission and Comparison Design Examples 6.6 XCH - Exchanging the Upper and Lower 8 bits in a Register Control Purpose: z Exchanging the data NB(Nibble)0 with NB1, NB2 with NB3 in a register every 1 sec. The data length of D register is Word (16 bits), and a Word is made up of 4 Nibbles. NB1 NB2 NB3 NB0 b14 b13 B12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 D0=H5678 (Before exchange) H6 H5 H7 H8 NB1 NB2 NB3 NB0 b14 b13 B12 b11 b10 b9 b8 b7 b6 b5 b4 b3 b2 b1 b0 D0=H6587 (After exchange) H8 H5 H6 H7 Devices: Control Program: M1002 T0 T0 Program Description: z First, the program will store the 16 bits ( 4 Nibbles) data in D0 to Y0~Y17.

After 1 sec, the NO contact T0 will be activated to execute XCHP instruction. The data in K1Y0 will be exchanged with K1Y4 and so will K1Y10 with K1Y14. Then, these data will be sent to D0. Finally, The data exchange between NB0/NB1 and NB2/NB3 is completed. 6-8 DVP-PLC Application Examples Device Function T0 1 sec timer. Time base: 100ms D0 Data register Y0~Y17 Storing 4 nibbles MOV H5678 D0 MOV D0 K4Y0 TMR T0 K10 XCHP K1Y0 K1Y4 XCHP K1Y10 K1Y14 MOVP K4Y0 D0