06-04-2016 11:04 AM
Hello, I'm looking for a sollution for my problem. I have a PID, and the output is 0-100%. The servo low position is 48, the high position is 18. I would like tohave a vi which corresponds 0-100% to 48-18 values.
So 0->48 100->18. Im using the PID percentage to EGU, but is doesnt seems towork with low value 48 and high 18.
Or i need a vi which "flips" between 18-48 --> 48-18.
I guess it is an easy task for experienced users.
Solved! Go to Solution.
06-04-2016 11:52 AM
This is a math problem. You want a function f(x) such that f(0) = 48, f(100) = 18.
Let's pick the easiest logical function, a linear relationship, which says f(x) can be written as f(x) = mx + b. Let's substitute in the two end conditions, and see if we can determine m and b.
f(0) = m*0 + b = 48, b = 48
f(100) = 100 m + b = 18, 100 m + 48 = 18, 100 m = -30, m = -0.3
So it looks like f(x) = -0.3x + 48 should work, that is, if we put in 0, we should get 48, and if we put in 100, we should get 18.
Let's try it with 0, 50, and 100.
f(0) = 48 (that was easy, and "correct")
f(50) = -15+48 = 33 (OK, we didn't know that before)
f(100) = -30 + 48 = 18 (also "correct").
So does f(50) make sense? 50 is halfway between 0 and 100, and 33 is halfway between 48 and 18, so maybe it does.
Now, write a LabVIEW sub-VI that takes in x (which should be between 0 and 100 -- you might want to think about adding some code to deal with numbers outside this range, either by throwing an error, "coercing" the values to this range, or whatever else you think is appropriate) and outputing the Servo position.
Bob Schor
06-04-2016 12:23 PM
Hi! Thank you for your answer really much!
How can I implement f(x)=-0,3x+48 ? which vi should i use?
06-04-2016 12:46 PM
Thanks i was able to solve it with formula node! Thank you really much again Bob!
06-04-2016 01:25 PM
You don't need a formula node. Just use the ADD and the MULTIPLY primitives.
I would recommend looking at the online LabVIEW tutorials
LabVIEW Introduction Course - Three Hours
LabVIEW Introduction Course - Six Hours