|
|
@@ -1983,12 +1983,10 @@ void motor_zero()
|
|
|
}
|
|
|
|
|
|
|
|
|
-uint16_t ctr_Motor86_move(uint32_t xdis,uint16_t pulse,uint8_t dir)
|
|
|
+uint16_t ctr_Motor86_move(uint32_t xdis,uint32_t pulse,uint8_t dir)
|
|
|
{
|
|
|
//rt_kprintf("run here1");
|
|
|
- uint32_t j;
|
|
|
- uint32_t xtemp = 0;
|
|
|
- xtemp = xdis; //两个脉冲移动0.72度,轴方向上移动2um
|
|
|
+ LOG_W("ctr_Motor86_move:%d-%d-%d",xdis,pulse,dir); //两个脉冲移动0.72度,轴方向上移动2um
|
|
|
uint32_t limit_tm= 0;
|
|
|
rt_pin_mode(Motor_EN, PIN_MODE_OUTPUT); //使能电机驱动引脚 PB14
|
|
|
rt_pin_write(Motor_EN, ON); //引脚输出高使能有效
|
|
|
@@ -2000,82 +1998,51 @@ uint16_t ctr_Motor86_move(uint32_t xdis,uint16_t pulse,uint8_t dir)
|
|
|
//rt_kprintf("run here2");
|
|
|
rt_pin_write(CTR_RO_LIMIT, dir); //CCW 置高
|
|
|
rt_thread_delay(50);
|
|
|
+ pwm_motor86_enable(pulse);
|
|
|
while(rt_pin_read(MOTOR_86)==0)
|
|
|
{
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse); //后10%以线性减速运动
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
+ pwm_motor86_enable(pulse*2);
|
|
|
while(rt_pin_read(MOTOR_86)==1){
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse*5); //后10%以线性减速运动
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse*5);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
+ pwm_motor86_enable(pulse);
|
|
|
while(rt_pin_read(MOTOR_86)==0)
|
|
|
{
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse); //后10%以线性减速运动
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
if(dir==0)
|
|
|
{
|
|
|
+ pwm_motor86_enable(pulse*2);
|
|
|
while(rt_pin_read(MOTOR_86)==1){
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse*5); //后10%以线性减速运动
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse*5);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
}else {
|
|
|
rt_thread_delay(500);
|
|
|
rt_pin_write(CTR_RO_LIMIT, !dir); //CCW 置高
|
|
|
rt_thread_delay(100);
|
|
|
+ pwm_motor86_enable(pulse*3);
|
|
|
while(rt_pin_read(MOTOR_86)==0){
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse*20); //
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse*20);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
while(rt_pin_read(MOTOR_86)==1){
|
|
|
- rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
- rt_hw_us_delay(pulse*10); //
|
|
|
- rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
- rt_hw_us_delay(pulse*10);
|
|
|
+ limit_tm++;
|
|
|
+ rt_thread_delay(10);
|
|
|
+ if(limit_tm>=1000) break;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-// while(rt_pin_read(MOTOR_86)==0)
|
|
|
-// {
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
-// rt_hw_us_delay(pulse); //后10%以线性减速运动
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
-// rt_hw_us_delay(pulse);
|
|
|
-// }
|
|
|
-// if(dir==1)
|
|
|
-// {
|
|
|
-// while(rt_pin_read(MOTOR_86)==1)
|
|
|
-// {
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
-// rt_hw_us_delay(pulse*10); //后10%以线性减速运动
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
-// rt_hw_us_delay(pulse*10);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// for(j=0;j<xtemp;j++)
|
|
|
-// {
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, OFF);
|
|
|
-// rt_hw_us_delay(pulse); //后10%以线性减速运动
|
|
|
-// rt_pin_write(CTR_RC_LIMIT, ON);
|
|
|
-// rt_hw_us_delay(pulse);
|
|
|
-// if(rt_pin_read(MOTOR_86)==0)
|
|
|
-// {
|
|
|
-// limit_tm++;
|
|
|
-// }
|
|
|
-// if(limit_tm==10) break;
|
|
|
-// }
|
|
|
-
|
|
|
+ stop_motor_86();
|
|
|
slidelock();
|
|
|
return xdis;
|
|
|
}
|