LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Question about timeSetEvent

    Hi James_McN

    I do a test vi with multiple ms function as you said,refer to the attachment.

    The time will chang and the maxvalue is much larger than the set vulue of multiple ms(20ms) when I do some other events,such as open word,click mouse,even keydown.

So I think the multiple ms function can not meet the requirements(I want to keep the time is fixed , without obvious changes at least.for example ,if I set the time is 20ms,the change range is 19ms-21ms.)

Download All
0 Kudos
Message 11 of 30
(1,666 Views)

@fjczd wrote:

    Thank you @Bublina for illustrated explanation.

    I can understand the concept,but how to do ? LVPostEvent is not open for user, I have no idea about how “call the timeSetEvent”. Do other languages,such VB VC, to achieve callback functional in winmm.dll,LabVIEW CAN NOT to do?


You CANNOT write a callback function in LabVIEW that can be called by a DLL.  As Bublina explained, you need to create an additional DLL (in C, or some other language that can return a function pointer).  That DLL should contain the callback function and a function that will return a pointer to the callback function.  It could also contain a function to allow you to set a reference to a LabVIEW user event, or you could pass that to the callback as user data if the call allows it.

 

Then, in your LabVIEW code, create a user event reference.  Get the address for the callback function, and pass that address to timeSetEvent.  Pass the event reference to the callback as user data, or use a function in the DLL to set it.  When the callback is called, it will generate the user event in LabVIEW, which you can then handle.

0 Kudos
Message 12 of 30
(1,647 Views)

    Thank you nathand,and Happy New Year.

    It seems that the underlying operating (such as operating dll), the LabVIEW has its limitations.After converted by VC and other languages ,maybe the run stability will be compromised. Is there LabVIEW itself function or vi achieve this function?

0 Kudos
Message 13 of 30
(1,635 Views)

@fjczd wrote:

    Thank you @nathand,and Happy New Year.

    It seems that the underlying operating (such as operating dll), the LabVIEW has its limitations.After converted by VC and other languages ,maybe the run stability will be compromised. Is there LabVIEW itself function or vi achieve this function?


Happy New Year to you as well.

 

In my opinion the best solution for you is to use a timed loop with a 1khz rate.  Each timed loop is assigned its own thread so the code inside it should be mostly isolated from other operations; however, since Windows is not a real-time operating system, there will be some jitter.

 

There is no way to use setTimeEvent in pure LabVIEW, and even with an added DLL to handle the callback it is unlikely that the timing will be perfect.

0 Kudos
Message 14 of 30
(1,628 Views)

Hi,

 

I expect this may suffer the same issue anyway. The term for the difference from the desired loop rate is jitter. On windows thiAlan be quite large because it is a general purpose OS. We can't guarantee that it services our application as a priority instead other items (graphics, virus scanner etc) as you've seen can cause spikes in jitter. I think this is likely to be the same with any method but the timed loops is an easy thing to try and see if there is any difference. 

 

The question is what does your application actually require? If these is key to what you are doing we have real time operating systems that have much smaller jitter, or is this something where the timing can be handled in hardware such as data acquisition on a DAQ card. 

James Mc
========
CLA and cRIO Fanatic
My writings on LabVIEW Development are at devs.wiresmithtech.com
0 Kudos
Message 15 of 30
(1,619 Views)

To 

    As you said, with a timed loop, there is jitterIndeed.Under Windows XP, timed loop in the role of jitter reduction is not really obvious.

    In our project ,the requirement of jitter is not larger than 1ms.So it seems that I have to use the LabVIEW RT module.

0 Kudos
Message 16 of 30
(1,607 Views)

    To 

    As you said, with a timed loop, there is jitterIndeed.Under Windows XP, timed loop in the role of jitter reduction is not really obvious.

    In our project ,the requirement of jitter is not larger than 1ms.So it seems that I have to use the LabVIEW RT module.

0 Kudos
Message 17 of 30
(1,602 Views)

    To James_McN

    Under Windows XP, timed loop in the role of jitter reduction is not really obvious than loop.

    But in LabVIEW RT, how about the jitter?If seltct 1MHz in loop timed source, how much about the jitter range? I guess the gitter will be larger than 1us, Does It has a range determined?

0 Kudos
Message 18 of 30
(1,598 Views)

fjczd,

 

You should state what are You trying to acomplish, so people will get a better scope and can give You some more specific hints.

 

As to your measurements of the ms precision in windows XP; You should realize, that all the timing precision depends on the operating system load, since we have multitasking in the round robin manner.

You can have the ms resolution / precision in windows XP, but it would be hard to keep in applications that use a lot of CPU.

 

Since some LV version 2K10 or so there is a high precision relative time VI you can use in windows.

 

C:\Program Files\National Instruments\LabVIEW 2011\vi.lib\Utility\High Resolution Relative Seconds.vi

 

 

0 Kudos
Message 19 of 30
(1,571 Views)

Bublina

      In our project ,the requirement of jitter is not larger than 1ms and the loop time is 50ms. That is, the range of ioop time is from 49ms to 51ms.During the loop time, the program will finish sample dada from instrument and calculate and data store.

    Other language, such VC/VB, which can meet the requirements with “timeSetEvent” (which in winmm.dll) in Windows XP. After previous discussion, we find LabVIEW can not use “timeSetEvent”,because it need callback.

    But I guess maybe LabVIEW will have other way to meet the requirement in Windows XP.I think other language can do ,LabVIEW can do also.

0 Kudos
Message 20 of 30
(1,555 Views)