LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using timed loops

I need to run a motor for a specific length of time, typically 5 +/- .1 second.  I am currently trying to do that with a event structure but have found out it is not very accurate (I know Windows is not deterministic).  

Would a timed loop better meet my needs?  

 

I have considered using hardware timing - I am using a Measurement Computing USB-1208FS-Plus which has a SYNC pin, and I have a request in to them for help using it.  If anyone has any experience with that hardware and using the SYNC pin, please give me some advice. 

 

My programming computer is a i7 processor, but I will be exporting is as an application to a touch screen with a slower processor, which I expect to cause additional problems.  I imagine the computer change will also affect the timed loop. 

 




metzler CLAD
0 Kudos
Message 1 of 5
(2,300 Views)

@metzler wrote:

I need to run a motor for a specific length of time, typically 5 +/- .1 second.  I am currently trying to do that with a event structure but have found out it is not very accurate (I know Windows is not deterministic).  

 


An event structure is primarily for dealing with user interactions, not for any timing. It is not clear to me what you are actually doing here. Can you show us some code?

0 Kudos
Message 2 of 5
(2,245 Views)

You're right about windows not being deterministic, but that's not going to impact how accurately it can count to 5 seconds. A windows PC will be able to do that very easily, precisely, and repeatably across an i7, i3, or any processor. 

 

The part that will be slow is the API call to turn the motor on or off. What protocol is being used to talk to the motor? How long does it take from when you send a command to when the device receives it and acts on it? These are the things that should be considered and optimized. 

Nathan Murphy
Message 3 of 5
(2,184 Views)

How important is not overshooting the time to you?

 

If it just ruins the test and you need to rerun it, that's not very important.

 

But if running it too long can destroy equipment or crush body parts, that is important.

 

If it's not very important, just use Windows OS timing and call it good enough.  If it is important, get some dedicated hardware with a real-time OS, and use a timed loop.

0 Kudos
Message 4 of 5
(2,166 Views)

@metzler wrote:

I need to run a motor for a specific length of time, typically 5 +/- .1 second. 


These specifications are not clear at all! Does the "5.0±0.1" mean that a uncertainly range of 0.2 seconds is acceptable or do you need a very exact timing around 5 second (e.g. first 4.9±0.0001, later 5.1±0.0001, etc.).

Is the ±0.1  a flat range or based on a Gaussian distributed standard deviation?

 

How do you communicate with the motor? Just a control voltage? Some serial command string to an external motor controller? What's the hardware delay (e.g. if that motor has a 5 ton flywheel, it might not react as fast as you want!)? What is acceptable jitter? Are both bounds equally important?

 

A X±0.1s control precision should be easily achievable, even on a slow computer running windows. (Probably even on an arduino!) so obviously you are doing something wrong. Can you show us some code and more details on the hardware setup?

0 Kudos
Message 5 of 5
(2,146 Views)