LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to round with decimals in labview?

First of all thank you.

 

I have already apply the same transformation to the inputs. And i'ts working.

The second will start when the first one is finished.

The outer while loop has no purpose, sure, it's for next step.

The code of the case structures will change, it was just to make it work right now without the controller.

 

Do you know if there is any code to use with this controller? is the final purpose of this proyect.

http://search.newport.com/?x2=sku&q2=AG-UC2

 

Thanks again for your answers

0 Kudos
Message 31 of 41
(2,969 Views)

Chapter 4.7 of the manual shows the command set.  http://assets.newport.com/webDocuments-EN/images/29942.pdf

 

It should be easy enough to communicate with knowing that information.

0 Kudos
Message 32 of 41
(2,954 Views)

this works.....

just convert the number to string there is a vi named NUMBER TO DECIMAL STRING then convert the string back to decimal using STRING TO DECIMAL NUMBER.......WORKS GREAT AND EASY........

0 Kudos
Message 33 of 41
(2,732 Views)

I need help for the same problem, shall you send to me the labview file that you have done to resolve this problem? Thanks!!

0 Kudos
Message 34 of 41
(2,159 Views)

Hi mb,

 

which of the solutions in this old thread does not work for you?

And who are you asking when you write "shall you send me"?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 35 of 41
(2,156 Views)

I have a aileron with a linear potentiometer linked to its shaft. My goal is to move the aileron in the potition that I want. I want to insert a value of position, compare it with the value that come from the potentiometer and then If they are the same the aileron motor has to stop, instead if they are not the same the motor has to move the aileron to that position.

 

I want to compare the value that I choose with the value that the potentiometer is reading. But I have the same problem with the rounding with decimal number and I don't know how to move the aileron in the position that I have choosen.

 

0 Kudos
Message 36 of 41
(2,154 Views)

Hi mb,

 

But I have the same problem with the rounding with decimal number

The problem is not the rounding…

 

If they are the same

You should not compare for "the same", but for "within limits"!

If "current postion" is within "target position ± limit" then the target is reached…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 37 of 41
(2,151 Views)

Frist of all thank you so much!! 

How can I do a "within limits" in labview?

0 Kudos
Message 38 of 41
(2,149 Views)

Hi mb,

 

some simple pseudocode:

IF (current-position > target-limit) AND (current-pos < target+limit) THEN stop motor

 

You can simplify this using the InRangeAndCoerce function…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 39 of 41
(2,145 Views)

Greetings!  This was something that I always struggled with to.  A really cool way to go about doing this without adding a ton of code is to use the number to fractional string, set the precision to however far you want to round, then use the fractional string to number to change it back to a double.  I attached an example for you to review if you are more of a visual person.

 

NGH6425_0-1653762445398.png

 

0 Kudos
Message 40 of 41
(1,121 Views)