Siemens S7 series PLC Conversion between integer and BCD

Conversion Instructions ACCU 1 data type conversion, the conversion still result in accumulator l. Switching operation can be realized are: Conversion BCD and integer and long integer between real and long integer between numbers negated negation, byte expansion.
In STEP 7, the integer and long integer expressed as a complement form. BCD code values, there are two: one is word (16-bit) number in BCD format, the values range from -999 to +999; the other is double the number of BCD code word (32-bit) format, ranging from 9999999 to +9999999.

 BTI instruction
   
SLT format: BTI
    
Description: ACCU 1 in BCD code number 3 is converted to 16-bit integer, into low word of accumulator 1 (0 to 11); the most significant bit (15) low word is the sign bit.
          
Accumulator high word of accumulator 1 and 2 of the same content.Example 3.6.1 L MW 10
           
BTI
           
T MW20

      BTD instructionSLT format: BTD
    
Description: The accumulator 1 7 BCD code number is converted to 32-bit integer, into accumulator 1 (0 to 27); the most significant bit (31) is the sign bit.l ITB instructionSLT format: ITBDescription: ACCU 1 in the 16-bit integer is converted to 3 BCD code number, 16-bit integer in the range of -999 to +999. If you want to convert the data out of range, an overflow occurs, while the OV and OS bit.Low word of accumulator 1 (0 to 11) stored three-digit BCD code. (12 to 15) bits as a sign bit, (0000) represents a positive number, (1111) represented a negative number. The high word of accumulator 1 (16 to 31) unchanged.Example 3.6.2L MW 10
           
ITB
           
T MW20


       ITD DirectiveSLT format: ITDDescription: l accumulator low word 16-bit integer to 32-bit integer and 16-bit integer in the range of -999 to +999. If you want to convert the data out of range, an overflow occurs, while the OV and OS bit.Low word of accumulator 1 (0 to 11) stored three-digit BCD code. (12 to 15) bits as a sign bit, (0000) represents a positive number, (1111) represented a negative number. The high word of accumulator 1 (16 to 31) unchanged.Example 3.6.3 L MW 10
            
ITB
            
T MW20

      DTB instructionSLT format: DTBDescription: Accumulator 1 32-bit integer is converted to BCD code number 7, 32-bit integer in the range of -9999999 ~ 9999999. If you want to convert the data out of range, an overflow occurs, while the OV and OS bit.Accumulator 1 (0 to 27) stored 7 BCD code. (28 to 31) bits as a sign bit, (0000) represents a positive number, (1111) represented a negative number.Example 3.6.4L MD 10
           
DTB
           
T MD20


      DTR instructionSLT format: DTRDescription: Accumulator 1 32-bit integer to 32-bit floating point (IEEE-FP)Example 3.6.5L MD 10
           
DTR
           
T MD20



Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.