Skip to main content
Submitted by abhikaushik1 on Thu, 01/14/2016 - 02:39

Dear sir,
I am trying to run a servo motor with following set of commands using gclib. Can you please suggest me what is error in this code.
I am using DMC 4040.

#include <iostream>
#include <gclibo.h>
#include <gclib.h>
#include <conio.h>
#include <string>
#include <iomanip>

using namespace std;

int main(int argc, char * argv[])
{

GCon g=0;

int gcommand(GCon g);

cout << "Revision report, ^R^V\n";
GCmd(g, "DP 0"); //define A position zero
GCmd(g, "SP 4000"); //set up speed
GCmd(g, "AC 1280000"); //acceleration
GCmd(g, "DC 1280000"); //deceleration
GCmd(g, "PR 8000"); //Postion Relative.
GCmd(g, "SH A"); //Servo Here
cout << "Beginning independent motion... ";
GCmd(g, "BG A"); //Begin motion

_getch();
return 0;

}

Thanks

Abhishek kaushik

Comments 1

troym_galil on 01/14/2016 - 08:29

Hello,
Are you using internal or external amplifiers?
Are you connected to the controller over Ethernet or RS232?
What compiler are you using?

I suggest you start with the x_simple.c example located on your PC. Follow the documentation example here and pick your compiler:
http://www.galil.com/sw/pub/all/doc/gclib/html/ccpp.html

Try modifying this example to establish communication with the controller before issuing motion commands. You are missing some key pieces such as you do not have a GOpen() call in your program and you are not checking your return codes.