06-22-2023 01:51 PM
I'm relatively new to LabVIEW and have been tasked with creating what I call a multipoint limiter. This function creates a curve where the value of Y is limited based on the value of X. I'm performing real-time motion control. In my applications, X is always speed and Y is position. The faster you go, the tighter the limits get.
In C++ I use 7 element arrays for X and Y. Read the values X and Y, determine the proper X array index, using that index select the proper Y limit value, and limit the value of Y if necessary. Some logic is included to indicate if my Y limits are unipolar or bipolar.
Reading some other posts, I see the In Range and Coerce function discussed. I also read the In Range and Coerce lower and upper limit values can be arrays.
Does this sound like the correct direction to head in, or is there something better?
06-22-2023 03:23 PM
it Looks like you're going on the right direction
06-22-2023 03:31 PM
Thanks for the reply.
As I read the Help file for the In Range and Coerce function, it implies that x, lower limit, and upper limit should be the same type. Like you showed all three as arrays in your diagram.
Does the input to x have to be an array?
06-22-2023 05:16 PM
@stgislander wrote:
Thanks for the reply.
As I read the Help file for the In Range and Coerce function, it implies that x, lower limit, and upper limit should be the same type. Like you showed all three as arrays in your diagram.
Does the input to x have to be an array?
That's the only thing that makes sense.
06-22-2023 05:31 PM
No, it can be a number.
I'm not sure if you can mix arrays and numbers, if that's what you;r planning to do.
06-22-2023 05:39 PM
@paul_a_cardinale wrote:
@stgislander wrote:
Thanks for the reply.
As I read the Help file for the In Range and Coerce function, it implies that x, lower limit, and upper limit should be the same type. Like you showed all three as arrays in your diagram.
Does the input to x have to be an array?
That's the only thing that makes sense.
Oops. I misread what @stgislander wrote. I thought he was asking about the 'output'.
06-23-2023 07:13 AM
Thanks.
If I reading the Help files correctly, I think I can use the Index Array function to get the particular limit value I need from the first array. I can wire that to the upper limit input on the In Range and Coerce function. (The lower limit will be either 0 or the negative of the upper limit.) That way all inputs are numbers.
If that is right, then my next step is to determine the correct index value based on a comparison of the X value and a second array.
06-23-2023 07:17 AM
Hi stgislander,
@stgislander wrote:
Thanks.
If I reading the Help files correctly, I think I can use the Index Array function to get the particular limit value I need from the first array. I can wire that to the upper limit input on the In Range and Coerce function. (The lower limit will be either 0 or the negative of the upper limit.) That way all inputs are numbers.
If that is right, then my next step is to determine the correct index value based on a comparison of the X value and a second array.
You better look at the help for the Interpolate1DArray/Threshold1DArray functions…
(They also work with array of points!)
06-23-2023 07:48 AM
If I understand this right, you are only looking at one Y value at any given time, but you know the X at that point. Why not just use a simple formula to calculate upper and lower limits for that x?
I am sure you can come up with a simple formula for UpperLimit(x) and LowerLimit(x) to be wired to the InRangeCoerce function. Wrap it all into a subVI.
06-23-2023 08:01 AM
Well every application is different. We don't know what the relationship between speed and position is until after trials testing. In C++, we approximate the curve from a look-up "table" method using arrays. Trials reveals what the limit points need to be at various speed points. This method is easy to understand, easily adjustable, very fast, and accurate enough.