4-18
Math Instructions
Publication 1747-RM001G-EN-P - November 2008
Application Example 2 - Scaling an Analog Input to Control an
Analog Output
32,764 10V
(Scaled MAX.)
Scaled Value
0 0V
(Scaled MIN.)
3,277 4 mA
(Input MIN.)
Calculating the Linear Relationship
Use the following equations to calculate the scaled units.
Scaled value = (Input Value X Rate) + Offset
Rate = (Scaled MAX. - Scaled MIN.) / (Input MAX. - Input MIN.)
(32,764 - 0) / (16,384 - 3277) = 2.4997 (or 24,997/10000)
Offset = Scaled MIN. - (Input MIN. x rate)
0 - (3277 x 2.4997) = - 8192
The above offset and rate values are correct for the SCL instruction. However,
if the input exceeds 13,107, the instruction overflows and sets S:5/0 math
overflow bit. For example:
17 mA = 13,926 x 2.2997 = 34,810 (actual overflow)
34,810 - 8192 = 26,618
To avoid an overflow, we recommend shifting the linear relationship along the
input value axis and reduce the values.
16,384 20 mA
(Input MAX.)
Input Value