LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Piecewise non linear function

Greetings, I need to make a VI that linearizes a non linear characteristic (output signal of a sensor) using piecewise method.  I have no idea how to start and what to use. Any help or advice would be appriciated. Thanks. 

0 Kudos
Message 1 of 8
(3,742 Views)

You could use the case structure.  It can accept integers to select and you can setup a case to use ranges.  So what I have done for something similar is multiply the value by 1000 (or however accurate you want your peicewise to be) and cast to an integer.  You can then use that for the case structure.  The rest is just a matter of what math to do in which case.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 8
(3,738 Views)
Hi ponorac,

can you show a typical sensor characteristic? Sometimes a simple lookup table is sufficient...
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 8
(3,721 Views)

Interpolate 1-D array and Threshold 1-D array are useful functions to linearize data piecewise in a lookup table fashion.

0 Kudos
Message 4 of 8
(3,708 Views)

Thanks for the reply guys. Here is what I made (so far). The graph on the right is  a simple characteristic i want to linearize and after the linearization it should display on the left one. In the array I want to set the boundaries which part of the characteristic i need to linearize (for example 0-5, 5-20,20-50)... 

0 Kudos
Message 5 of 8
(3,687 Views)

Just calculate the function at the switch points and use "interpolate array" on the cluster array to get any linearly interpolated value.

0 Kudos
Message 6 of 8
(3,680 Views)

Thanks for the suggestion but It needs to work on any non linear function without me having to calculate the switch points. This is just an expample I made.

0 Kudos
Message 7 of 8
(3,666 Views)

You can't create a piecewise function unless you come up with a way to determine where those pieces exist.  If you don't do it for some arbitrary function, then how do you expect to get it done?

0 Kudos
Message 8 of 8
(3,659 Views)