10-06-2009 09:01 AM
Hello,
I am using a Thorlabs motor, which has an ActiveX control. My program moves the motor a fixed amount every time, and an event is fired every time the move is finished. It is registered by the RegisterEventCallback function (attached is an example). The callback function should do some calculation, etc...
The question is - can I make the loop wait till the callback function FINISHES operation before it executes again? If it can be done, how? I'm completely new to event handling, so almost any info will be helpful. (I have searched LabView help and the discussion boards in vain...)
Thanks in advance,
Michal
10-06-2009 09:03 AM
10-06-2009 09:10 AM
OOPS...
Sorry... I guess this is the signal for an emergency coffee break. Here it is.
10-06-2009 09:13 AM
10-06-2009 09:23 AM
The callback function does nothing so far. In the future I want to make it read a voltage value from another device and save the value in an array. This would also require it returning the array somehow... but I'll deal with it later.
(What is the "event done" event and can I use it somehow to indicate that the callback function has finished execution?)
Thanks a lot,
Michal
10-06-2009 09:26 AM
10-06-2009 09:27 AM
One way to do this is to send a queue, notifier or user event reference to your Callback VI. You do this by wiring the reference into the User Parameter input of the Register Events function. Then regenerate a new Callback VI and you'll see it supplies you with that wired reference as an input. Have your Callback VI put an element on the queue, or fire a notification or User Event.
Finally, have your main loop wait on this queue, notifier, or User Event before continuing.
It's a little roundabout, but this is definitely the best way to go once you wrap your head around it.
Search the forums and online help for info about queues and so on if you need it.
10-06-2009 09:38 AM
@ aeastet -
Yes, it's working ok, it just fires every time the loop runs.
@ Jarrod S -
thanks, I'll see if I understood correctly what you meant (after some digging into info about queues and user events... ).
Another thing - there is no real need for using a callback VI - actually, I'd rather do without it - but then how do I ensure that MoveAbsolute has completed action WITHOUT waiting for the MoveComplete event to fire? Is wiring the error to the next function (what I usually do) sufficient?
10-06-2009 10:20 AM
10-06-2009 10:34 AM
Ok... I got lost. I think I am missing something very basic, and the documentation is not helping.
If I create a user event in the main vi, I can wire it to the User Parameter of the Register Events Callback. Is that what you meant?
If so, then I don't understand how it's recognized by the callback vi and when does the callback vi fire the event - should I put a Generate Event inside it? Because if I do, then its output should also be wired...
In short, I could really use a bit more detailed explanation.... if it's not too much trouble...
Thanks,
Michal