LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timer problems

Hi,

 

I need to add in a scheduling/timer function to my vi and this is what i came up with. It works quite well, but there is a small problem. If i use both the start and stop function, the vi starts and stops exactly at the specified time. However, if i only use the stop function while starting the vi manually, the vi sometimes exceeds the specified time by 1 second. I'm guessing this is due to the labview "get date/time" getting the micro seconds as well. Is there any way to solve this? 

0 Kudos
Message 1 of 6
(2,897 Views)

Your VI does not make a lot of sense.

 

Everything without data dependency will run in parallel, so most likely, the loop will spin about once per second, determined by the time delay express VI.

 

The entire logic of the case structure, boolean "set starting time", and wait function takes either 0 or 1000 ms, and is thus completely irrelevant, because the loop time is entirely determined by the other time delay. The setting of the "time to start" and "set start time" does nothing useful and never makes a difference. You could even delete them, without any change in functionality of the VI.

 

 


@J.R wrote:

If i use both the start and stop function, the vi starts and stops exactly at the specified time. However, if i only use the stop function while starting the vi manually, the vi sometimes exceeds the specified time by 1 second. I'm guessing this is due to the labview "get date/time" getting the micro seconds as well. Is there any way to solve this? 


 

Can you explain once more how you are operating this VI? What is "manually"?

 

Your code checks the time roughly every second. This means the time can be up to 1 second off, depending on the how the loop iterates with respect to the actual time.

 

Can you explain in a few more sentences what the VI is supposed to do?

 

0 Kudos
Message 2 of 6
(2,893 Views)

This is actually something i want to add on to another vi which reads data from sensors. I would like to be able to set what time the vi starts and stops collecting data. When i mentioned manually, it meant hitting the run button to start the vi, after which i set the stopping time and switching on the boolean. Attached is the vi which i have been running, if you would like to take a look.

 

The problem is that the vi sometimes does not stop collecting data exactly at the specified time, but 1 second later. It is actually not a major problem as i can always delete the last data from the database, but it might be troublesome if i need to do it frequently.

0 Kudos
Message 3 of 6
(2,890 Views)

Your VI still makes no sense. (also, all the subVIs are missing)


@J.R wrote:

 When i mentioned manually, it meant hitting the run button to start the vi, after which i set the stopping time and switching on the boolean.


I don't see how the order of operations has anything to do with how the VI functions: If you run the VI, It will automatically be exipred, but will not stop because "set stopping time" is still false. That seems very clumsy.

 

As I said, you loop resolution is 1 second, so of the comparison occurs a X.99second or X.001 seconds, the loop will, or will not, spin another time. Nothing is predictable, because we don't really know how long the inner loop takes to complete. Form the timeout settings, it could be up to 10 seconds.

 

Your programming logic is a real mess and a lot of things are way too complicated. I would recommend to start over from scratch, after doing some tutorials.

 

For example your inner FOR loops are not needed at all, just cast the raw U16 array to a SGL array. Same difference. The two code segments shown in the image below produce exactly the same output for input arrays with an even number of elements and one is much simpler!. Why are you going to dynamic data and back, just to form some arrays? That's painful!

 

 

0 Kudos
Message 4 of 6
(2,883 Views)

The device stores 32-bit data in 2 consecutive 16-bit registers. The for loop is to read the 2 16-bit registers and output the actual value. I'm a student working on a project and i am not someone who has years of programming knowledge. Programming is not even my field of study. I am sorry for the mess, but thanks for your help anyway, i'll try to solve it again. 

0 Kudos
Message 5 of 6
(2,878 Views)

 

 

No problem. You will learn a lot here. We all started out as beginners. 😉

 

Feel free to post here again for feedback if you have an improved version or ask if you need advice.

 

Good luck!

 

 


@J.R wrote:

The device stores 32-bit data in 2 consecutive 16-bit registers. The for loop is to read the 2 16-bit registers and output the actual value.


Yes, simply typecast it to a SGL array as I showed. You can do it with an atomic operation instead of a FOR loop and complicated code. 🙂

 

0 Kudos
Message 6 of 6
(2,851 Views)