LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

C Problem in VI

first formula node of C there, giving me maxAch (61) of 1666667, and hence, distorting what i want with the rest of the VI, when i want to be 2000000? despise C/C++ etc with a passion!lol

 

In case VI doesnt run, i've attached pics of the probes and data etc. to show

Download All
0 Kudos
Message 1 of 24
(3,239 Views)

Sorry, no idea what you're asking here. Are you asking if your formula is correct, or are you saying that LabVIEW is miscalculating the result, or something else?

0 Kudos
Message 2 of 24
(3,193 Views)

as in the code within the formula node, its producing an output of 1.67x10^6 but i want 2x10^6, i suppose a C forum may be a better place to ask

0 Kudos
Message 3 of 24
(3,132 Views)

Please set the controls to values which illustrate your problem and make those values default before saving and posting the VI. 

 

When I set the controls to:

 

maxFFin = 2E+6

sCLKin = 60000000

ffin = 200000

bit = 18

taq = 3E-7

spec = 200000

 

The results are:

 

sCLKout = 60000000

maxAch = 200000

ffOut = 200000

 

 

If you do not like the formula node syntax, why use it? There does not apper to be anything in there which could not be implemented in a straightforward way with LV primitives.

 

Lynn

 

0 Kudos
Message 4 of 24
(3,118 Views)

Your VI is driven by the controls below but the values you are using when you get your unexpected result did not get posted with your VI/message.  Please let us know. 

 

formula_node2.png

 

Your C code is not particular complex or long and you're not doing anything exotic so this forum is a reasonable choice.

 

A little bit of context may also help here, too.  What is it your code is used for? 

0 Kudos
Message 5 of 24
(3,115 Views)
Where did you copy it from? Ask there.
0 Kudos
Message 6 of 24
(3,104 Views)

One of the itermediate calculations in the left formula node may have roundoff problems. When I duplicated the calculation with LV primitives, I get different results when using single and double precision.

 

inte = sCLKout*((bit/sCLKout)+taq)

 

sCLKout = 6E7

bit = 17

taq = 3E-7

 

inte (DBL) = 35.000000000000007100

inte (SGL) = 35.000000000000000000

 

The ceiling operation gives different results, 36 and 35, respectively.

 

Reconfiguring the calculation as inte = bit + taq*sCLKout has fewer operations and may not be as sensitive to round off errors.

 

 

 

In the while loop the lower shift register produces a result identical to the iteration count. Just wire the "i" terminal to the output.

 

Lynn

Message 7 of 24
(3,085 Views)

Wow. Kudo'd that.

0 Kudos
Message 8 of 24
(3,062 Views)

whenever i lose the line 'inte= etc' i get the output of 2x10^6 with the values of maxFFin, sCLKin, ffin , bit ,taq ,spec . probably just an instance of this working as opposed a long term solution.

 

changing inte to inte = bit + taq*sCLKout; stil gives me 1.67x10^6 output 

0 Kudos
Message 9 of 24
(3,032 Views)

with the inputs coming in still an output of 1.67x10^6 being produced, seen by the red arrow

0 Kudos
Message 10 of 24
(3,020 Views)