仿真原理圖如下(proteus仿真工程文件和完整單片機(jī)C源碼可到本帖附件中下載)
1 (2).jpg (84.21 KB)
下載附件
2021-6-20 23:53 上傳
部分單片機(jī)源碼:
- #include "pid.h"
- #include "huoer.h"
- extern times_A,times;
- float PID_M_Kp =0.1382, PID_M_Ki = 0.001, PID_M_Kd =0.01; //定義 Kp、Ki、Kd 三個(gè)參數(shù)
- float pid_Sv;
- u16 PID_m_add=0,pid_pwm;
- float PID_current_error; //當(dāng)前差值
- float PID_last_error; //上次差值
- float PID_prev_error; //上上次差值
- float integrality_date=0; //積分?jǐn)?shù)據(jù)
- void Motor(u16 std_speed)
- {
- float P,D;//,I;//,I,D; //定義局部變量
- std_speed+=120;
- PID_prev_error=PID_last_error; //更新每次的差值
- PID_last_error=PID_current_error; //更新每次的差值
- PID_current_error=std_speed-times; //更新每次的差值
-
- integrality_date=integrality_date+PID_current_error;
- P=PID_M_Kp*PID_current_error; //比例 P 輸出公式
- // I=PID_M_Ki*integrality_date; //積分 I 輸出公式
- D=PID_M_Kd*(PID_current_error-PID_last_error); //微分 D 輸出公式
-
- PID_m_add=P+D;//+I;//+I+D+PID_m_add; //電機(jī)的 PID 增量值輸
-
- output_pwm(PID_m_add);
- }
- void output_pwm(u16 output)
- {
- if(output>200)output=200; //限制電機(jī)的最大速度
- if(output<1)output=1;
- pid_pwm = output;
- }
- /*/////////////////
- 60 360
- 420 0
- //////////代碼太多放不下,請(qǐng)到附件下載后瀏覽////////
復(fù)制代碼 完整單片機(jī)源碼和proteus仿真文件:
lcd1602霍爾編碼電機(jī).zip
(85.26 KB, 售價(jià): 5 E幣)
2021-6-20 23:55 上傳
點(diǎn)擊文件名下載附件
售價(jià): 5 E幣 [記錄]
[ 購(gòu)買]
【必讀】版權(quán)免責(zé)聲明
1、本主題所有言論和內(nèi)容純屬會(huì)員個(gè)人意見,與本論壇立場(chǎng)無關(guān)。2、本站對(duì)所發(fā)內(nèi)容真實(shí)性、客觀性、可用性不做任何保證也不負(fù)任何責(zé)任,網(wǎng)友之間僅出于學(xué)習(xí)目的進(jìn)行交流。3、對(duì)提供的數(shù)字內(nèi)容不擁有任何權(quán)利,其版權(quán)歸原著者擁有。請(qǐng)勿將該數(shù)字內(nèi)容進(jìn)行商業(yè)交易、轉(zhuǎn)載等行為,該內(nèi)容只為學(xué)習(xí)所提供,使用后發(fā)生的一切問題與本站無關(guān)。 4、本網(wǎng)站不保證本站提供的下載資源的準(zhǔn)確性、安全性和完整性;同時(shí)本網(wǎng)站也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的損失或傷害。 5、本網(wǎng)站所有軟件和資料均為網(wǎng)友推薦收集整理而來,僅供學(xué)習(xí)用途使用,請(qǐng)務(wù)必下載后兩小時(shí)內(nèi)刪除,禁止商用。6、如有侵犯你版權(quán)的,請(qǐng)及時(shí)聯(lián)系我們(電子郵箱1370723259@qq.com)指出,本站將立即改正。
|