|
|
@ -35,13 +35,13 @@ write_pn 1 617 100 #Pn617 |
|
|
|
write_pn_bit 1 1501 0 0 |
|
|
|
write_pn_bit 1 1501 0 1 |
|
|
|
#endif
|
|
|
|
DO(write_pn(m_deviceId, 610, 0x0001)); |
|
|
|
DO(write_pn(m_deviceId, 615, rpm)); |
|
|
|
DO(write_pn(m_deviceId, 614, topos)); |
|
|
|
DO(write_pn(m_deviceId, 616, acctime)); |
|
|
|
DO(write_pn(m_deviceId, 617, acctime)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 0, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 0, 1)); |
|
|
|
DO(write_pn(610, 0x0001)); |
|
|
|
DO(write_pn(615, rpm)); |
|
|
|
DO(write_pn(614, topos)); |
|
|
|
DO(write_pn(616, acctime)); |
|
|
|
DO(write_pn(617, acctime)); |
|
|
|
DO(write_pn_bit(1501, 0, 0)); |
|
|
|
DO(write_pn_bit(1501, 0, 1)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::move_by(int32_t pos, int32_t rpm, int32_t acctime) { |
|
|
@ -54,13 +54,13 @@ write_pn 1 617 100 #Pn617 |
|
|
|
write_pn_bit 1 1501 0 0 |
|
|
|
write_pn_bit 1 1501 0 1 |
|
|
|
#endif
|
|
|
|
DO(write_pn(m_deviceId, 610, 0x0011)); |
|
|
|
DO(write_pn(m_deviceId, 614, pos)); |
|
|
|
DO(write_pn(m_deviceId, 615, rpm)); |
|
|
|
DO(write_pn(m_deviceId, 616, acctime)); |
|
|
|
DO(write_pn(m_deviceId, 617, acctime)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 0, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 0, 1)); |
|
|
|
DO(write_pn(610, 0x0011)); |
|
|
|
DO(write_pn(614, pos)); |
|
|
|
DO(write_pn(615, rpm)); |
|
|
|
DO(write_pn(616, acctime)); |
|
|
|
DO(write_pn(617, acctime)); |
|
|
|
DO(write_pn_bit(1501, 0, 0)); |
|
|
|
DO(write_pn_bit(1501, 0, 1)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::rotate(int32_t rpm, int32_t acctime) { return move_by(100000 * 10000, rpm, acctime); } |
|
|
@ -77,46 +77,50 @@ write_pn 1 606 0 # |
|
|
|
write_pn_bit 1 1501 1 0 |
|
|
|
write_pn_bit 1 1501 1 1 |
|
|
|
#endif
|
|
|
|
DO(write_pn(m_deviceId, 600, 11)); |
|
|
|
DO(write_pn(m_deviceId, 601, lookzeropoint_rpm)); |
|
|
|
DO(write_pn(m_deviceId, 602, findzero_edge_rpm)); |
|
|
|
DO(write_pn(m_deviceId, 603, lookzeropoint_acc_time)); |
|
|
|
DO(write_pn(m_deviceId, 604, 0)); |
|
|
|
DO(write_pn(m_deviceId, 605, 0)); |
|
|
|
DO(write_pn(m_deviceId, 606, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 1, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 1, 1)); |
|
|
|
DO(write_pn(600, 11)); |
|
|
|
DO(write_pn(601, lookzeropoint_rpm)); |
|
|
|
DO(write_pn(602, findzero_edge_rpm)); |
|
|
|
DO(write_pn(603, lookzeropoint_acc_time)); |
|
|
|
DO(write_pn(604, 0)); |
|
|
|
DO(write_pn(605, 0)); |
|
|
|
DO(write_pn(606, 0)); |
|
|
|
DO(write_pn_bit(1501, 1, 0)); |
|
|
|
DO(write_pn_bit(1501, 1, 1)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::move_to_zero_backward(int32_t lookzeropoint_rpm, int32_t findzero_edge_rpm, int32_t lookzeropoint_acc_time) { |
|
|
|
DO(write_pn(m_deviceId, 600, 8)); |
|
|
|
DO(write_pn(m_deviceId, 601, lookzeropoint_rpm)); |
|
|
|
DO(write_pn(m_deviceId, 602, findzero_edge_rpm)); |
|
|
|
DO(write_pn(m_deviceId, 603, lookzeropoint_acc_time)); |
|
|
|
DO(write_pn(m_deviceId, 604, 0)); // 零点偏移
|
|
|
|
DO(write_pn(m_deviceId, 605, 0)); // 回零动作超时时间
|
|
|
|
DO(write_pn(m_deviceId, 606, 0)); // 回零动作中止使能
|
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 1, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 1, 1)); |
|
|
|
DO(write_pn(600, 8)); |
|
|
|
DO(write_pn(601, lookzeropoint_rpm)); |
|
|
|
DO(write_pn(602, findzero_edge_rpm)); |
|
|
|
DO(write_pn(603, lookzeropoint_acc_time)); |
|
|
|
DO(write_pn(604, 0)); // 零点偏移
|
|
|
|
DO(write_pn(605, 0)); // 回零动作超时时间
|
|
|
|
DO(write_pn(606, 0)); // 回零动作中止使能
|
|
|
|
DO(write_pn_bit(1501, 1, 0)); |
|
|
|
DO(write_pn_bit(1501, 1, 1)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::getpos(int32_t &pos) { |
|
|
|
DO(readreg(m_deviceId, 2036, pos)); |
|
|
|
int32_t Eq20ServoMotor::get_pos(int32_t &pos) { |
|
|
|
DO(readreg(2036, pos)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::enable(int32_t enable) { |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 2, enable)); |
|
|
|
DO(write_pn_bit(1501, 2, enable)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::stop() { |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 0, 0)); |
|
|
|
DO(write_pn_bit(m_deviceId, 1501, 1, 0)); |
|
|
|
DO(write_pn_bit(1501, 0, 0)); |
|
|
|
DO(write_pn_bit(1501, 1, 0)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::get_servo_internal_state(servo_internal_status_t &state) { |
|
|
|
DO(read_pn(1065, state.status)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::isReachTarget(uint8_t &isReachTarget) {} |
|
|
|
|
|
|
|
#define AUTO_RESEND(exptr) \
|
|
|
|
int ret = 0; \ |
|
|
@ -127,57 +131,57 @@ int32_t Eq20ServoMotor::isReachTarget(uint8_t &isReachTarget) {} |
|
|
|
} \ |
|
|
|
} |
|
|
|
|
|
|
|
int32_t Eq20ServoMotor::writereg(int deviceid, uint32_t regadd, int32_t value) { //
|
|
|
|
AUTO_RESEND(_writereg(deviceid, regadd, value)); |
|
|
|
int32_t Eq20ServoMotor::writereg(uint32_t regadd, int32_t value) { //
|
|
|
|
AUTO_RESEND(_writereg(regadd, value)); |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::readreg(int deviceid, uint32_t regadd, int32_t &value) { //
|
|
|
|
AUTO_RESEND(_readreg(deviceid, regadd, value)); |
|
|
|
int32_t Eq20ServoMotor::readreg(uint32_t regadd, int32_t &value) { //
|
|
|
|
AUTO_RESEND(_readreg(regadd, value)); |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::write_reg_bit(int deviceid, uint32_t regadd, int32_t off, int32_t value) { //
|
|
|
|
AUTO_RESEND(_write_reg_bit(deviceid, regadd, off, value)); |
|
|
|
int32_t Eq20ServoMotor::write_reg_bit(uint32_t regadd, int32_t off, int32_t value) { //
|
|
|
|
AUTO_RESEND(_write_reg_bit(regadd, off, value)); |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::write_pn(int deviceid, uint32_t pnadd, int32_t value) { //
|
|
|
|
AUTO_RESEND(_write_pn(deviceid, pnadd, value)); |
|
|
|
int32_t Eq20ServoMotor::write_pn(uint32_t pnadd, int32_t value) { //
|
|
|
|
AUTO_RESEND(_write_pn(pnadd, value)); |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::read_pn(int deviceid, uint32_t pnadd, int32_t &value) { //
|
|
|
|
AUTO_RESEND(_read_pn(deviceid, pnadd, value)); |
|
|
|
int32_t Eq20ServoMotor::read_pn(uint32_t pnadd, int32_t &value) { //
|
|
|
|
AUTO_RESEND(_read_pn(pnadd, value)); |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::write_pn_bit(int deviceid, uint32_t pnadd, int32_t off, int32_t value) { AUTO_RESEND(_write_pn_bit(deviceid, pnadd, off, value)); } |
|
|
|
int32_t Eq20ServoMotor::read_reg_bit(int deviceid, uint32_t regadd, int32_t off, int32_t &value) { AUTO_RESEND(_read_reg_bit(deviceid, regadd, off, value)); } |
|
|
|
int32_t Eq20ServoMotor::read_pn_bit(int deviceid, uint32_t pnadd, int32_t off, int32_t &value) { AUTO_RESEND(_read_pn_bit(deviceid, pnadd, off, value)); } |
|
|
|
int32_t Eq20ServoMotor::write_pn_bit(uint32_t pnadd, int32_t off, int32_t value) { AUTO_RESEND(_write_pn_bit(pnadd, off, value)); } |
|
|
|
int32_t Eq20ServoMotor::read_reg_bit(uint32_t regadd, int32_t off, int32_t &value) { AUTO_RESEND(_read_reg_bit(regadd, off, value)); } |
|
|
|
int32_t Eq20ServoMotor::read_pn_bit(uint32_t pnadd, int32_t off, int32_t &value) { AUTO_RESEND(_read_pn_bit(pnadd, off, value)); } |
|
|
|
|
|
|
|
/*******************************************************************************
|
|
|
|
* BASIC_API * |
|
|
|
*******************************************************************************/ |
|
|
|
int32_t Eq20ServoMotor::_write_pn(int deviceid, uint32_t pnadd, int32_t value) { return _writereg(deviceid, pnadd * 2, value); } |
|
|
|
int32_t Eq20ServoMotor::_read_pn(int deviceid, uint32_t pnadd, int32_t &value) { return _readreg(deviceid, pnadd * 2, value); } |
|
|
|
int32_t Eq20ServoMotor::_write_pn_bit(int deviceid, uint32_t pnadd, int32_t off, int32_t value) { return _write_reg_bit(deviceid, pnadd * 2, off, value); } |
|
|
|
int32_t Eq20ServoMotor::_read_pn_bit(int deviceid, uint32_t pnadd, int32_t off, int32_t &value) { return _read_reg_bit(deviceid, pnadd * 2, off, value); } |
|
|
|
int32_t Eq20ServoMotor::_write_pn(uint32_t pnadd, int32_t value) { return _writereg(pnadd * 2, value); } |
|
|
|
int32_t Eq20ServoMotor::_read_pn(uint32_t pnadd, int32_t &value) { return _readreg(pnadd * 2, value); } |
|
|
|
int32_t Eq20ServoMotor::_write_pn_bit(uint32_t pnadd, int32_t off, int32_t value) { return _write_reg_bit(pnadd * 2, off, value); } |
|
|
|
int32_t Eq20ServoMotor::_read_pn_bit(uint32_t pnadd, int32_t off, int32_t &value) { return _read_reg_bit(pnadd * 2, off, value); } |
|
|
|
/*******************************************************************************
|
|
|
|
* REG * |
|
|
|
*******************************************************************************/ |
|
|
|
int32_t Eq20ServoMotor::_writereg(int deviceid, uint32_t regadd, int32_t value) { //
|
|
|
|
DO(m_modbusBlockHost->writeReg10Muti(deviceid, regadd, (uint16_t *)&value, 2, 100)); |
|
|
|
int32_t Eq20ServoMotor::_writereg(uint32_t regadd, int32_t value) { //
|
|
|
|
DO(m_modbusBlockHost->writeReg10Muti(m_deviceId, regadd, (uint16_t *)&value, 2, 100)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::_readreg(int deviceid, uint32_t regadd, int32_t &value) { //
|
|
|
|
DO(m_modbusBlockHost->readReg03Muti(deviceid, regadd, (uint16_t *)&value, 2, 100)); |
|
|
|
int32_t Eq20ServoMotor::_readreg(uint32_t regadd, int32_t &value) { //
|
|
|
|
DO(m_modbusBlockHost->readReg03Muti(m_deviceId, regadd, (uint16_t *)&value, 2, 100)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::_write_reg_bit(int deviceid, uint32_t regadd, int32_t off, int32_t value) { |
|
|
|
int32_t Eq20ServoMotor::_write_reg_bit(uint32_t regadd, int32_t off, int32_t value) { |
|
|
|
int32_t regval; |
|
|
|
DO(_readreg(deviceid, regadd, regval)); |
|
|
|
DO(_readreg(regadd, regval)); |
|
|
|
if (value) { |
|
|
|
regval |= (1 << off); |
|
|
|
} else { |
|
|
|
regval &= ~(1 << off); |
|
|
|
} |
|
|
|
DO(_writereg(deviceid, regadd, regval)); |
|
|
|
DO(_writereg(regadd, regval)); |
|
|
|
return 0; |
|
|
|
} |
|
|
|
int32_t Eq20ServoMotor::_read_reg_bit(int deviceid, uint32_t regadd, int32_t off, int32_t &value) { |
|
|
|
int32_t Eq20ServoMotor::_read_reg_bit(uint32_t regadd, int32_t off, int32_t &value) { |
|
|
|
int32_t regval; |
|
|
|
DO(_readreg(deviceid, regadd, regval)); |
|
|
|
DO(_readreg(regadd, regval)); |
|
|
|
value = (regval >> off) & 0x01; |
|
|
|
return 0; |
|
|
|
} |