Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I tell my program to wait for my Velmex driver motor to finish moving, then continue executing?

Hello everyone!

 

I've been working for a couple of days now trying to figure this out. I have a 2 axis stage from Velmex with their proprietary driver which controls two stepper motors, one for each axis. I need to execute an algorithm of commands, such as one I call "Find Y Center". My problem is as follows:

 

Whenever I have a complex chain of commands, the VISA commands execute too quickly for them all to be executed. I need my program to wait for the last command to have finished, THEN send the next command. Right now, my program will send the first command, the motor will begin to move, then the all of the next commands will ber sent and the driver won't read any of them because the first command is still moving the motor. I've included my code here below which shows the part I'm having a problem with, thanks for your help!

0 Kudos
Message 1 of 2
(3,623 Views)

You might try setting the VISA functions to synchronous to allow for more time for data to be transferred, I've linked more information below..

 

If you are asking how to wait until the stage is done moving you have two options that I can think of:

 

1) If the stage responds with some sort of "done" signal then you can use a VISA read with a sufficiently long timeout to wait for this response before proceeding. This would be the best solution but requires the Velmex stage to respond when finished, something I don't know if it can do you'll need to check the manual.

 

2) If the stage doesn't respond when finished you can manually time how long each of these operations take and implement a static wait after you write the VISA command each time.

 

Choosing Between Synchronous and Asynchronous NI-VISA Functions

http://digital.ni.com/public.nsf/allkb/ECCAC3C8B9A2A31186256F0B005EEEF7

Alex W.
0 Kudos
Message 2 of 2
(3,598 Views)