Appendix C
Sample Programs
119
Program Example
The following program can be executed only with the C200HS, C200HX/HG/HE CPU Units.
•
Data Flow (Unit Number 0):
Word 101 (AD Conversion Value)
→
Words 201 and 202 (Conversion Results)
ANDW(34)
#8000
DM0000
DM0002
25506(=)
25503((ERR)
MOV(21)
101
DM0000
MOV(21)
#0000
DM0001
NEG
DM0000
DM0000
MOV(21)
#F000
DM0001
BCD(24)
DM0000
DM0000
XFER(70)
#0002
DM0000
200
Execution condition
16-bit binary data
Clears leftmost word to 0000
Reverses leftmost bit if it is not 0.
Reverses leftmost word to
F000 if it is not 0.
Converts to BCD.
Outputs BCD data with sign to
words 200 and 201.
(1)
(2)
(3)
1, 2, 3...
1. If the leftmost bit is a 1 (negative number) in 16-bit binary data, the data is
reversed.
2. 16-bit binary data is converted to BCD.
3. BCD data with sign is output to words 200 and 201.
Sample Program 7: Square Root Calculation
Data expressed as quadratic curves, such as thermocouple inputs, is converted and output to linear data (0000 to
4400).
Unit Settings
Item
Setting contents
Actual settings
Unit
C200H-AD003
---
Unit number
#0
Unit number switch: 0
Operation mode
Normal mode
Back-panel DIP switch: All OFF
Input 1 used
---
DM 1000 = 0001
Input signal range
Input number 1, 0 to 10 V
DM 1001 = 0001