diff --git a/matlab_stm_emulate b/matlab_stm_emulate index ea8bdbc..a92cd95 160000 --- a/matlab_stm_emulate +++ b/matlab_stm_emulate @@ -1 +1 @@ -Subproject commit ea8bdbc185777a1321e8dedcfb76bfeb7f74b94c +Subproject commit a92cd95eeb67f97cbd0ce74966bde3971527cb4a diff --git a/mcu_project/upp/Core/upp/tiristor.c b/mcu_project/upp/Core/upp/tiristor.c index ed39a60..bf4e720 100644 --- a/mcu_project/upp/Core/upp/tiristor.c +++ b/mcu_project/upp/Core/upp/tiristor.c @@ -49,17 +49,23 @@ void tiristor_angle_control(TiristorControl_t *ctrl) if ((uint16_t)((uint16_t)TIMER->CNT - ctrl->angle.start_delay_us) > ctrl->angle.delay_us) { +#ifndef DISABLE_TIRISTOR_READY if(ctrl->f.TiristorDone == 0) { ctrl->f.EnableTiristor = 1; ctrl->f.TiristorDone = 1; } +#else + ctrl->f.EnableTiristor = 1; +#endif } } void tiristor_start_angle_delay(TiristorControl_t *ctrl) { +#ifndef DISABLE_TIRISTOR_READY ctrl->f.TiristorDone = 0; +#endif ctrl->angle.start_delay_us = TIMER->CNT; } @@ -82,10 +88,10 @@ void tiristor_init(TiristorControl_t *ctrl, GPIO_TypeDef *gpiox, uint32_t gpio_p ctrl->gpiox = gpiox; ctrl->gpio_pin = gpio_pin; ctrl->angle.delay_max_us = 8000; - ctrl->angle.delay_min_us = 100; - ctrl->angle.delay_us = 7000; - ctrl->angle.delay_step_us = 500; - ctrl->angle.sample_time_ms = 100; + ctrl->angle.delay_min_us = 500; + ctrl->angle.delay_us = 8000; + ctrl->angle.delay_step_us = 800; + ctrl->angle.sample_time_ms = 20; ctrl->open_time = 1; TIMER->CR1 |= TIM_CR1_CEN; } \ No newline at end of file diff --git a/mcu_project/upp/Core/upp/tiristor.h b/mcu_project/upp/Core/upp/tiristor.h index 5893d46..8d4d875 100644 --- a/mcu_project/upp/Core/upp/tiristor.h +++ b/mcu_project/upp/Core/upp/tiristor.h @@ -10,12 +10,15 @@ #define TIMER TIM2 +#define DISABLE_TIRISTOR_READY typedef struct { unsigned EnableTiristor:1; unsigned TiristorIsEnable:1; +#ifndef DISABLE_TIRISTOR_READY unsigned TiristorDone:1; +#endif }TiristorControlFlags; diff --git a/mcu_project/upp/Core/upp/upp.c b/mcu_project/upp/Core/upp/upp.c index 9d61be4..39cf054 100644 --- a/mcu_project/upp/Core/upp/upp.c +++ b/mcu_project/upp/Core/upp/upp.c @@ -10,28 +10,27 @@ void upp_main(void) upp_phase_routine(&phase_B); upp_phase_routine(&phase_C); -// upp_phase_control(&phase_A); -// upp_phase_control(&phase_B); -// upp_phase_control(&phase_C); + upp_phase_control(&phase_A); + upp_phase_control(&phase_B); + upp_phase_control(&phase_C); } void upp_phase_control(Phase_t *phase) { - tiristor_angle_control(&phase->ctrl); - tiristor_control(&phase->ctrl); + if(is_zero_cross(&phase->zc_detector)) + { + tiristor_start_angle_delay(&phase->ctrl); + + if (phase->ctrl.f.TiristorIsEnable) + tiristor_disable(&phase->ctrl); + } } void upp_phase_routine(Phase_t *phase) { + tiristor_angle_control(&phase->ctrl); + tiristor_control(&phase->ctrl); zero_cross_update(&phase->zc_detector); - if(is_zero_cross(&phase->zc_detector)) - { - phase->ctrl.gpiox->ODR ^= phase->ctrl.gpio_pin; -// tiristor_start_angle_delay(&phase->ctrl); - -// if (phase->ctrl.f.TiristorIsEnable) -// tiristor_disable(&phase->ctrl); - } } void upp_init(void)