【正文】
V。 shedin[9]=(set/10)%10+0x30。 if((PINCamp。 if(key!=0) shuju()。 clrram()。 33 KP_data[14]=KP%10+0x30。 chn_disp(1,0,KP_data)。 the Proportional, the Integral and Derivative values. The Proportional value determines the reaction to the current error, the Integral determines the reaction based on the sum of recent errors and the Derivative determines the reaction to the rate at which the error has been changing. The weighted sum of these three actions is used to adjust the process via a control element such as the position of a control valve or the power supply of a heating element. By tuning the three constants in the PID controller algorithm the PID can provide control action designed for specific process requirements. The response of the controller can be described in terms of the responsiveness of the controller to an error, the degree to which the controller overshoots the setpoint and the degree of system oscillation. Note that the use of the PID algorithm for control does not guarantee optimal control of the system or system stability. Some applications may require using only one or two modes to provide the controle ppropriate system control. This is achieved by setting the gain of undesired control outputs to zero. A PID controller will be called a PI, PD, P or I controller in the absence of the respective control actions. PI controllers are particularly mon, since derivative action is very sensitive to measurement noise, and the absence of an integral value may prevent the system from reaching its target value due to the control action. 2 A block diagram of a PID controller Note: Due to the diversity of the field of control theory and application, many naming conventions for the relevant variables are in mon use. Control loop basics A familiar example of a control loop is the action taken to keep one39。 chn_disp(3,0,TD_data)。 TI_data[12]=(TI/10)%10+0x30。 SEI()。0X04)==0) { CLI()。 shedin[8]=set/100+0x30。 } if(key==1) KP++。 ADCSRA|=(1ADSC)。 //禁止模擬比較器 ADCSRA= 0xCE。 //調(diào)整值限幅,防止積分飽和 } PWM_out=PWM_out+pwm_var。 Dennis C Program— ming Language, 1997, P387 28 [20] Sha zhanyou, Guochen, Sui Design of Multiple Channel Dustlike Object Temperature Measure and Control Syetem, MCGM’2022 , ISTP [21] Boait Peter, Co ntroling embedded generators using SMS, IEE Power Engineer, 2022, Volumel7, P3133 29 附錄 1:程序 ////// PID運(yùn)算 /////// void pid_ctrl(void) { Ek = ref feb。 PID控制器參數(shù)整定的方法很多,概括起來有兩大類:一是理論計(jì)算整定法。 本設(shè)計(jì)中鍵盤的按鍵直接與單片機(jī)相連,包括按鍵查詢、鍵功能程序轉(zhuǎn)移,作用是 切換 液晶顯示 界面,設(shè)定 或 更改 控制 參數(shù)。 顯示程序:向 LCD送數(shù) 據(jù) 顯示,控制系統(tǒng)的顯示部分。增量型算 法只需知道連續(xù)三個(gè)采樣值的偏差值就能計(jì)算增量輸出。而增量設(shè)計(jì)只與本次的偏差 值有關(guān),與閥門原來的位置無關(guān),因而增量算法易于實(shí)現(xiàn)手動(dòng) /自動(dòng)無擾動(dòng)切換; ( 3) 不產(chǎn)生積分失控,所以容易獲得較好的調(diào)節(jié)效果。 在一個(gè)控制系統(tǒng)中至少由被控對(duì)象、測量變送器、控制器及執(zhí)行器等部分組成。 其 具體電路圖如圖 35所示: 19 圖 35 聲光 報(bào)警電路 電源的設(shè)計(jì) 本設(shè)計(jì)用到兩個(gè)電壓 +5v 和 +12v, 可以分別用 7805和 7812穩(wěn)壓芯片提供。 本設(shè)計(jì)采用蜂鳴器和高亮發(fā)光二極管組成聲光報(bào)警電路。鍵盤可以用來進(jìn)行人機(jī)交流。電機(jī)狀態(tài)參見表 34。 圖 32為 L298N的引腳和外形圖。 DC6V以下能連續(xù)通 電 24小 時(shí)。 本設(shè)計(jì)用到的是家用小水泵(電機(jī))和 水管 等配件 。 位 2~ 0: ADPS2ADPS0位用于選擇 ADC時(shí)鐘 。如果 ADC使能,置位 ADFR,則 ADC功能工作于自由轉(zhuǎn)換方式下。 表 31 ADC通道選擇表 MUX2 MUX1 MUX0 通道選擇 說明 0 0 0 通道 0 模擬信號(hào)從 PA0(ADC0)輸入 0 0 1 通道 1 模擬信號(hào)從 PA1(ADC1)輸入 0 1 0 通道 2 模擬信號(hào)從 PA2(ADC2)輸入 0 1 1 通道 3 模擬 信號(hào)從 PA3(ADC3)輸入 1 0 0 通道 4 模擬信號(hào)從 PA4(ADC4)輸入 1 0 1 通道 5 模擬信號(hào)從 PA5(ADC5)輸入 1 1 0 通道 6 模擬信號(hào)從 PA6(ADC6)輸入 1 1 1 通道 7 模擬信號(hào)從 PA7(ADC7)輸入 12 ? ADC控制和狀態(tài)寄存器 ADCSR(0x06) Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 ADEN ADSC ADFR ADIF ADIE ADPS2 ADPS1 ADPS0 ADCSR用于設(shè)置 A/D轉(zhuǎn)換器的工作方式和頻率。 ADC的時(shí)鐘分頻器的機(jī)構(gòu)。 ATmega16L單片機(jī)的 ADC具有兩種工作方式:單次轉(zhuǎn)換方式和自由運(yùn)行方式。超聲波是一種振動(dòng)頻率高于聲波的機(jī)械波,由換能晶片在電壓的激勵(lì)下發(fā)生振動(dòng)產(chǎn)生的,它具有頻率高、波 長短 、繞射現(xiàn)象小,特別是方向性好、能夠成為射線而定向傳播等特點(diǎn) , 因此 本系統(tǒng)選用了超聲波傳感器 。 在眾多可以探測液位信號(hào)傳感器中,我選用了超聲波傳感器。不使用 ADC時(shí),該引腳應(yīng)該直接與 Vcc連接。其輸出緩沖器具有對(duì)稱的驅(qū)動(dòng)特性,可以輸出和吸收大電流。端口 B也可以用做其他不同的特殊功能。 ( 2) 端口 A( PA7PA0)作為 A/D轉(zhuǎn)換器的模擬輸入端,是 8位雙向 I/O口,具有可編程的內(nèi)部上拉電阻。 另外,本設(shè)計(jì)還實(shí)現(xiàn)了 當(dāng)前液位值 及超限液位報(bào)警 等功能 。同時(shí),對(duì)各功能模塊進(jìn)行軟硬件的設(shè)計(jì)與實(shí)現(xiàn)。 本設(shè)計(jì)的優(yōu)點(diǎn)及其所要實(shí)現(xiàn) 的功能 針對(duì)液位控制過程中存在大滯后、時(shí)變、非線性的特點(diǎn),該數(shù)字 PID控制器可以在線實(shí)現(xiàn) PID參數(shù)和程序的修改,使控制系統(tǒng)的響應(yīng)速度加快,超調(diào)量減少,過渡過程時(shí)間縮短,振蕩次數(shù)減少 等優(yōu)點(diǎn) 。自動(dòng)控制系統(tǒng)可分為開環(huán)控制系統(tǒng)和閉環(huán)控制系統(tǒng)。比如海洋環(huán)境監(jiān)測開始,它是獲取長期、連續(xù)的海洋環(huán)境資料的唯一途徑。 因此, PID液位調(diào)節(jié)器 廣泛應(yīng)用于工業(yè) 生產(chǎn)和日常生活之中。通過數(shù)學(xué) 方法證明,在其他控制方法導(dǎo)致系統(tǒng)有穩(wěn)定誤差或過程反復(fù)的情況下,一個(gè) PID反饋回路卻可以保持系統(tǒng)的穩(wěn)定。 Liquid level control 1 目 錄 1 緒 論 .............................................. 2 研究的目的和意義 ................................................................................................. 2 本設(shè)計(jì)的優(yōu)點(diǎn)及其所要實(shí)現(xiàn)的功能 ..................................................................... 3 本文的主要研究內(nèi)容 ............................................................................................. 3 2 系統(tǒng)工作原理及其總體設(shè)計(jì)方案 ....................... 5 系統(tǒng)工作 原理 ......................................................................................................... 5 總體設(shè)計(jì)方案 ......................................................................................................... 5 3 系統(tǒng)的硬件電路設(shè)計(jì) ................................. 7 核心控制 模塊的設(shè)計(jì) ............................................................................................. 7 ATmega16L單片機(jī)簡介 .............................................................................. 7 ATmega16L單片機(jī)最小系統(tǒng) ...................................................................... 8 液位采集模塊的設(shè)計(jì) ............................................................................................. 9 液位傳感器選擇 ......................................................................................... 9 采集電路的設(shè)計(jì) ....................................................................................... 10 執(zhí)行模塊的設(shè)計(jì) ................................................................................................... 13 水泵的 選