コード例 #1
0
int TestPtToPtMotionShort()
{

//	NMCSERVO Servo;
	int iModules;
	int iError;
	long lPosition;
	double XPos,YPos,ZPos;
	double CmXPos,CmdYPos,CmdZPos;
	double dCmdXSpeed,dCmdYSpeed,dCmdZSpeed;
	double dCmdXAccel,dCmdYAccel,dCmdZAccel;
	double dVelocity;
	double dXHome, dYHome, dZHome;
	byte byAD;

	iModules=g_stage.Initialize("COM4:");

	SetScaling_3Axis();
	SetPIDGain_3Axis();


	g_stage.SetVel(3.0, 3.0, 3.0);
	g_stage.SetAccel(6.0, 6.0, 6.0);

	g_stage.EnableAmp();
	g_stage.ResetPos();
	g_stage.GetHome( dXHome, dYHome, dZHome);

	BOOL bMotion;
	iError=g_stage.MoveRel(0.00, 0.00, 0.15, true);
	iError=g_stage.MoveRel(0.00, 0.00, 0.15, true);
	iError=g_stage.MoveRel(0.00, 0.00, 0.15, true);
	iError=g_stage.MoveRel(0.15, 0.00, 0.00, true);
	iError=g_stage.MoveRel(0.15, 0.00, 0.00, true);
	iError=g_stage.MoveRel(0.15, 0.00, 0.00, true);
	iError=g_stage.MoveRel(0.00, 0.15, 0.00, true);
	iError=g_stage.MoveRel(0.00, 0.15, 0.00, true);
	iError=g_stage.MoveRel(0.00, 0.15, 0.00, true);
	iError=g_stage.MoveTo(1.00, 1.000, 1.000, true);
	g_stage.GetPos(XPos, YPos, ZPos );
	if ( !((XPos < 1.02) && (XPos > 0.98)) && 
		 !((YPos < 1.02) && (YPos > 0.98)) &&
		 !((ZPos < 1.02) && (ZPos > 0.98))   )
		 MessageBox(NULL, "Error with Position","Error Dialog", 1);

	g_stage.GetHome( dXHome, dYHome, dZHome);

	g_stage.GetCmdAccel(dCmdXSpeed, dCmdYSpeed, dCmdZSpeed);
	g_stage.GetCmdAccel(dCmdXAccel, dCmdYAccel, dCmdZAccel );

	iError=g_stage.MoveTo(0.0, 0.0, 0.0, true);

	g_stage.GetPos(XPos, YPos, ZPos );
	if ( !((XPos < 0.02) && (XPos > -0.02)) && 
		 !((YPos < 0.02) && (YPos > -0.02)) &&
		 !((ZPos < 0.02) && (ZPos > -0.02))   )
		 MessageBox(NULL, "Error with Position","Error Dialog", 1);

	iError=g_stage.MoveTo(0.000, 0.000, 0.000, true);
	g_stage.GetPos(XPos, YPos, ZPos );

	g_stage.GetHome( dXHome, dYHome, dZHome);

	return 0;
}	
コード例 #2
0
int TestPtToPtMotionWithStage()
{

//	NMCSERVO Servo;
	int iModules;
	int iError;
	long lPosition;
	double dXPosition,dYPosition,dZPosition;
	double dCmdXPosition,dCmdYPosition,dCmdZPosition;
	double dCmdXSpeed,dCmdYSpeed,dCmdZSpeed;
	double dCmdXAccel,dCmdYAccel,dCmdZAccel;
	double dVelocity;
	double dXHome, dYHome, dZHome;
	byte byAD;

	iModules=g_stage.Initialize("COM4:");

	SetScaling_3Axis();
	SetPIDGain_3Axis();


	g_stage.SetVel(3.0, 3.0, 3.0);
	g_stage.SetAccel(1.0, 1.0, 1.0);

	g_stage.EnableAmp();
	g_stage.ResetPos();
	
	g_stage.GetCmdVel(dCmdXSpeed, dCmdYSpeed, dCmdZSpeed);
	g_stage.GetSpeed(dCmdXSpeed, dCmdYSpeed, dCmdZSpeed);
	g_stage.GetCmdAccel(dCmdXAccel, dCmdYAccel, dCmdZAccel );

	BOOL bMotion;
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );
	iError=g_stage.MoveTo(1.00, 1.000, 1.000, true);
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

	g_stage.GetCmdVel(dCmdXSpeed, dCmdYSpeed, dCmdZSpeed);
	g_stage.GetCmdAccel(dCmdXAccel, dCmdYAccel, dCmdZAccel );

	iError=g_stage.MoveTo(1.201, 1.202, 1.203, true);

	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

	iError=g_stage.MoveTo(0.000, 0.000, 0.000, true);
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

	iError=g_stage.MoveTo(-1.201, -1.202, -1.203, true);
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

	iError=g_stage.MoveTo(-0.500, -0.500, -0.500, true);
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

	iError=g_stage.MoveTo(0.000, 0.000, 0.000, true);
	g_stage.GetPos(dXPosition, dYPosition, dZPosition );

//	iError=Servo.move(-8000,2);
//	do{
//		bMotion=Servo.IsInMotion();
//	}
//	while(bMotion);
	g_stage.GetHome( dXHome, dYHome, dZHome);

	return 0;
}