B 1 Appendix B Analog I/O

B 1 Appendix B Analog I/O
Appendix B
Analog I/O
Scaling Examples
Ċ Analog Input Module
Ċ Analog Output Module
1B
B–2
Terminator Analog I/O
Appendix B
Analog I/O
Analog Input Module
Scaling the
Input Data
Most applications usually require
measurements in engineering units,
which provide more meaningful data.
This is accomplished by using the
conversion formula shown.
You may have to make adjustments to
the formula depending on the scale you
choose for the engineering units.
Units + A H * L
8191
H = high limit of the Engineering
unit range
L = low limit of the Engineering
unit range
A = Analog value (0 – 8191)
For example, if you wanted to measure pressure (PSI) from 0.0 to 99.9 then you
would have to multiply the analog value by 10 in order to imply a decimal place when
you view the value with the programming software or a handheld programmer. Notice
how the calculations differ when you use the multiplier.
Analog Value of 4047, slightly less than half scale of 8191, should yield 49.4 PSI
Example without multiplier
Units + A H * L
8191
Example 1:
Scaling 4–20mA
Input Signal
Example with multiplier
Units + 10 A H * L
8191
Units + 4047 100 * 0
8191
Units + 40470 100 * 0
8191
Units + 49
Units + 494
Here’s how you would write the program to perform the engineering unit
conversion for a 4 – 20mA input signal. This example uses SP1 which is always
on. You could also use an X, C, etc. permissive contact.
SP1
LD
V3000
When C0 is on, channel 1 data is loaded into the accumulator.
BCD
Converts the binary analog data to BCD to perform math
operations. Omit this instruction if binary data is to be used
for binary math operations.
SUB
K1638
Subtracts 1638 from the incoming signal to adjust the 4mA offset.
MUL
K1000
Multiplies the accumulator data by 1000 (to start the conversion).
DIV
K6553
Divides the accumulator data by 6553. (8191 – 1638)
OUT
V2500
Stores the result in location V2500.
Terminator Analog I/O
Here’s how you would write the program to perform the engineering unit
conversion for a 0–5V, 0–10V, $5, $10, 0–20mA or $20mA input signal.
The example assumes the analog data is in V3000.
This rung executes if the channel data is positive
Use SP1, C or X
bits for unipolar
inputs
V3000 K2000
<
LD
V3000
Channel 1 data is loaded into the accumulator.
BCD
Converts the binary analog data to BCD to perform math
operations. Omit this instruction if binary data is to be used
for binary math operations.
MUL
K1000
Multiplies the accumulator data by 1000 (to start the conversion).
DIV
K8191
OUT
V2500
Divides the accumulator data by 8191. Divide by 4095 for
0–5V or $5V input signal ranges.
Stores the result in location V2500.
This rung executes if the channel data is negative. It can be
omitted for unipolar inputs.
V3000 K2000
>
–
LD
V3000
Channel 1 data is loaded into the accumulator.
INV
The INV and ADDB instructions convert the incoming
2’s complement analog data into binary
ADDB
K1
ANDD
K1FFF
Masks the channel sign bit
BCD
Converts the binary analog data to BCD to perform math
operations. Omit this instruction if binary data is to be used
for binary math operations.
MUL
K1000
Multiplies the accumulator data by 1000 (to start the conversion).
DIV
K8191
OUT
V2500
C0
OUT
Divides the accumulator data by 8191. Divide by 4095 for
0–5V or $5V input signal ranges.
Stores the result in location V2500.
C0 is ON when the input signal is negative
Appendix B
Analog I/O
Example 2:
Scaling Unipolar
and Bipolar
Input Signals
B–3
B–4
Terminator Analog I/O
Appendix B
Analog I/O
Analog Output Module
Calculating the
Digital Value
Your program has to calculate the
digital value to send to the analog
module. There are many ways to do
this, but most applications are
understood more easily if you use
measurements in engineering units.
This is accomplished by using the
conversion formula shown.
You may have to make adjustments
to the formula depending on the
scale you choose for the engineering
units.
A + U 4095
H*L
A = Analog value (0 – 4095)
U = Engineering units
H = High limit of the engineering
unit range
L = Low limit of the engineering
unit range
Consider the following example which controls pressure from 0.0 to 99.9 PSI. By
using the formula you can easily determine the digital value that should be sent to
the module. The example shows the conversion required to yield 49.4 PSI. Notice
the formula uses a multiplier of 10. This is because the decimal portion of 49.4
cannot be loaded, so you must adjust the formula to compensate for it.
A + 10U
Engineering Unit
Conversion
4095
10(H * L)
A + 494
4095
1000 * 0
A + 2023
The following example program shows how you would write the program to perform
the engineering unit conversion to output data formats 0–4095. This example
assumes you have calculated or loaded the engineering unit values in BCD format
and stored it in V2300. It is usually easier to perform any math calculations in BCD
and then convert the value to binary before you send the data to the module.
SP1
LD
V2300
The LD instruction loads the engineering units used with channel 1 into
the accumulator. This example assumes the numbers are BCD. Since
SP1 is used, this rung automatically executes on every scan. You could
also use an X, C, etc. permissive contact.
MUL
K4095
Multiply the accumulator by 4095 (to start the conversion).
DIV
K1000
Divide the accumulator by 1000 (because we used a multiplier of
10, we have to use 1000 instead of 100).
BIN
Convert the data to binary format before sending it to the module
OUT
V3100
Send the binary data to channel 1 of the module
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement