|
50黑幣
我在做PID溫度控制的時候,下面的這個函數有一部分不懂,我用紅色標記出來,大神幫忙看一下,幫下小白哈,小白再次感激不盡! 
- /***********************************************************
- 溫度比較處理子程序
- ***********************************************************/
- void compare_temper()
- {
- unsigned char i ;
- //EA=0;
- if(set_temper>temper)//設定值大于測量值
- {
- if(set_temper-temper>1)
- {
- high_time=100 ; //大于1°不進行PID運算
- low_time=0 ;
- }
- else
- { //在1°范圍內進行PID運算
- for(i=0;i<10;i++) //為什么要進行10次,這樣前九次不是都沒用了嗎?
- {
- //get_temper();
- rin=s;
- // Read Input
- rout=PIDCalc(&spid,rin); //執行PID運算(位置式PID)
- // Perform PID Interation
- }
- if(high_time<=100) //限制最大值
- high_time=(unsigned char)(rout/800);//這里為什么要除以800啊?
- else
- high_time=100;
- low_time=(100-high_time);
- }
- }
- /****************************************/
- else if(set_temper<=temper) //當實際溫度大于設置溫度時
- {
- if(temper-set_temper>0)//如果實際溫度大于設定溫度
- {
- high_time=0 ;
- low_time=100 ;
- }
- else
- {
- for(i=0;i<10;i++)
- {
- //get_temper();
- rin=s ;
- // Read Input
- rout=PIDCalc(&spid,rin);
- // Perform PID Interation
- }
- if(high_time<100) //此變量是無符號字符型
- high_time=(unsigned char)(rout/10000);//這里又為什么除以10000?
- else
- high_time=0 ;//限制不輸出負值
- low_time=(100-high_time);
- //EA=1;
- }
- }
- }
- 各位大神幫忙看下,如果需要其他源程序,小白立馬貼上。
- 在這里再次感謝各位大神了。
- 小白在線等,非常感謝。。。
|
|