Сб мар 21, 2020 18:25:05
Сб мар 21, 2020 21:50:59
Вс мар 22, 2020 10:20:53
Пт авг 06, 2021 15:23:04
Пт авг 06, 2021 16:18:05
/**********************************************************************************************************
void pwm_Adjust(void)
**********************************************************************************************************
Function: void pwm_Adjust(void)
Input: None
Output: uint16_t
Description: Pwm adjustment
**********************************************************************************************************/
void pwm_Adjust(void)
{
static uint16_t LastRun=0;
uint16_t call_delta=0;
int16_t temp_Diff=0;
uint16_t temperature=999;
if(LastRun>Ticks){
call_delta=UINT16_MAX-LastRun+Ticks;
} else {
call_delta=Ticks-LastRun;
}
if(call_delta< DETLA_REG ){
_NOP();
} else {
LastRun=Ticks;
cli();
adjustPWM_Running=1;
sei();
Station.PWM.Off(); //switch off heater
_delay_ms(10); //wait for some time (to get low pass filter in steady state)
temperature = Station.Temp.Read(ADC_AVG);
if(setpoint > temperature)
{
temp_Diff = (int32_t)setpoint - (int32_t)temperature;
if(temp_Diff < 3)
{
current_PWM +=(int32_t)5;
}
else
{
current_PWM = (int32_t)temp_Diff * (int32_t)setpoint/ (int32_t)6 ;
}
if(current_PWM > MAX_PWM_LIMIT){
current_PWM = MAX_PWM_LIMIT;
}
}
else if(setpoint < temperature)
{
temp_Diff = (int32_t)temperature - (int32_t)setpoint;
if(temp_Diff > 2)
{
current_PWM = 0;
}
else
{
if(current_PWM>0){
if( ((int32_t)current_PWM/(int32_t)7) > 0){
current_PWM -= (int32_t)current_PWM/(int32_t)7;
if( ((int32_t)current_PWM%(int32_t)7) > 3){
if(current_PWM>0){
current_PWM--;
}
}
} else {
current_PWM--;
}
}
}
if(current_PWM < 0)
current_PWM = 0;
} else {
current_PWM = current_PWM;
}
HeatPwr_Percent= ((current_PWM*100) / MAX_PWM_LIMIT );
adjustPWM_Running=0;
}
}
Пн авг 09, 2021 15:48:30
Пн авг 09, 2021 17:02:37
Ср сен 08, 2021 20:53:52
Ср сен 08, 2021 22:19:40
Чт сен 09, 2021 08:21:25
конечно PID foreveramigo60 писал(а):PID и дальше