From 1430888d67927f4ffe34e9bbd320d77e717cef3b Mon Sep 17 00:00:00 2001 From: "REASEARCHER\\18383" <1633026436@qq.com> Date: Wed, 20 Aug 2025 10:38:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=BB=E5=9E=8B=E6=AD=A5=E8=BF=9B=E7=94=B5?= =?UTF-8?q?=E6=9C=BA=E4=BD=BF=E7=94=A8DcStep=EF=BC=8CDCO=EF=BC=8CDCEN?= =?UTF-8?q?=EF=BC=8CDCIN=E4=B8=89=E4=B8=AA=E5=BC=95=E8=84=9A=E5=9D=87?= =?UTF-8?q?=E7=94=A8=E4=B8=8A=20=E5=A4=87=E6=B3=A8=EF=BC=9A=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E4=B8=80=E4=B8=AA=E5=9F=BA=E7=A1=80=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=89=88=EF=BC=8C=E9=9D=9E=E5=8F=AF=E7=94=A8=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hyt2/APP/Device/Device_speed/speed_to_step.c | 26 ++------ .../Device/device_Other/device_interrupt.c | 10 --- .../Device/device_Other/device_interrupt.h | 10 ++- Hyt2/BSP/Driver/tmc2160/tmc2160.c | 6 +- .../SYSTICK/gd32f4xx_it.c | 62 ++++++++++--------- Hyt2/PROJECT/OS2.ewp | 2 +- ReadMe.txt | 5 ++ 7 files changed, 51 insertions(+), 70 deletions(-) create mode 100644 ReadMe.txt diff --git a/Hyt2/APP/Device/Device_speed/speed_to_step.c b/Hyt2/APP/Device/Device_speed/speed_to_step.c index bb5a38a..82c4e0c 100644 --- a/Hyt2/APP/Device/Device_speed/speed_to_step.c +++ b/Hyt2/APP/Device/Device_speed/speed_to_step.c @@ -8,8 +8,8 @@ #ifdef PTZ_STEP_MOTOR #define DCSTEP_SPEED_LIMIT_HORI 3.3//19.8°以下不使用DCSTEP #define DCSTEP_SPEED_LIMIT_VERT 3.3//俯仰 -#define DCSTEP_HORI_EN 1 -#define DCSTEP_VERT_EN 1 +#define DCSTEP_HORI_EN 0 +#define DCSTEP_VERT_EN 0 static BSP_OS_SEM ptz_ftm_mutex;//共享资源锁 @@ -177,8 +177,8 @@ static void ptz_vert_step_speed_task() while(1) { -// if ( GetVertDcoStatus() ) -// { + if ( GetVertDcoStatus() ) + { 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); @@ -250,23 +250,7 @@ static void ptz_vert_step_speed_task() g_ptz.vert_speed_actual = 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); } diff --git a/Hyt2/APP/Device/device_Other/device_interrupt.c b/Hyt2/APP/Device/device_Other/device_interrupt.c index e58ef6e..df14286 100644 --- a/Hyt2/APP/Device/device_Other/device_interrupt.c +++ b/Hyt2/APP/Device/device_Other/device_interrupt.c @@ -11,22 +11,12 @@ #if DCSTEP_FUN_EN uint8_t g_dcStepVert = 1; -uint8_t g_dcStepVertPulseFlag = 0; uint8_t GetVertDcoStatus(void) { return g_dcStepVert; } -uint8_t GetDcstepPulseFlag(void) -{ - return g_dcStepVertPulseFlag; -} - -void ResetDcstepPulseFlag(void) -{ - g_dcStepVertPulseFlag = 0; -} #endif /// @brief 外部中断初始化 diff --git a/Hyt2/APP/Device/device_Other/device_interrupt.h b/Hyt2/APP/Device/device_Other/device_interrupt.h index 9ebe54e..8c79113 100644 --- a/Hyt2/APP/Device/device_Other/device_interrupt.h +++ b/Hyt2/APP/Device/device_Other/device_interrupt.h @@ -3,13 +3,11 @@ #include "ptz_type_select.h" #include "gd32f4xx.h" -#define DCSTEP_FUN_EN 0 +#define DCSTEP_FUN_EN 1 -//#if DCSTEP_FUN_EN -//uint8_t GetVertDcoStatus(void); -//uint8_t GetDcstepPulseFlag(void); -//void ResetDcstepPulseFlag(void); -//#endif +#if DCSTEP_FUN_EN +uint8_t GetVertDcoStatus(void); +#endif #ifdef PTZ_LIGHT_GEAR_L6235D_AS5047D //使用L6235D驱动电机,并打开霍尔反馈 diff --git a/Hyt2/BSP/Driver/tmc2160/tmc2160.c b/Hyt2/BSP/Driver/tmc2160/tmc2160.c index 9f6c59f..2cf1b84 100644 --- a/Hyt2/BSP/Driver/tmc2160/tmc2160.c +++ b/Hyt2/BSP/Driver/tmc2160/tmc2160.c @@ -180,7 +180,7 @@ void tmc2160_init() /*垂直DCO触发外部中断*/ nvic_irq_enable(EXTI10_15_IRQn, 2U, 2U); 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); /*垂直DCO定时器更新中断配置*/ timer_parameter_struct timer_initpara;//定时器结构体 @@ -191,8 +191,8 @@ void tmc2160_init() timer_deinit(TIMER7); //复位定时器 /* TIMER1 configuration */ - //200M/200/1000 = 1k - timer_initpara.prescaler = 200-1;//预分频 + //200M/20/1000 = 10K + timer_initpara.prescaler = 20-1;//预分频 timer_initpara.alignedmode = TIMER_COUNTER_EDGE; //边缘对齐 timer_initpara.counterdirection = TIMER_COUNTER_UP; //向上计数方式 timer_initpara.period = 1000-1; //计数值 diff --git a/Hyt2/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c b/Hyt2/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c index 2c1176d..f01724b 100644 --- a/Hyt2/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c +++ b/Hyt2/GD32F4xx_Firmware_Library/SYSTICK/gd32f4xx_it.c @@ -37,10 +37,10 @@ OF SUCH DAMAGE. #include "bsp_os.h" #include "Usart.h" #include "device_interrupt.h" +#include "Timer.h" #if DCSTEP_FUN_EN extern uint8_t g_dcStepVert; -extern uint8_t g_dcStepVertPulseFlag; #endif 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)) { /*function start*/ -// if (g_dcStepVert) -// { -//// exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_RISING);//上升沿中断 -// timer_enable(TIMER7);//使能定时器 -// timer_counter_value_config(TIMER7, 0u); -// g_dcStepVert = 0; -// } -// else -// { -//// exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_FALLING);//下降沿中断 -// timer_disable(TIMER7);//失能定时器 -// timer_counter_value_config(TIMER7, 0u); -// g_dcStepVert = 1; -// } + if (g_dcStepVert) + { + exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_RISING);//上升沿中断 + timer_enable(TIMER7);//使能定时器 + timer_counter_value_config(TIMER7, 0u); + ptz_vert_timer_stop(); + g_dcStepVert = 0; + } + else + { + exti_init(EXTI_12, EXTI_INTERRUPT, EXTI_TRIG_FALLING);//下降沿中断 + timer_disable(TIMER7);//失能定时器 + timer_counter_value_config(TIMER7, 0u); + ptz_vert_timer_start(20000); + g_dcStepVert = 1; + } /*function end*/ exti_interrupt_flag_clear(EXTI_12); } @@ -368,20 +370,22 @@ void EXTI2_IRQHandler(void) */ void TIMER7_UP_TIMER12_IRQHandler(void) { -// static uint32_t count = 0; -// if(SET == timer_interrupt_flag_get(TIMER7,TIMER_INT_UP)) -// { -// count++; -// if ( count >= 2 ) -// { -// count = 0; -// g_dcStepVertPulseFlag = 1; -// timer_disable(TIMER7);//失能定时器 -// timer_counter_value_config(TIMER7, 0u); -//// g_dcStepVert = 1; -// } -// -// } + static uint16_t count = 0; + if(SET == timer_interrupt_flag_get(TIMER7,TIMER_INT_UP)) + { + count ++; + if ( count >= 10 ) + { + gpio_bit_set(GPIOD, GPIO_PIN_12); + } + else if( count >= 12 ) + { + count = 0; + timer_disable(TIMER7);//失能定时器 + timer_counter_value_config(TIMER7, 0u); + gpio_bit_reset(GPIOD, GPIO_PIN_12); + } + } /* clear TIMER interrupt flag */ timer_interrupt_flag_clear(TIMER7,TIMER_INT_UP); } \ No newline at end of file diff --git a/Hyt2/PROJECT/OS2.ewp b/Hyt2/PROJECT/OS2.ewp index 2fded51..d8d75c5 100644 --- a/Hyt2/PROJECT/OS2.ewp +++ b/Hyt2/PROJECT/OS2.ewp @@ -738,7 +738,7 @@ - 184 + 1 inputOutputBased diff --git a/ReadMe.txt b/ReadMe.txt new file mode 100644 index 0000000..0276818 --- /dev/null +++ b/ReadMe.txt @@ -0,0 +1,5 @@ +V1.0(sourcetree鍐咃細鐩歌緝鍓嶄竴鐗堟湰浼樺寲涓浜涘弬鏁) +1锛屾按骞冲拰鍨傜洿鍦25掳/S鍣0鏄庢樉 +2锛屾按骞冲拰鍨傜洿鍦40掳/S鏁堟灉杈冨ソ +3锛屾按骞冲拰鍨傜洿鍦ㄩ珮杞熶笅锛堟按骞60浠ヤ笂锛屽瀭鐩60锛夛紝鎺ヨ繎鐩爣浣嶇疆5掳鍐呬細鑷姩灏嗛熷害闄嶅埌1.8掳/S +4锛屼刊浠拌浆鍔ㄥ湪浣庤浆閫熶笅锛-45掳浣嶇疆浼氭湁杞诲井寮傚搷 \ No newline at end of file