Example 4
Continued
F4–16DA–2 16-Ch. Analog Voltage Output
Use the channel selection value, which is now on the data stack, as an
LDX
offset from V3000 to load the channel data into the accumulator.
V3000
Octal
V
3
0
0
Convert the BCD data to binary. Since the value can never be above
BIN
4095, only the least significant 12 bits of the accumulator are used.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Mask off the upper four bits of the word, just in case the data value is out
ANDD
of range (greater than 4095).
KFFF
Earlier in the program the channel selection portion of the data word
OR
was created and stored in V1501. Now we can OR this location with
V1501
the data word currently in the accumulator to get the final data word
that is ready to send to the analog module.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
V1501
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Set the Output Enable bit, by combining the value of 8000 hex with the
ORD
accumulator value. This sets bit 15 to "1", enabling channels 1 through
K8000
8.
31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16
Acc.
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Send the data stored in the lower half of the accumulator to the analog
OUT
module (the OUT instruction ignores the upper 16 bits of the
V40501
accumulator). The most significant four bits of the analog word contain
the channel selection bits. The remaining 12 bits contain the analog
data. This example uses V40501, but the actual value depends on the
location of the module in your application.
HEX Value in 1st
stack location.
Octal
0
0
1
=
V
3
0
0
1
+
The value in V3001 is
2345, which is slightly
Acc. 0
0
0
0
2
3
4
5
over half scale.
0
0
0
0
2
3
4
5
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1
BCD Value converted to binary now in accumulator.
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1
OR
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
0 0 0 1 1 0 0 1 0 0 1 0 1 0 0 1
Data for Analog Module
15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
1 0 0 1 1 0 0 1 0 0 1 0 1 0 0 1
20–23
Need help?
Do you have a question about the DL405 and is the answer not in the manual?
Questions and answers