11-07-2014 09:34 AM
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
11-07-2014 12:41 PM
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?
11-09-2014 04:15 PM
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
11-09-2014 04:39 PM
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
11-09-2014 04:44 PM
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.
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?
11-09-2014 05:09 PM
11-09-2014 08:07 PM
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
11-09-2014 09:55 PM - edited 11-09-2014 09:56 PM
Wow. Kudo'd that.
11-10-2014 03:45 AM
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
11-10-2014 04:46 AM
with the inputs coming in still an output of 1.67x10^6 being produced, seen by the red arrow