тест тиристоров
This commit is contained in:
		
							parent
							
								
									f34eb8b900
								
							
						
					
					
						commit
						bfcd696ccd
					
				@ -1 +1 @@
 | 
			
		||||
Subproject commit ea8bdbc185777a1321e8dedcfb76bfeb7f74b94c
 | 
			
		||||
Subproject commit a92cd95eeb67f97cbd0ce74966bde3971527cb4a
 | 
			
		||||
@ -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;
 | 
			
		||||
}
 | 
			
		||||
@ -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;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user