1 / 13

樂高機器人

樂高機器人. 本周進度. PID 程式練習、波型調整、差分方程式運算. PID 程式練習. 我們先用程式看一個 sin 波微分跟積分後的波型. 藍色: sin 波型 紅色: sin 波積分後波型 綠色: sin 波微分後波型. 波型調整. 再來我們先給輸入一個定值,自已先假設一個差分成程式. clear; py(1)=0; iy(1)=0; dy(1)=0; x(1)=0; y(1)=0; e(2)=5; e(1)=5; for t=2:6280 py(t)=2*e(t);

Télécharger la présentation

樂高機器人

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 樂高機器人

  2. 本周進度 • PID程式練習、波型調整、差分方程式運算

  3. PID程式練習 • 我們先用程式看一個sin波微分跟積分後的波型

  4. 藍色:sin波型 • 紅色:sin波積分後波型 • 綠色:sin波微分後波型

  5. 波型調整 • 再來我們先給輸入一個定值,自已先假設一個差分成程式

  6. clear; • py(1)=0; • iy(1)=0; • dy(1)=0; • x(1)=0; • y(1)=0; • e(2)=5; • e(1)=5; • for t=2:6280 • py(t)=2*e(t); • iy(t)=iy(t-1)+e(t-1)*0.001; • dy(t)=e(t)-e(t-1)/0.001; • u(t)=py(t)+iy(t)+dy(t); • y(t)=0.001*5*u(t-1)-3*0.001*y(t-1)+y(t-1); • yo=y(t); • e(t+1)=x(t)-yo; • end • subplot(311) • plot(e) • subplot(312) • plot(u) • subplot(313) • plot(y)

  7. 差分方程式運算 • 我們輸入值改成給一個sin波

  8. clear; • py(1)=0; • iy(1)=0; • dy(1)=0; • x(1)=0; • y(1)=0; • e(2)=5; • e(1)=5; • for t=2:6280 • x(t)=5*sin(0.001*t); • py(t)=50*e(t); • iy(t)=(iy(t-1)+e(t-1)*0.001)*0.00045; • dy(t)=(e(t)-e(t-1))*0.00000025/0.001; • u(t)=py(t)+iy(t)+dy(t); • y(t)=0.001*5*u(t-1)-3*0.001*y(t-1)+y(t-1); • yo=y(t); • e(t+1)=x(t)-yo; • end • tt=1:6280; • subplot(311) • plot(e) • subplot(312) • plot(u) • subplot(313) • plot(tt,x,tt,y)

  9. 由於在此我們犯一個重大的錯誤,就是導入了錯誤的差分方程式,所以我們的波型追不到輸入的sin波,無法產生正確的波型圖;所以我們要重新推導差分方程式,才能讓程式完成正確的動作。由於在此我們犯一個重大的錯誤,就是導入了錯誤的差分方程式,所以我們的波型追不到輸入的sin波,無法產生正確的波型圖;所以我們要重新推導差分方程式,才能讓程式完成正確的動作。

  10. End

More Related