F
3--
08
T
E
M
P
8C
h.
Te
m
pe
ra
tu
re
In
pu
t
10--11
F3--08TEMP 8-Channel Temperature Input
NOTE:
This example uses
°
C. To use
°
F, simply change the scaling factor and offset
instructions to use the F formula.
S
_
F scale
— Constant of 2276 for scaling factor, constant of 4596 for
offset.
S
_
C scale
— constant of 4096 for scaling factor, constant of 2732 for
offset.
DIV
K4096
F74
This instruction moves the two-byte decimal
portion into the accumulator for further operations.
Scale the data
The analog value is divided by
_
C scaling factor,
which is 4096. (1733 / 4096 = 0.4230)
DSTR
R576
F50
SUB
K2732
F72
1
7
3
3
Accumulator
0
0
0
0
Aux. Accumulator
0
0
0
0
Accumulator
4
2
3
0
Aux. Accumulator
4
2
3
0
Accumulator
4
2
3
0
Aux. Accumulator
Now subtract the
_
K offset from the accumulator.
(The
_
K offset is 2732, which represents 273.2
_
.
4
2
3
0
Accumulator
2
7
3
2
Constant
R577
R576
R577
R576
R577
R576
--
1
4
9
8
Accumulator
DSTR3
R011
F53
Read the data
This rung loads the four data bits into the
accumulator from Register 011 on ever scan.
DOUT1
R501
F61
Temporarily store the bits to Register 501.
DSTR1
R001
F51
This rung loads the eight data bits into the
accumulator from Register 001.
DOUT1
R500
F61
Temporarily store the bits to Register 500. Since
the most significant bits were loaded into 501, now
R500 and R501 contain all twelve bits in order.
DSTR
R500
F50
BCD
F86
Now that all the bits are stored, load all twelve bits
into the accumulator.
Math operations are performed in BCD. This
instruction converts the binary data to BCD. (We’ll
have to use math to convert the value to a
temperature.)
374
374