LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

1st:I would like to make a delay for microseconds.2nd: measure a loop timing

For the first problem i would like to make a delay for microseconds i tried using wait ms and wait until next ms and i could not do it them i tried using a for loop with N times but i could not measure the delay is there another way .

for the second problem is there a way to measure the execution time of part of the code  

thank you very much 

0 Kudos
Message 1 of 12
(3,793 Views)

There is no option to wait in microseconds on a non-deterministic OS like Windows or (most) Linux. It makes no sense, as the OS jitter is usually in ranges up to multiple ms, so already ms wait is "questionable".

 

You can use timed structures or custom additions to benchmark your code in execution speed. Also VI Profiler might add some info as well as DETT (Desktop Execution Trace Toolkit).

 

EDIT: Please note that every measurement of performance adds overhead to your performance. If your code is already fast, you should implement something like this:

Benchmarktemplate.PNG

Your code would be inside the FOR loop and you would iterate something like 10k-10M times.

Also note that the previously hidden VI "High Resolution Relative Seconds.vi" is nowadays available on the palette to measure sub-ms ranges. But as pointed out: The shorter time you measure, the more relevant is your inherent OS jitter.....

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 12
(3,785 Views)

Depending on your Labview version, there is a High Resolution Relative Seconds vi. Otherwise, in Windows, you have to call the windows API (https://msdn.microsoft.com/en-us/library/windows/desktop/ms644904(v=vs.85).aspx).

 

Doing this, you can ensure two events have at least some time between them (with approximately 1 us resolution), but you can't be sure they don't have more than that, because the operating system isn't a real time OS in most cases. If you want tighter timing, you need to implement it in hardware or get a real time operating system.

0 Kudos
Message 3 of 12
(3,776 Views)

To do microsecond delays, you need LabVIEW RT or FPGA, or do some other hardware based, OS independent timing.

 

To measure the execution time is a code fragment, place it in the middle of a three frame flat sequence. Place high resolution relative seconds in the flanking frames and subtract the two. Be aware that other code running in parallel can bias the results.

 

Here's how I measure the elapsed time for the fitting parts in one of my programs:

 

 

 

 

0 Kudos
Message 4 of 12
(3,742 Views)

thank you very much but i need a microsecond delay in order to operate a stepper motor is it possible ? or how could it be done

0 Kudos
Message 5 of 12
(3,707 Views)

thank you very much . for the other question i want to generate a clock signal as an output to control a stepper motor how can i control its frequency and generate one

0 Kudos
Message 6 of 12
(3,706 Views)

Do it hardware timed.

 

Have you looked if there are stepper motor drivers available already?

0 Kudos
Message 7 of 12
(3,697 Views)

Please give us a more complete big picture for this project.  What are the functional needs for this stepper?  What kinds of motions must it do?  What else must you integrate and coordinate with these motions?  What budget and deadlines do you have?  What's your experience level with LabVIEW?

 

You'll get better targeted help by providing more context with your questions.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 12
(3,682 Views)

i am using drv8825 and it requires a clock signal or square wave 

0 Kudos
Message 9 of 12
(3,672 Views)

well i took core 1 and 2 courses thats my knowledge with labview for the project i am trying to control delta robot but in this step just trying to operate the stepper motor nema 17 using drv8825 which requires a square wave for the step 

0 Kudos
Message 10 of 12
(3,670 Views)