Browse Source

update

master
zhaohe 2 years ago
parent
commit
147006090e
  1. 3
      components/step_motor_ctrl_module/step_motor_ctrl_module.hpp
  2. 2
      components/tmc/basic/tmc_ic_interface.hpp
  3. 27
      components/tmc/ic/ztmc5130.cpp
  4. 5
      components/tmc/ic/ztmc5130.hpp

3
components/step_motor_ctrl_module/step_motor_ctrl_module.hpp

@ -163,6 +163,9 @@ class StepMotorCtrlModule : public I_StepMotorCtrlModule, public ZIModule, publi
virtual int32_t motor_easy_move_to(int32_t position) override;
virtual int32_t motor_easy_move_to_zero(int32_t direction) override;
IStepperMotor* _getStepMotor() { return m_stepM1; }
base_param_t& _get_base_param() { return m_param; }
private:
void active_cfg();

2
components/tmc/basic/tmc_ic_interface.hpp

@ -63,6 +63,8 @@ class IStepperMotor {
virtual void setScaleDenominator(int32_t scale) = 0;
virtual void enable(bool enable) = 0;
virtual void setNoAccLimit(bool enable){};
};
} // namespace iflytop

27
components/tmc/ic/ztmc5130.cpp

@ -10,7 +10,7 @@ using namespace iflytop;
* @brief TMC5130配置参数,使
*
* :
* 1. 使??
* 1. 使??
* 2. ??
* @param config
*/
@ -62,13 +62,19 @@ void TMC5130::initialize(cfg_t *cfg) {
writeInt(TMC5130_XACTUAL, 0x00000000);
writeInt(TMC5130_VACTUAL, 0x00000000);
writeInt(TMC5130_VSTART, 5);
writeInt(TMC5130_VSTART, 100);
writeInt(TMC5130_A1, 1000);
writeInt(TMC5130_V1, 0);
writeInt(TMC5130_D1, 1000);
writeInt(TMC5130_VSTOP, 10);
writeInt(TMC5130_TZEROWAIT, 1000);
writeInt(TMC5130_VSTOP, 100);
writeInt(TMC5130_TZEROWAIT, 0);
// writeInt(TMC5130_VSTART, 100);
// writeInt(TMC5130_V1, 0);
// writeInt(TMC5130_VSTOP, 100);
// writeInt(TMC5130_TZEROWAIT, 0);
setAcceleration(100);
setDeceleration(100);
@ -76,6 +82,16 @@ void TMC5130::initialize(cfg_t *cfg) {
enableIC(true);
}
void TMC5130::setNoAccLimit(bool enable) {
if (!enable) {
writeInt(TMC5130_VSTART, 100);
writeInt(TMC5130_VSTOP, 100);
} else {
writeInt(TMC5130_VSTART, 262144 - 1); // 2^18-1
writeInt(TMC5130_VSTOP, 262144 - 1); // 2^18-1
}
}
void TMC5130::enableIC(bool enable) {
// m_port->TMC5130Port_setENNPinState(m_channel, !enable);
SET_PIN(m_ennpin, !enable);
@ -211,7 +227,8 @@ int32_t TMC5130::readInt(uint8_t address) {
return ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | (data[3] << 8) | data[4];
}
int32_t TMC5130::to_motor_acc(int32_t acc) { //
int32_t val = acc / 60.0 * 51200;
int32_t val = acc / 60.0 * 51200; // 65535
// if (val > 65535) val = 65535;
return val;
}
int32_t TMC5130::to_motor_vel(int32_t vel) { //

5
components/tmc/ic/ztmc5130.hpp

@ -91,6 +91,8 @@ class TMC5130 : public IStepperMotor {
int32_t m_scale = 10000;
int32_t m_scale_deceleration = 1;
// int32_t m_subdivision = 256;
public:
TMC5130(/* args */);
@ -123,6 +125,7 @@ class TMC5130 : public IStepperMotor {
virtual void setDeceleration(float accelerationpps2);
void setIHOLD_IRUN(uint8_t ihold, uint8_t irun, uint16_t iholddelay);
// void setSubdivision(uint8_t subdivision);
void setMotorShaft(bool reverse); // ÉèÖõç»úÐýת·½Ïò
@ -149,6 +152,8 @@ class TMC5130 : public IStepperMotor {
void writeInt(uint8_t address, int32_t value);
int32_t readInt(uint8_t address);
void setNoAccLimit(bool enable) override;
private:
uint32_t haspassedms(uint32_t now, uint32_t last);

Loading…
Cancel
Save