D
3--
04
A
D
4-
C
ha
nn
el
A
na
lo
g
In
pu
t
2--17
D3--04AD 4-Channel Analog Input
This example program shows how you can use the instructions to load the equation
constants into data registers. The example is written for channel 1, but you can
easily use a similar approach to use different scales for all channels if required.
You may just use the appropriate constants in the instructions dedicated for each
channel, but this method allows easier modifications. For example, you could easily
use an operator interface or a programming device to change the constants if they
are stored in Registers.
374
This rung loads the data into the accumulator on
every scan. (You could use any permissive contact.)
The DL305 CPUs perform math operations in
BCD. Since we will perform math on the data, the
data must be converted from binary data to BCD.
DSTR1
R001
F51
Read the data
BCD
F86
110
Store channel 1
374
DSTR
K256
F50
DOUT
R430
F60
DSTR
K1000
F50
DOUT
R432
F60
On the first scan, these first two instructions load
the analog resolution (constant of 256) into R430
and R431.
These two instructions load the high limit of the
Engineering unit scale (constant of 1000) into
R432 and R433. Note, if you have different scales
for each channel, you’ll also have to enter the
Engineering unit high limit for those as well.
Load the constants
DIV
R430
F74
DSTR
R576
F50
MUL
R432
F73
This instruction moves the decimal portion from the
auxilliary accumulator into the regular accumulator
for further operations.
The analog value is divided by the resolution of the
module, stored in R430.
DSTR
R576
F50
DOUT
R400
F60
The accumulator is multiplied by the scaling factor,
stored in R432.
This instruction moves most significant digits (now
stored in the auxilliary accumulator) into the
regular accumulator for further operations.
The scaled value is stored in R400 and R401 for
further use.