Skip to main content
Submitted by Matteo on Sat, 02/18/2012 - 01:31

Hi,
I'm using the DMC32 lib with DMC 18x6. Programming with CVI NI.

The problem is that WaitForMotionComplete returns, with no error, immediately during the motion. It happens in homing procedure (HM).
Sometimes instead happen the opposite: WaitForMotionComplete doesn't return, or it returns after 1 or 2 minutes that the motion is completed.

I tried to add a Delay between the BG and the WaitForMotionComplete, but the issue persist.

Comments 7

Galil_MarissaT on 02/21/2012 - 08:39

Hi Matteo:

With programming issues like the one you're seeing there are a few ways to diagnose it. But first, to make sure we're all on the same page, I would recommend sending me a 10-15 line example of how you're using the WaitForMotionComplete.

To my understanding CVI NI is used primarily with ANSI C and Win32--is there any support for COM libraries or C++?

Forward your stuff directly to my e-mail here: marissat at galilmc dot com

Matteo on 02/23/2012 - 10:13

email sent.
;)

sumukh@metaroc… on 06/06/2015 - 17:57

hi
i m trying to write the NI instrument driver to communicate with dmc4040 . can you please share your instrument driver with me?

AndrewS on 06/15/2015 - 09:44

Hi sumukh,
Since this original thread started, we have released a new C library, gclib, which I would recommend for this application. You can find it on our API webpage: http://www.galilmc.com/downloads/api If you would like to discuss this further, please call in or email support@galilmc.com and we would be happy to discuss how best to implement gclib to meet your project requirements.

Regards,
Andrew

abhikaushik1 on 12/30/2015 - 04:37

Dear Sir,
I am using GALIL motion controller DMC 4040 to run two servo motor and I am facing problem while calling WT command using C++. The program which i am running is shown below:

#include <windows.h>
#include <dmccom.h>
long rc;
HANDLEDMC hDmc;
HWND hWnd;
int main(void)
{
// Connect to controller number 1
rc = DMCOpen(1, hWnd, &hDmc);
if (rc == DMCNOERROR)
{
char szBuffer[64];
// Move the X axis 1000 counts
rc = DMCCommand(hDmc, "PR1000;BGX;", szBuffer, sizeof(szBuffer));

// Wait for 4000 milliseconds
rc = DMCCommand(hDmc, "AM;WT3000;", szBuffer, sizeof(szBuffer));

// Move the Y axis 1000 counts
rc = DMCCommand(hDmc, "PR1000;BGY;", szBuffer, sizeof(szBuffer));

// Disconnect from controller number 1 as the last action
rc = DMCClose(hDmc);
}
return 0;

Kindly give some suggestions to use WT command using C++. As WT command is working in properly in DMC Smart Terminal

AndrewS on 01/04/2016 - 08:49

Hi abhikaushik1,
The AM and WT commands are actually not valid in the terminal and that could be your issue. The previous thread referenced WaitForMotionComplete which is not the same as sending down AM or WT. For AM, you can use something similar to WaitForMotionComplete, or you can look at _BGm in a loop and wait for it to complete its motion. For WT, I would recommend using a timer or wait function in C++.

Regards,
Andrew

edprochak on 03/30/2016 - 19:40

I have encountered this error more frequently recently. It may be due to a programming issue on my side but I need to find a clear solution. I am using a DMC-30012-BOX. It drives a servo motor for a bed into and out of a scanner. There are two inputs for foot pedals. This are read and command a jog IN or OUT. The foot pedal inputs are checked in a loop running in thread 2. In thread 0, a command loop is running. It can also receive commands to move the bed IN or OUT. The Command loop checks the command message and runs the selected motion routine in thread 3 (or a STOP command is executed in thread 1). In the simple case the command are sent when an operator presses separate IN or OUT buttons. (Press a button, motion starts, release a button and the stop command is selected.
So the problem is this:

There is a race condition for sure. Pressing the buttons and foot pedals in the right sequence causes the foot pedal motion to hang on the AM command (thread 2). The result is the foot pedals no longer respond. MO=1, TE=-18. and I suspect it is at the AM command

Okay, so I tried a simple change to see if I can recover. I changed the AM to MC with a TW of 500. So the #MCTIME handler should be called and free up thread 2, right? Here is the foot pedal routine with the MC command: Net result, it still hangs.

REM READ AND ACT ON THE FOOT PEDALS
#FOOTPAD
REM no matter what pedals are pressed, if FOOTSAFE is false
REM STOP MOTION!!!
IF (FOOTSAFE=0)
MYMOVFP=0
JS #DOSTOP
ELSE
REM THE FOOT PEDALS ARE ACTIVE LOW (PRESSING THE PEDAL MAKES THE INPUT=0)
CURIN =@IN[2]
CUROUT =@IN[3]
IF (DBGFOOT=1)
MG CURIN, CUROUT,"IN/OUT"
ENDIF
REM IF BOTH FOOT PEDALS ARE PRESSED (CAN'T GO BOTH WAYS 8^)
REM OR BOTH FOOT PEDALS ARE NOT PRESSED (2)
IF ( ((CURIN+CUROUT)=0)|((CURIN+CUROUT)=2) )
REM AND WE WERE MOVING BY FOOT PEDAL
IF ( MYMOVFP = 1 )
REM STOP MOTION
MYMOVFP=0
JS #DOSTOP
MG "FOOTPEDAL STOP"
ENDIF
ELSE
REM HERE WE KNOW WE DON'T HAVE BOTH PEDALS PRESSED.
REM IF IN IS PRESSED (0) AND WE ARE NOT MOVING (0)
REM THEN START THE MOTION
IF ( (CURIN=0)&(MYMOVFP=0) )
SHA
JG -footSpd
MYMOVFP=1
BG
MG "FOOTPEDAL MOVE,IN"
ELSE
REM IF OUT IS PRESSED (0) AND WE ARE NOT MOVING (0)
REM THEN START THE MOTION
IF ( (CUROUT=0)&(MYMOVFP=0) )
SHA
JG footSpd
MYMOVFP=1
BG
MG "FOOTPEDAL MOVE,OUT"
ENDIF;' MOVE OUT
ENDIF;' MOVEIN
ENDIF;' BOTH FOOTPEDALS
ENDIF;'FOOTSAFE=0
EN
REM ==========
#DOSTOP
STA
TW 500
MCA
MO
EN
' ====================
#MCTIME
MG " Motion Complete Timeout,error ",_TC1,",stop code=",_SCA
EN

It still hangs. The purpose for the MC (or the AM) is to be sure the motor stopped before issuing the MO command.
I could not find any example code or forum discussions that cover this issue. I suspect there is an easier way to solve this. OR I will have to put in a loop that checks for motion to stop before I issue the MO command.

Go ahead and explain how I am making a silly mistake. I can take it 8^)
ed