63
DYN2MS-02F-0116A17
void main(void)
{
/* (1) Move motor 2 to absolute position of 321,456 - Method 1*/
char Axis_Num = 2;
Global_Func = (char)Go_Absolute_Pos;
long pos = 321456;
Send_Package(Axis_Num,Pos);
/* (2) Move motor 2 to absolute position of 321,456 - Method 2 - Using subroutine function*/
MoveMotorToAbsolutePosition32(2,321456);
/* (3) Code for reading the motor shaft 32bits absolute position - Method 1
This method uses a while delay to wait for Send_Package() function to complete
*/
int i;
InBfTopPointer = InBfBtmPointer = 0;
//reset input buffer pointers
OutBfTopPointer = OutBfBtmPointer = 0;
//reset output buffer pointers
for(i=0;i<8;i++)
Read_Package_Buffer[i] = 0;
Read_Num = Read_Package_Length = 0;
//Reading motor 32bits position
char ID = 0; //Suppose read 0 axis motor
Global_Func = General_Read;
Send_Package(ID , Is_AbsPos32);
while(i<10000)
//10~20ms waiting
{
i++;
}
ReadPackage();
//Motor absolute position stored in Motor_Pos32 variable
/* (4) Reading the motor shaft 32bits absolute position - Method 2 using subroutine function*/
ReadMotorPosition32();
//Motor absolute position stored in Motor_Pos32 variable
/* (5) Reading the motor current using subroutine function*/
ReadMotorTorqueCurrent(); //Motor torque current stored in MotorTorqueCurrent variable
/* (6) Reading the main gain of 8th axis servo drive using subroutine function*/
ReadMainGain(8);
//Main Gain stored in MainGain_Read variable
}
C++ Code for Serial Communication - Page 6
7.9A Appendix : C++ Code for Serial Communication Protocol