parent
93071dc6b4
commit
1430888d67
|
@ -8,8 +8,8 @@
|
||||||
#ifdef PTZ_STEP_MOTOR
|
#ifdef PTZ_STEP_MOTOR
|
||||||
#define DCSTEP_SPEED_LIMIT_HORI 3.3//19.8°以下不使用DCSTEP
|
#define DCSTEP_SPEED_LIMIT_HORI 3.3//19.8°以下不使用DCSTEP
|
||||||
#define DCSTEP_SPEED_LIMIT_VERT 3.3//俯仰
|
#define DCSTEP_SPEED_LIMIT_VERT 3.3//俯仰
|
||||||
#define DCSTEP_HORI_EN 1
|
#define DCSTEP_HORI_EN 0
|
||||||
#define DCSTEP_VERT_EN 1
|
#define DCSTEP_VERT_EN 0
|
||||||
|
|
||||||
static BSP_OS_SEM ptz_ftm_mutex;//共享资源锁
|
static BSP_OS_SEM ptz_ftm_mutex;//共享资源锁
|
||||||
|
|
||||||
|
@ -177,8 +177,8 @@ static void ptz_vert_step_speed_task()
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
// if ( GetVertDcoStatus() )
|
if ( GetVertDcoStatus() )
|
||||||
// {
|
{
|
||||||
if(g_ptz.vert_start_stop_set == PTZ_VERT_START)
|
if(g_ptz.vert_start_stop_set == PTZ_VERT_START)
|
||||||
{
|
{
|
||||||
g_ptz.vert_tmc2160.set_f = ptz_vert_step_v_to_f((g_ptz.vert_speed_set * PTZ_VERT_RATIO), g_ptz.vert_tmc2160.microstep_vlue);
|
g_ptz.vert_tmc2160.set_f = ptz_vert_step_v_to_f((g_ptz.vert_speed_set * PTZ_VERT_RATIO), g_ptz.vert_tmc2160.microstep_vlue);
|
||||||
|
@ -250,23 +250,7 @@ static void ptz_vert_step_speed_task()
|
||||||
g_ptz.vert_speed_actual = 0;
|
g_ptz.vert_speed_actual = 0;
|
||||||
g_ptz.vert_tmc2160.f = 0;
|
g_ptz.vert_tmc2160.f = 0;
|
||||||
}
|
}
|
||||||
// }
|
}
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if ( GetDcstepPulseFlag() )
|
|
||||||
// {
|
|
||||||
//// gpio_bit_set(GPIOD, GPIO_PIN_12);
|
|
||||||
//// OSTimeDlyHMSM(0u, 0u, 0u, 1u);
|
|
||||||
//// gpio_bit_reset(GPIOD, GPIO_PIN_12);
|
|
||||||
//// ptz_vert_timer_start((unsigned int)(g_ptz.vert_tmc2160.f + 0.5));
|
|
||||||
//// OSTimeDlyHMSM(0u, 0u, 0u, 1u);
|
|
||||||
// ResetDcstepPulseFlag();
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
//// ptz_vert_timer_stop();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
OSTimeDlyHMSM(0u, 0u, 0u, PTZ_VERT_ACC_DEC_INC_T);
|
OSTimeDlyHMSM(0u, 0u, 0u, PTZ_VERT_ACC_DEC_INC_T);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,22 +11,12 @@
|
||||||
|
|
||||||
#if DCSTEP_FUN_EN
|
#if DCSTEP_FUN_EN
|
||||||
uint8_t g_dcStepVert = 1;
|
uint8_t g_dcStepVert = 1;
|
||||||
uint8_t g_dcStepVertPulseFlag = 0;
|
|
||||||
|
|
||||||
uint8_t GetVertDcoStatus(void)
|
uint8_t GetVertDcoStatus(void)
|
||||||
{
|
{
|
||||||
return g_dcStepVert;
|
return g_dcStepVert;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t GetDcstepPulseFlag(void)
|
|
||||||
{
|
|
||||||
return g_dcStepVertPulseFlag;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ResetDcstepPulseFlag(void)
|
|
||||||
{
|
|
||||||
g_dcStepVertPulseFlag = 0;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// @brief 外部中断初始化
|
/// @brief 外部中断初始化
|
||||||
|
|
|
@ -3,13 +3,11 @@
|
||||||
#include "ptz_type_select.h"
|
#include "ptz_type_select.h"
|
||||||
#include "gd32f4xx.h"
|
#include "gd32f4xx.h"
|
||||||
|
|
||||||
#define DCSTEP_FUN_EN 0
|
#define DCSTEP_FUN_EN 1
|
||||||
|
|
||||||
//#if DCSTEP_FUN_EN
|
#if DCSTEP_FUN_EN
|
||||||
//uint8_t GetVertDcoStatus(void);
|
uint8_t GetVertDcoStatus(void);
|
||||||
//uint8_t GetDcstepPulseFlag(void);
|
#endif
|
||||||
//void ResetDcstepPulseFlag(void);
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
#ifdef PTZ_LIGHT_GEAR_L6235D_AS5047D
|
#ifdef PTZ_LIGHT_GEAR_L6235D_AS5047D
|
||||||
//使用L6235D驱动电机,并打开霍尔反馈
|
//使用L6235D驱动电机,并打开霍尔反馈
|
||||||
|
|
|
@ -180,7 +180,7 @@ void tmc2160_init()
|
||||||
/*垂直DCO触发外部中断*/
|
/*垂直DCO触发外部中断*/
|
||||||
nvic_irq_enable(EXTI10_15_IRQn, 2U, 2U);
|
nvic_irq_enable(EXTI10_15_IRQn, 2U, 2U);
|
||||||
syscfg_exti_line_config(EXTI_SOURCE_GPIOE, EXTI_SOURCE_PIN12);
|
syscfg_exti_line_config(EXTI_SOURCE_GPIOE, EXTI_SOURCE_PIN12);
|
||||||
exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_BOTH);
|
exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_FALLING);
|
||||||
exti_interrupt_flag_clear(EXTI_12);
|
exti_interrupt_flag_clear(EXTI_12);
|
||||||
/*垂直DCO定时器更新中断配置*/
|
/*垂直DCO定时器更新中断配置*/
|
||||||
timer_parameter_struct timer_initpara;//定时器结构体
|
timer_parameter_struct timer_initpara;//定时器结构体
|
||||||
|
@ -191,8 +191,8 @@ void tmc2160_init()
|
||||||
timer_deinit(TIMER7); //复位定时器
|
timer_deinit(TIMER7); //复位定时器
|
||||||
|
|
||||||
/* TIMER1 configuration */
|
/* TIMER1 configuration */
|
||||||
//200M/200/1000 = 1k
|
//200M/20/1000 = 10K
|
||||||
timer_initpara.prescaler = 200-1;//预分频
|
timer_initpara.prescaler = 20-1;//预分频
|
||||||
timer_initpara.alignedmode = TIMER_COUNTER_EDGE; //边缘对齐
|
timer_initpara.alignedmode = TIMER_COUNTER_EDGE; //边缘对齐
|
||||||
timer_initpara.counterdirection = TIMER_COUNTER_UP; //向上计数方式
|
timer_initpara.counterdirection = TIMER_COUNTER_UP; //向上计数方式
|
||||||
timer_initpara.period = 1000-1; //计数值
|
timer_initpara.period = 1000-1; //计数值
|
||||||
|
|
|
@ -37,10 +37,10 @@ OF SUCH DAMAGE.
|
||||||
#include "bsp_os.h"
|
#include "bsp_os.h"
|
||||||
#include "Usart.h"
|
#include "Usart.h"
|
||||||
#include "device_interrupt.h"
|
#include "device_interrupt.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
#if DCSTEP_FUN_EN
|
#if DCSTEP_FUN_EN
|
||||||
extern uint8_t g_dcStepVert;
|
extern uint8_t g_dcStepVert;
|
||||||
extern uint8_t g_dcStepVertPulseFlag;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern BSP_OS_SEM sem_enet_isr_recv;
|
extern BSP_OS_SEM sem_enet_isr_recv;
|
||||||
|
@ -286,20 +286,22 @@ void EXTI10_15_IRQHandler(void)
|
||||||
if(RESET != exti_interrupt_flag_get(EXTI_12))
|
if(RESET != exti_interrupt_flag_get(EXTI_12))
|
||||||
{
|
{
|
||||||
/*function start*/
|
/*function start*/
|
||||||
// if (g_dcStepVert)
|
if (g_dcStepVert)
|
||||||
// {
|
{
|
||||||
//// exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_RISING);//上升沿中断
|
exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_RISING);//上升沿中断
|
||||||
// timer_enable(TIMER7);//使能定时器
|
timer_enable(TIMER7);//使能定时器
|
||||||
// timer_counter_value_config(TIMER7, 0u);
|
timer_counter_value_config(TIMER7, 0u);
|
||||||
// g_dcStepVert = 0;
|
ptz_vert_timer_stop();
|
||||||
// }
|
g_dcStepVert = 0;
|
||||||
// else
|
}
|
||||||
// {
|
else
|
||||||
//// exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_FALLING);//下降沿中断
|
{
|
||||||
// timer_disable(TIMER7);//失能定时器
|
exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_FALLING);//下降沿中断
|
||||||
// timer_counter_value_config(TIMER7, 0u);
|
timer_disable(TIMER7);//失能定时器
|
||||||
// g_dcStepVert = 1;
|
timer_counter_value_config(TIMER7, 0u);
|
||||||
// }
|
ptz_vert_timer_start(20000);
|
||||||
|
g_dcStepVert = 1;
|
||||||
|
}
|
||||||
/*function end*/
|
/*function end*/
|
||||||
exti_interrupt_flag_clear(EXTI_12);
|
exti_interrupt_flag_clear(EXTI_12);
|
||||||
}
|
}
|
||||||
|
@ -368,20 +370,22 @@ void EXTI2_IRQHandler(void)
|
||||||
*/
|
*/
|
||||||
void TIMER7_UP_TIMER12_IRQHandler(void)
|
void TIMER7_UP_TIMER12_IRQHandler(void)
|
||||||
{
|
{
|
||||||
// static uint32_t count = 0;
|
static uint16_t count = 0;
|
||||||
// if(SET == timer_interrupt_flag_get(TIMER7,TIMER_INT_UP))
|
if(SET == timer_interrupt_flag_get(TIMER7,TIMER_INT_UP))
|
||||||
// {
|
{
|
||||||
// count++;
|
count ++;
|
||||||
// if ( count >= 2 )
|
if ( count >= 10 )
|
||||||
// {
|
{
|
||||||
// count = 0;
|
gpio_bit_set(GPIOD, GPIO_PIN_12);
|
||||||
// g_dcStepVertPulseFlag = 1;
|
}
|
||||||
// timer_disable(TIMER7);//失能定时器
|
else if( count >= 12 )
|
||||||
// timer_counter_value_config(TIMER7, 0u);
|
{
|
||||||
//// g_dcStepVert = 1;
|
count = 0;
|
||||||
// }
|
timer_disable(TIMER7);//失能定时器
|
||||||
//
|
timer_counter_value_config(TIMER7, 0u);
|
||||||
// }
|
gpio_bit_reset(GPIOD, GPIO_PIN_12);
|
||||||
|
}
|
||||||
|
}
|
||||||
/* clear TIMER interrupt flag */
|
/* clear TIMER interrupt flag */
|
||||||
timer_interrupt_flag_clear(TIMER7,TIMER_INT_UP);
|
timer_interrupt_flag_clear(TIMER7,TIMER_INT_UP);
|
||||||
}
|
}
|
|
@ -738,7 +738,7 @@
|
||||||
<data>
|
<data>
|
||||||
<extensions></extensions>
|
<extensions></extensions>
|
||||||
<cmdline></cmdline>
|
<cmdline></cmdline>
|
||||||
<hasPrio>184</hasPrio>
|
<hasPrio>1</hasPrio>
|
||||||
<buildSequence>inputOutputBased</buildSequence>
|
<buildSequence>inputOutputBased</buildSequence>
|
||||||
</data>
|
</data>
|
||||||
</settings>
|
</settings>
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
V1.0(sourcetree内:相较前一版本优化一些参数)
|
||||||
|
1,水平和垂直在25°/S噪声明显
|
||||||
|
2,水平和垂直在40°/S效果较好
|
||||||
|
3,水平和垂直在高转速下(水平60以上,垂直60),接近目标位置5°内会自动将速度降到1.8°/S
|
||||||
|
4,俯仰转动在低转速下,-45°位置会有轻微异响
|
Loading…
Reference in New Issue