3–24
F4–04AD 4-Channel Analog Input
Optional Method,
DL440/450
5
4
4
430
440
450
Reading Values,
DL430
4
4
4
430
440
450
The previous example used the OUT instruction to store channel data in V memory,
requiring four ladder rungs. The OUTX (Out Indexed) instruction in the next
example does much of that work for you. It uses the first stack location to
temporarily hold the data to be stored at an address modified by an offset in the
accumulator.
SP1
LDF
X20
K12
BCD
LDF
X34
K2
OUTX
V3000
Note: This example
uses SP1, which is
always on. You could
also use an X, C, etc.
permissive contact.
The following program example shows how to read the analog data into V-memory
locations with DL430 CPUs. Since the DL430 does not support the LDF instruction,
you can use the LD instruction instead as shown. You can also use this method with
DL440 and DL450 CPUs.
SP1
LD
V40401
ANDD
KFFF
BCD
LD
V40401
ANDD
K3000
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 first 12 bits of the data word into the accumulator. The X
address depends on the I/O configuration.
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 PID loops).
This LDF instruction loads the two channel indicator bits into the
accumulator. The channel data is pushed onto a stack.
The OUTX (out indexed) instruction stores the channel data,
currently the first item on stack, to an address that starts at V3000
plus the channel offset (0–3) located in the accumulator. For
example, when channel 3 is read, the data is stored in V3002 (V3000
+ 2).
Module Reading
Acc. Bits
Channel 1
00
Channel 2
01
Channel 3
10
Channel 4
11
Loads the complete data word into the accumulator. The V-memory
location depends on the I/O configuration. See Appendix A for the
memory map.
Mask off active channel bits, etc. above the 12 bits of data.
It's usually easier to perform math operations in BCD, so it is best to
convert the data to BCD immediately. You can omit this instruction if
your application does not require it (such as PID loops).
The load instruction reads the data into the accmulator again. This
pushes the channel data onto a stack.
This instruction masks the analog data values, sign bit, and broken
transmitter bit, to leave the active channel bits in the accumulator.
Now you have to shift the active channel bits to the right so the result
has a value from 0 to 3 (inclusive) in binary format.
The OUTX (out indexed) instruction stores the channel data, currently
the first item on stack, to an address that starts at V3000 plus the
channel offset (0–3) located in the accumulator. For example, when
channel 3 is read, the data is stored in V3002 (V3000 + 2).
Module Reading
Acc. Bits
Channel 1
00
Channel 2
01
Channel 3
10
Channel 4
11
Offset
Data Stored in ...
0
V3000
1
V3001
2
V3002
3
V3003
Offset
Data Stored in ...
0
V3000
1
V3001
2
V3002
3
V3003
Need help?
Do you have a question about the DL405 and is the answer not in the manual?
Questions and answers