关于PID算法温控
2019-07-14 21:02发布
打开微信“扫一扫”,打开网页后点击屏幕右上角分享按钮
- void compare_temper()
- {
- unsigned char i;
- if(set_temper>temper) //是否设置的温度大于实际温度
- {
- if(set_temper-temper>1) //设置的温度比实际的温度是否是大于1度
- {
- high_time=100; //如果是,则全速加热
- low_time=0;
- }
- else //如果是在1度范围内,则运行PID计算
- {
- 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/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);
- else
- high_time=0;
- low_time= (100-high_time);
- }
- }
- // else
- // {}
- }
想问问第20行和第42行的含义?
一周热门 更多>