LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linear Curve Fitting

A very flexible way of timing your code is by using a Functional Global Variable which monitors the clock of your operating system. You will first reset it and then you can measure the elapsed time.

Have a look at the attached VI on how you can implement it. Note that the error wires force the execution flow. This example counts the elapsed time between starting and stopping the VI.

KostasB

NI UK

 

 

 

 

 



Message Edited by KostasB on 03-04-2008 11:34 AM

Message Edited by KostasB on 03-04-2008 11:35 AM
Download All
0 Kudos
Message 11 of 42
(1,333 Views)
KostasB,

That is very nice. If good dataflow such as error handling is available in a piece of code this can be more flexible than the three frame sequence which is often used.

Lynn
0 Kudos
Message 12 of 42
(1,328 Views)
KostasB
 
I am trying to do what you said in order to measure the time, but because I am not very expert in Labview I could not Smiley Sad. I have attached my code that I need to measure the time,
Could you have a look at it see if you can do it.
 
Thanks
0 Kudos
Message 13 of 42
(1,304 Views)

Hi

There is a problem associated with using count time function, we cannot convert millisecond timer value to a real-world time or date.

Can you have a look at the code, when I run it,  it shows that it takes 7996339 to complete, does it make sense to you?

0 Kudos
Message 14 of 42
(1,302 Views)
My problem is that I do not know how to wire the case structure to while loop. Is the returned measured time , real-world time? Is is ms?
0 Kudos
Message 15 of 42
(1,300 Views)


Maryam hosseini wrote:
 but because I am not very expert in Labview I could not Smiley Sad. I have attached my code that I need to measure the time,
Could you have a look at it see if you can do it.

OK, first we need to know more details. Does the code constantly need to read new data? You are currently initialize your device, read x and y, and close the device over and over again. If you just want to read the data once, this belongs outside the loop. If you want to read new data with each iteration, you initialize once outside the loop, read inside the loop, and close at the conclusion of the program as in the attached modification. Any such toplevel loop should have a small wait statement, so other code has a better chance to use the CPU too once in a while.
 
You'll also see how to measure the time needed for the fitting.
 
Here's a quick draft with corrections. You still need to hook up a stop button etc. (currently it only stops if there is an error in the IO)
 
Modify as needed. The code is NOT finished! I cannot test, because I don't have your hardware or IO subVIs.
0 Kudos
Message 16 of 42
(1,297 Views)


Maryam hosseini wrote:
There is a problem associated with using count time function, we cannot convert millisecond timer value to a real-world time or date.
The millisecond timer is just an U32 that increments 1000 units/second. The only useful way to use it for your purpose is to look at the difference between two readings. To measure the total loop time, you could just always subtract the reading from the previous call via a shift register or feedback node. Here's a quick draft:
 
 
(NOTE: The first iteration will be off, so you should initialize the feedback node outside the loop with another ms timer value) .


Message Edited by altenbach on 03-05-2008 12:20 PM
0 Kudos
Message 17 of 42
(1,293 Views)

The code constantly need to read new time, I do not really need to use while loop because I need to read each set of data once,

I need to measure the time of the whole of the code, I mean the time that it takes the code to read data, and fit it to the model.

This one is measuring only the time of the fitting, isn’t it?

Is the returned value for the time real world value? Let's say if it says 2512 ms does it really mean it take 2512 ms to do the fitting?

0 Kudos
Message 18 of 42
(1,290 Views)
If I want to measure the time that the whole code takes to complete, instead of just the fitting funtion is it the correct way of doing it? (I have attached the code)
0 Kudos
Message 19 of 42
(1,280 Views)

Sorry I forgot to attach. This time it is attached.

Thanks

0 Kudos
Message 20 of 42
(1,279 Views)