欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: arduino PID庫文件下載 [打印本頁]

作者: xiaoyan6hao    時(shí)間: 2019-1-10 17:26
標(biāo)題: arduino PID庫文件下載
arduinoPID庫文件


3個(gè)文件下載(僅供參考,有錯(cuò)誤請(qǐng)指出):
PID_v1.rar (6.84 KB, 下載次數(shù): 146)

  1. /********************************************************
  2. * PID RelayOutput Example
  3. * Same as basic example, except that this time, the output
  4. * is going to a digital pin which (we presume) is controlling
  5. * a relay.  the pid is designed to Output an analog value,
  6. * but the relay can only be On/Off.
  7. *
  8. *   to connect them together we use "time proportioning
  9. * control"  it's essentially a really slow version of PWM.
  10. * first we decide on a window size (5000mS say.) we then
  11. * set the pid to adjust its output between 0 and that window
  12. * size.  lastly, we add some logic that translates the PID
  13. * output into "Relay On Time" with the remainder of the
  14. * window being "Relay Off Time"

  15. PID繼電器輸出范例
  16. 與基本范例相同,這一次輸出是一個(gè)數(shù)字引腳控制的繼電器。PID被設(shè)計(jì)成
  17. 輸出一個(gè)模擬值,但是繼電器只有開關(guān)狀態(tài)。
  18. 為了聯(lián)系上兩者,我們使用時(shí)間比例控制,它本質(zhì)上是一個(gè)很慢的PWM。
  19. 首先我們決定一個(gè)窗口時(shí)間(比如5000ms)。
  20. 然后設(shè)置PID適應(yīng)它的輸出在0到窗口時(shí)間的范圍。
  21. 最后我們添加一些邏輯,把PID輸出轉(zhuǎn)換成“繼電器接通時(shí)間”和剩余的
  22. “繼電器斷開時(shí)間”
  23. ********************************************************/

  24. #include <PID_v1.h>
  25. #define RelayPin 8
  26. // 定義我們將要使用的變量
  27. //Define Variables we'll be connecting to
  28. double Setpoint, Input, Output;
  29. //指定鏈接和最初的調(diào)優(yōu)參數(shù)
  30. //Specify the links and initial tuning parameters
  31. PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);

  32. int WindowSize = 2000;
  33. unsigned long windowStartTime;
  34. void setup()
  35. {
  36.   windowStartTime = millis();
  37.   //初始化變量
  38.   //initialize the variables we're linked to
  39.   Setpoint = 100;
  40.   //告訴PID在從0到窗口大小的范圍內(nèi)取值
  41.   //tell the PID to range between 0 and the full window size
  42.   myPID.SetOutputLimits(0, WindowSize);
  43.   //開啟PID
  44.   //turn the PID on
  45.   myPID.SetMode(AUTOMATIC);
  46. }

  47. void loop()
  48. {
  49.   Input = analogRead(0);
  50.   myPID.Compute();

  51.   /************************************************
  52.    * turn the output pin on/off based on pid output 基于PID輸出,打開或關(guān)閉端口輸出
  53.    ************************************************/
  54.   if(millis() - windowStartTime>WindowSize)
  55.   { //time to shift the Relay Window 繼電器窗口時(shí)間
  56.     windowStartTime += WindowSize;
  57.   }
  58.   if(Output < millis() - windowStartTime) digitalWrite(RelayPin,HIGH);
  59.   else digitalWrite(RelayPin,LOW);

  60. }
復(fù)制代碼



作者: ecpc    時(shí)間: 2019-1-12 12:52
沒有解壓密碼

作者: muelfox    時(shí)間: 2019-1-14 19:17
謝謝分享
作者: HeiZu    時(shí)間: 2019-5-4 01:27
感謝分享
作者: kb_001    時(shí)間: 2019-7-14 21:24

感謝分享
作者: Markus0010    時(shí)間: 2019-11-1 17:26
謝謝分享
作者: 雷一刀    時(shí)間: 2020-2-5 22:58
感謝分享
作者: way42    時(shí)間: 2024-1-17 16:08
樓主,請(qǐng)問為什么PID定義那里編譯不過呢?會(huì)是什么原因?




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1