LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

activeX event - wait till callback finished

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 

0 Kudos
Message 1 of 15
(4,625 Views)
You forgot the attachment.
Tim
GHSP
0 Kudos
Message 2 of 15
(4,624 Views)

OOPS... 

 

Sorry... I guess this is the signal for an emergency coffee break. Here it is.

 

 

 

0 Kudos
Message 3 of 15
(4,620 Views)
The VI TDC_MoveComplete_callback.vi was not attached. Is this VI just sending the event done event? Could you attach it too?
Tim
GHSP
0 Kudos
Message 4 of 15
(4,618 Views)

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 

0 Kudos
Message 5 of 15
(4,609 Views)
So right Move Completenow when you are running do you get the message "Move Complete" When everthing is done? Is that part working ok?
Tim
GHSP
0 Kudos
Message 6 of 15
(4,606 Views)

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.

Jarrod S.
National Instruments
0 Kudos
Message 7 of 15
(4,605 Views)

@ 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? 

 

 

0 Kudos
Message 8 of 15
(4,600 Views)
If I understand How things work. I have added an event structure that will get you close to waht I believe that you wanted. The call back VI now fires an event that is registered on the mian loop and fire when the move is complete. The MG17 Events is a static event. If you want to add event you just have to open the strict type def and add events. I believe that if I understood what the end program was going to do I might be able to help a little more. I hope this get you started.
Tim
GHSP
0 Kudos
Message 9 of 15
(4,572 Views)

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 

0 Kudos
Message 10 of 15
(4,569 Views)