04-19-2017 10:35 AM
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
04-19-2017 10:43 AM - edited 04-19-2017 10:49 AM
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:
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.....
04-19-2017 10:52 AM
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.
04-19-2017 12:52 PM - edited 04-19-2017 02:25 PM
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:
04-19-2017 07:38 PM
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
04-19-2017 07:42 PM
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
04-19-2017 09:00 PM
Do it hardware timed.
Have you looked if there are stepper motor drivers available already?
04-20-2017 12:05 PM
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
04-20-2017 07:06 PM
i am using drv8825 and it requires a clock signal or square wave
04-20-2017 07:10 PM
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