LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

vi for 18-48 to 48-18 value flip

Solved!
Go to solution

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.

0 Kudos
Message 1 of 5
(3,015 Views)
Solution
Accepted by topic author Oiver91

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

Message 2 of 5
(2,999 Views)

Hi! Thank you for your answer really much!

 

How can I implement f(x)=-0,3x+48 ? which vi should i use? 

0 Kudos
Message 3 of 5
(2,987 Views)

Thanks i was able to solve it with formula node! Thank you really much again Bob!

0 Kudos
Message 4 of 5
(2,974 Views)

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

0 Kudos
Message 5 of 5
(2,953 Views)