描述
<div class="document">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"> </p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">1、项目功能介绍</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">使用合宙Air001单片机设计一个pid恒温加热台</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">2、项目属性</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">开源项目</p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">3、开源协议</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">GPL3.0</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">4、硬件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;"><span style="color: #95a5a6; font-size: 14px;">采集部分使用电阻分压电路采集热敏电阻两端电压值,推算出电阻值即可查表获取温度值;继电器控制部分采用三极管驱动,线圈接二极管用于续流;设计了两个按键,一个boot0用于下载程序,另一个用于用户控制;电源部分采用220v转5v的开关电源板,可在某购物网站上买到;三色LED灯显示当前状态:蓝灯闪-待机中,温度低,红灯闪-待机中,温度高,绿灯闪-加热中,绿灯亮-到达指定温度。</span></p>
<h3 class="paragraph text-align-type-left pap-line-1.3 pap-line-rule-auto pap-spacing-before-3pt pap-spacing-after-3pt" style="line-height: 1.8;">5、软件部分</h3>
<hr class="horizontal-splitline normal-bold-2">
<p>#define Relay PA_6<br>#define A0 PA_5<br>#define Button PB_3<br>#define Red PB_1<br>#define Green PB_2<br>#define Blue PB_0</p>
<p>int T[251] = {4033, 4030, 4027, 4024, 4020, 4017, 4013, 4009, 4005, 4000, 3996, 3991, 3986, 3981, 3976, 3971, 3965, 3959, 3953, 3947, 3941, 3934, 3927, 3920, 3912, 3905, 3896, 3888, 3880, 3871, 3862, 3852, 3842, 3832, 3822, 3811, 3800, 3788, 3777, 3764, 3752, 3739, 3725, 3712, 3697, 3683, 3668, 3653, 3637, 3621, 3604, 3587, 3569, 3551, 3533, 3514, 3495, 3475, 3455, 3434, 3413, 3391, 3369, 3347, 3324, 3301, 3277, 3253, 3228, 3203, 3178, 3152, 3125, 3099, 3072, 3044, 3017, 2989, 2960, 2932, 2902, 2873, 2844, 2814, 2784, 2753, 2723, 2692, 2661, 2630, 2599, 2567, 2536, 2504, 2472, 2441, 2409, 2377, 2345, 2313, 2285, 2249, 2218, 2186, 2154, 2123, 2091, 2060, 2029, 1998, 1967, 1936, 1906, 1876, 1846, 1816, 1786, 1757, 1728, 1699, 1670, 1642, 1615, 1587, 1559, 1549, 1506, 1479, 1453, 1427, 1402, 1377, 1352, 1328, 1304, 1280, 1257, 1234, 1211, 1189, 1167, 1145, 1124, 1103, 1082, 1062, 1042, 1022, 1003, 984, 966, 947, 929, 912, 894, 877, 861, 844, 828, 812, 797, 781, 766, 752, 737, 724, 710, 697, 683, 670, 657, 645, 632, 620, 608, 597, 586, 575, 564, 553, 543, 532, 522, 512, 503, 494, 484, 475, 466, 458, 449, 440, 433, 424, 416, 409, 401, 394, 387, 380, 372, 366, 359, 352, 346, 340, 334, 327, 321, 316, 310, 305, 299, 294, 288, 283, 279, 273, 269, 264, 260, 255, 250, 246, 242, 237, 233, 230, 226, 222, 218, 214, 211, 207, 204, 200, 197, 193, 190, 187, 184, 181, 178, 175, 172, 169, 166, 164, 161, 158, 156<br>};<br>int pv;<br>int sv = 200;<br>int last_es;<br>int es;<br>int sum_es;<br>int kp = 20;<br>int ki = 5;<br>int kd = 100;<br>bool bzw;<br>int loopTime;<br>int last_value = 0;<br>/****************初始化函数****************/<br>void setup() <br>{<br> //输入输出模式定义<br> pinMode(Relay, OUTPUT);<br> pinMode(Red, OUTPUT);<br> pinMode(Green, OUTPUT);<br> pinMode(Blue, OUTPUT);<br> pinMode(A0, INPUT);<br> pinMode(Button, INPUT);<br> //初始化端口<br> digitalWrite(Red,HIGH);<br> digitalWrite(Green,HIGH);<br> digitalWrite(Blue,HIGH);<br> //串口初始化<br> Serial.begin(9600);<br> //ADC配置<br> analogReadResolution(12);<br> //PWM<br> analogWriteFrequency(1);</p>
<p>}<br>/****************主循环函数****************/<br>void loop() <br>{<br> trig();<br> delay(10);<br> loopTime = loopTime + 1;<br> if (loopTime>=150)<br> {Main();}<br> <br> if (bzw==1)<br> {<br> analogWrite(Green,0);<br> analogWrite(Red,255);<br> if (pv>=sv)<br> {analogWrite(Blue,0);}<br> else<br> {analogWrite(Blue,255);}<br> }<br> else<br> {<br> analogWrite(Green,255);<br> if (pv>70)<br> {analogWrite(Red,128);<br> analogWrite(Blue,255);}<br> else<br> {analogWrite(Blue,128);<br> analogWrite(Red,255);}<br> }<br> //Serial.print("标志位:");<br> //Serial.println(bzw);<br>}<br>/****************查表函数****************/<br>int table()<br>{<br> for (int i=0; i</p></div>
评论(0)