88
Sample Programs
Appendix B
Converting Data from Signed Binary to Signed BCD
Summary
This program converts binary setting/monitor values from signed binary (4 digits) to signed BCD (8 digits).
• When the most significant bit (leftmost bit) in a word is 1, that word is treated as 2’s complement binary
data.
• With signed BCD, the leftmost digit indicates the sign (0 for +, F for -) and the remaining 7 digits contain the
BCD value.
Example Unit Settings
• Unit:
CJ1W-TC001 Temperature Control Unit
• Unit number:
00 (See note 1.)
• Data format:
16-bit binary (See note 2.)
Note
1.
The unit number switches are on the front of the Unit. Refer to
2-3-3 Unit Number Switches
for details.
2.
Turn ON pin 3 of the DIP switch to select the binary data format.
Example Program
MOV(021)
2003
D00000
MOV(021)
#0000
D00001
ANDW(034)
#8000
D00000
D00002
NEG(060)
D00000
ERR
D00000
MOV(021)
#F000
D00001
BCD(024)
D00000
D00000
XFER(070)
#0002
D00000
0200
=
CIO 2003 (Loop 1 PV)
CIO 0201 (Result) CIO 0201 (Result)
2 words
If the leftmost bit of the binary data
is 1 (negative data), this program
section takes the complement of
the data and writes F000 to the
leftmost result word.
16-bit binary data
Clears the highest
word to 0000.
If the leftmost bit is
1, add 1 and
reverse bit status.
Execution
condition
If the leftmost bit is
1, transfer F000 to
the highest word.
Converts to BCD.
Outputs signed
BCD data to
CIO 0200 and
CIO 0201.
This instruction converts the 16-bit
binary data to BCD.
This instruction outputs the signed
BCD data to CIO 0200 and
CIO 0201.
Summary of Contents for Sysmac CJ Series
Page 1: ...OPERATION MANUAL Cat No W396 E1 03 SYSMAC CJ Series CJ1W TC Temperature Control Units...
Page 2: ...CJ1W TC Temperature Control Units Operation Manual Revised December 2005...
Page 3: ...iv...
Page 5: ...vi...
Page 13: ...xiv...
Page 23: ......
Page 93: ......
Page 105: ......
Page 107: ......
Page 113: ......
Page 115: ......