2-385
2 Instruction Descriptions
NJ-series Instructions Reference Manual (W502)
Conversion Instructions
2
PWLApprox
Line[] must be a two-dimensional or three-dimensional array. Set the number of elements for the first
dimension to 2. Set the number of elements for the second dimension to 2. Set the array elements from
Line[0,0] to X
1
, Y
1
, X
2
, Y
2
, etc., as shown in the following figure.
Always attach the element numbers to the input parameter that is passed to Line[], e.g., array[3,4].
The following example is for when Num is UINT#3, In is INT#3, (X
1
,Y
1
) is (1,5), (X
2
,Y
2
) is (2,6), and
(X
3
,Y
3
) is (4,2).
• If the value of In is smaller than the value of Line[0,0] (i.e., the value of X
1
), then the value of Out will
be the value of Line[0,1] (i.e., the value of Y
1
).
Precautions for Correct Use
X
Y
(X
1,Y1)
(X
2,Y2)
(X
3,Y3)
(X
Num −1,Y Num −1)
(X
Num,Y Num)
X
a
Ya
The instruction will find the Ya
that corresponds to Xa on the
broken line graph.
def:=PWLApprox(INT#3, abc[3,4], UINT#3);
LD ST
def
INT#3
abc[3,4]
UINT#3
PWLApprox
EN ENO
In
Line
Num
In Out = def
X
Y
(1,5)
(2,6)
(4,2)
3
4
Line[0,0]=abc[3,4]
Line[0,1]=abc[3,5]
Line[1,0]=abc[4,4]
Line[1,1]=abc[4,5]
Line[2,0]=abc[5,4]
Line[2,1]=abc[5,5]
1
5
2
6
4
2
UINT#3 4