void DlgRun::ReadMotorPosition32(void)
{/*Below are the codes for reading the motor shaft 32bits absolute position */
//Read motor 32bits position
char ID = 0; //Suppose read 0 axis motor
Global_Func = General_Read;
Send_Package(ID , Is_AbsPos32);
// Function code is General_Read, but one byte data is : Is_AbsPos32
// Then the drive will return a packet, Function code is Is_AbsPos32
// and the data is 28bits motor position32.
MotorPosition32Ready_Flag = 0xff;
While(MotorPosition32Ready_Flag != 0x00)
ReadPackage();
// MotorPosition32Ready_Flag is cleared inside ReadPackage() or inside
// Get_Function() exactly after the Motor_Pos32 is updated.
}
void MoveMotorToAbsolutePosition32(char MotorID,long Pos32)
{
char Axis_Num = MotorID;
Global_Func = (char)Go_Absolute_Pos;
Send_Package(Axis_Num,Pos32);
}
void ReadMainGain(char MotorID)
{
char Axis_Num = MotorID;
Global_Func = (char)Read_MainGain;
Send_Package(Axis_Num, Is_MainGain);
MainGainRead_Flag = 0xff;
while(MainGainRead_Flag != 0x00)
{
ReadPackage();
}
}
C++ Code for Serial Communication - Page 5
7.9A Appendix : C++ Code for Serial Communication Protocol