CRV_INTERP_Y (id, x, [options])
CRV_INTERP_V (id, x, [options])
CRV_INTERP_A (id, x, [options])
Interpolates the curve with the specified id at the given value of x, and returns the Y value, velocity (V), or acceleration (A) at that point in the curve.
Parameters
Id(DINT)
The curve identification number.
X(REAL)
The x value of the specified curve.
Options(DINT)
Optional parameter. Defines the behavior of the function when x is beyond the endpoints of the specified curve. The following options exist, similar to the Endpoint Behavior Options of the Curve Start Advanced (88) command:
Option |
Description |
Image |
0: Fault (default) |
If x is beyond the endpoints of the curve, a runtime error will occur, and the task will stop running. |
|
4: Truncated |
If x is beyond the endpoints of the curve, the curve holds it position at each endpoint: CRV_INTERP_Y will return the Y value of the closest endpoint of the curve. CRV_INTERP_V will return zero. CRV_INTERP_A will return zero. |
|
8: Extrapolated |
Ifxis beyond the endpoints of the curve, the curve will be extrapolated linearly, and that value returned: CRV_INTERP_Y will return the extrapolated Y value. The curve will be extrapolated linearly, using the velocity of the curve at the closest endpoint of the curve. CRV_INTERP_V will return the velocity of the closest endpoint of the curve. CRV_INTERP_A will return zero. |
|
Returns
The interpolated Y, velocity, or acceleration value of the specified curve at the given value of x. The returned data type is REAL.
Remarks
These functions can be used for purposes such as:
Gain Scheduling
If the application requires different tuning gains based on some value, such as position, a curve can be created that defines the gain based on that value. A simple user program can then use the CRV_INTERP_Y interpolation function to continuously apply the gain. See Gain Scheduling for details.
Run a curve on a velocity axis
Velocity axes do not currently support curves directly. To run a curve on a velocity axis, first create a curve where the y values represent velocity. Make a simple user program that uses the CRV_INTERP_Y function to continuously update a variable. The user program should then gear the velocity axis to that variable with the Gear Velocity command.
If the specified curve Id does not exist or the Options value is invalid, the task will fault. The task will also fault if Options is zero and the X value is not within the range of x-values of the curve. When the task faults, an error will be logged in the Event Log and the user program running on the task will stop. Use the CRV_EXISTS function to programmatically check if the curve id exists.
The CRV_FIRST_X, CRV_LAST_X, AND CRV_EXISTS functions are useful in conjunction with the curve interpolation functions.
Examples
MyReal := CRV_INTERP_Y(3, 5.67, 8);
See Also
Gain Scheduling | CRV_FIRST_X | CRV_LAST_X | CRV_EXISTS | Standard Functions
Copyright © 2024 Delta Computer Systems, Inc. dba Delta Motion