From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with INF

Solved!
Go to solution

Hello,

 

I am with a problem regarding the calculation of capacitator reactance (XC=1/WC), i have a problem when my capacitator is 0 ( i can adjust the value with a knob) the display number will be INF, because i am dividing for 0.

 

Is there a way to display 0 when this happens?

When capacitator is 0 i want to display that my XC is also 0 and it keeps displaying INF.

 

Thanks in advance,

 

Montjack

0 Kudos
Message 1 of 9
(4,545 Views)

Just check for zero and conditionally substitute a different code path. Can you show us your code?

0 Kudos
Message 2 of 9
(4,520 Views)

I was able to switch the maximum to display at max 16 bits (32768), even tho it wont display INF, but it will display the 32768, which doesnt solve at all my problem.

 

The problem is that by showing the max number it will affect all my program, that is why i need to fix this issue.

 

Thanks,

 

Montjack

0 Kudos
Message 3 of 9
(4,515 Views)

Hi Montjack,

 

IF divisor == 0 THEN
  result := 0
ELSE
  result := dividend/divisor
ENDIF

Have you tried to implement this simple algorithm in LabVIEW?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(4,505 Views)

You could also just set the input range of the knob such that zero is not allowed.

0 Kudos
Message 5 of 9
(4,498 Views)
Solution
Accepted by Montjack

Hi Montjack,

 

please post your questions here in the forum, using PMs isn't the right way!

Why do you use FXP datatype as shown in your PM?

 

I give you a hint on how to implement the algorithm:

check.png

Btw. to calculate the reciprocal you could find a specialized function called reciprocal😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(4,495 Views)

Thank you for the help, i managed to do it 🙂

WC-Solution.png

0 Kudos
Message 7 of 9
(4,484 Views)

What's the point of the weird output configuration? Just keep it all DBL!

0 Kudos
Message 8 of 9
(4,480 Views)

It was when i was trying different data types 🙂 I will change, Thank you 🙂

0 Kudos
Message 9 of 9
(4,476 Views)