LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do use a timer to run a motor based on a variable?

Solved!
Go to solution
Solution
Accepted by Royjays

You are not understanding the wait function and shift registers. The output of the wait function is the same as a 32bit counter and only differences between two readings will give you a relative time in ms (same as tick count). You wire the output into the shift register and use it as wait on the next iteration, which will cause it to wait anywhere from zero to 2^32ms, e.g. almost forever.

I already linked to a simple example, so study that. It uses the high resolution timer. (Again, only relative differences are useful, but  opposed to tick count, the units are seconds and the type is DBL). The wait should be independent and just determine the loop rate with a constant wired to the input..

 

A scalar shift register does not "move" anything to anywhere, it refers to one memory location that gets updated as needed. In LabVIEW, "the wire is the variable" (simplified).

 

Saving a file for previous will not change any default values. It is possible that you did not make the current values default before saving.

 

Message 11 of 16
(274 Views)

I think I am beginning to understand but I still dont have it quite right.

Please see my updated program with the timer added and i have removed the external hardware IO so that I can simulate and run the program.

 

The temperature check and FIS states seem to be ok.

 

I tried using a case structure like what you had in your example but the elapsed time just flickers. I tried it connected to a select function and it did start counting up but the state didn't change when the value matched the duration value. What am i doing wrong here?

 

Also, is the elapsed time the time since the vi begins running or when that state is made active? I would like the latter but think it may be the other way round. The states change too quickly for me to be able to tell. 

 

I feel like I am slowly getting there! 

0 Kudos
Message 12 of 16
(258 Views)
Solution
Accepted by Royjays

In the false case, you need to wire the old relative across. Else you constantly update the time reference and the difference will never exceed the loop time.

 

altenbach_0-1725634427295.png

 

Message 13 of 16
(243 Views)
Solution
Accepted by Royjays

Thanks. 

My timer is now counting up and returns to zero when it meets the duration time but the state is not incrementing. Have I missed something?

0 Kudos
Message 14 of 16
(234 Views)

Apologies, it is changing state. It was just going too quick for me to notice.

0 Kudos
Message 15 of 16
(226 Views)

Thank you for all your help, my program is working great now. I couldn't have done it without your advice, It's really appreciated.  

0 Kudos
Message 16 of 16
(188 Views)