70
DMM Technology Corp.
DYN4 AC Servo Drive Instruction Manual
REV. ZM7-A10A
CT1
void DlgRun::Make_CRC_Send(unsigned char Plength,unsigned char B[8])
{
unsigned char Error_Check = 0;
for(int i=0;i<Plength-1;i++)
{
OutputBuffer[OutBfTopPointer] = B[i];
OutBfTop+;
Error= B[i];
}
Error_Check = Error_Check|0x80;
OutputBuffer[OutBfTopPointer] = Error_Check;
OutBfTop+;
while(OutBfBtmPointer != OutBfTopPointer)
{
RS232_HardwareShiftRegister = OutputBuffer[OutBfBtmPointer];
SendRS232Port();
// Include customer code to send to RS232 port
OutBfBtm+;
// Change to next byte in OutputBuffer to send
}
}
void DlgRun::ReadMotorTorqueCurrent(void)
{/*Below are the codes for reading the motor torque current */
//Read
motor torque current
char ID = 0;
//Suppose read 0 axis motor
Global_Func = General_Read;
Send_Package(ID , Is_TrqCurrent);
//Function code is General_Read, but one byte data is : Is_TrqCurrent
//Then the drive will return a packet, Function code is Is_TrqCurrent
//and the data is 16bits Motor torque current.
MotorTorqueCurrentReady_Flag = 0xff;
While(MotorTorqueCurrentReady_Flag != 0x00)
ReadPackage();
//MotorTorqueCurrentReady_Flag is cleared inside ReadPackage() or inside
//Get_Function() exactly after the MotorTorqueCurrent is updated.
}
C++ Code for Serial Communication - Page 4
7.9A Appendix : C++ Code for Serial Communication Protocol