6–14
F4–16AD–1 16-Channel Analog Input
Reading Values,
DL430 CPU
4
4
4
430
440
450
The following program example shows how to read the analog data into V-memory
locations with the DL430 CPU. Since the DL430 does not support the LDF
instruction, you can use the LD instruction instead as shown. The example also
works for DL440 and DL450 CPUs. This example will read one channel per scan, so
it will take eight scans to read all eight channels. Contact SP1 is used in the example
because the inputs are continually being updated.
SP1
LD
V40401
ANDD
KFFF
BCD
LD
V40401
ANDD
KF000
SHFR
K12
OUTX
V3000
Note, this example
uses SP1, which is
always on. You could
also use an X, C, etc.
permissive contact.
Loads the complete channel data word from the module into the
accumulator. The V-memory location depends on the I/O
configuration. See Appendix A for the memory map.
This instruction masks the channel identification bits. Without this,
the values used will not be correct, so do not forget to include it.
Since the DL405 CPUs perform math operations in BCD, it is usually
best to convert the data to BCD immediately. You can leave out this
instruction if your application does not require it (such as for PID
loops, which require the process variable to be in binary format).
This load instruction reads the data into the accumulator again. The
channel data will be pushed into the first level of the stack.
This instruction masks the analog data values and leaves the
channel ID bits in the accumulator.
Now you have to shift the accumulator bits so the channel ID bits will
result in a value between 0 and 15 (binary format). This value is the
offset and indicates which channel is being processed in that scan.
OUTX copies the value from the first level of the accumulator
stack to a source address offset by the value in the accumulator.
In this case it adds the above binary value (0–15) to V3000. The
particular channel data is then stored in its respective location:
For example, if the binary value of the channel select bits is 0,
then channel 1 data is stored in V-memory location V3000
(V3000 + 0) and if the binary value is 6, then the channel 7 data
is stored in location V3006 (V3000 + 6). See the table on page
6–13.
Need help?
Do you have a question about the DL405 and is the answer not in the manual?