Demo entry 6350216

哈哈

   

Submitted by anonymous on Mar 08, 2017 at 08:50
Language: C. Code size: 790 Bytes.

/** 获取当前通道的实时AD值 */
heater[i].cur_temperature_ad = get_pt100_ad(i);
/** 计算当前误差(比例) */
heater[i].cur_err = ((int32_t)heater[i].temperature_set_ad - (int32_t)heater[i].cur_temperature_ad) / AD_0T01; 
heater[i].sum_err += heater[i].cur_err;    /**< 累计变化(积分) */
if ( heater[i].sum_err > 300000)           /**< 限制积分过大 */
{
    heater[i].sum_err = 300000;
}
 /** 误差变化(微分)*/
heater[i].d_err = (heater[i].cur_err << 1) - heater[i].last_err - heater[i].prev_err;   
 /** 保存当前值 */
heater[i].prev_err = heater[i].last_err;   
heater[i].last_err = heater[i].cur_err;

/** duty_p[i] 比例因子的计算,将设定值调高0.1℃ */
duty_p[i] = (int32_t)heater[i].p * (heater[i].cur_err + 10) * 5;    
duty_i[i] = (int32_t)heater[i].i * heater[i].sum_err / 300;
duty_d[i] = (int32_t)heater[i].d * heater[i].d_err;

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).