Chapter 6 Applied Instructions 6.3.2 Explanation of Data Conversion Instructions Symbol: S : Source device Word/Double word D : Conversion result Word/Double word Explanation: 1. The binary value in S is converted into the binary-coded decimal value, and the conversion result is stored in D . 2. Only the instruction DBCD can use the 32-bit counter. 3. The four fundamental operations of arithmetic in the PLC, the instruction INC, and the instruction DEC all involve binary numbers. To show the decimal value on the display, users can use the instruction BCD to convert the binary value into the binary-coded decimal value Example: 1.
When X0.0 is ON, the binary value in D10 is converted into the binary-code decimal value, and the conversion result is stored in D100. 2. If D10=16#04D2=1234, the conversion result will be that D100=16#1234. Additional remark: 1. If the conversion result exceeds the range between 0 and 9,999, the instruction BCD is not executed, SM0 is ON, and the error code in SR0 is 16#200D (The binary-coded decimal value is represented by the hexadecimal value, but one of digits is not within the range between 0 and 9.). 2.
If the conversion result exceeds the range between 0 and 99,999,999, the instruction DBCD is not executed, SM0 is ON, and the error code in SR0 is 16#200D (The binary-coded decimal value is represented by the hexadecimal value, but one of digits is not within the range between 0 and 9.). 6-75 API Instruction code Operand Function 0200 D BCD P S, D Converting the binary number into the binary-coded decimal number Device X Y M S T C HC D L SM SR E PR K 16# “$” DF S D Pulse instruction 16-bit instruction (5 steps) 32-bit instruction (5 steps) AH500 AH500 AH500