标题:
arduino PID库文件下载
[打印本页]
作者:
xiaoyan6hao
时间:
2019-1-10 17:26
标题:
arduino PID库文件下载
arduinoPID库文件
0.png
(6.29 KB, 下载次数: 106)
下载附件
2019-1-10 17:33 上传
3个文件下载(仅供参考,有错误请指出):
PID_v1.rar
(6.84 KB, 下载次数: 146)
2019-1-10 17:25 上传
点击文件名下载附件
下载积分: 黑币 -5
/********************************************************
* PID RelayOutput Example
* Same as basic example, except that this time, the output
* is going to a digital pin which (we presume) is controlling
* a relay. the pid is designed to Output an analog value,
* but the relay can only be On/Off.
*
* to connect them together we use "time proportioning
* control" it's essentially a really slow version of PWM.
* first we decide on a window size (5000mS say.) we then
* set the pid to adjust its output between 0 and that window
* size. lastly, we add some logic that translates the PID
* output into "Relay On Time" with the remainder of the
* window being "Relay Off Time"
PID继电器输出范例
与基本范例相同,这一次输出是一个数字引脚控制的继电器。PID被设计成
输出一个模拟值,但是继电器只有开关状态。
为了联系上两者,我们使用时间比例控制,它本质上是一个很慢的PWM。
首先我们决定一个窗口时间(比如5000ms)。
然后设置PID适应它的输出在0到窗口时间的范围。
最后我们添加一些逻辑,把PID输出转换成“继电器接通时间”和剩余的
“继电器断开时间”
********************************************************/
#include <PID_v1.h>
#define RelayPin 8
// 定义我们将要使用的变量
//Define Variables we'll be connecting to
double Setpoint, Input, Output;
//指定链接和最初的调优参数
//Specify the links and initial tuning parameters
PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);
int WindowSize = 2000;
unsigned long windowStartTime;
void setup()
{
windowStartTime = millis();
//初始化变量
//initialize the variables we're linked to
Setpoint = 100;
//告诉PID在从0到窗口大小的范围内取值
//tell the PID to range between 0 and the full window size
myPID.SetOutputLimits(0, WindowSize);
//开启PID
//turn the PID on
myPID.SetMode(AUTOMATIC);
}
void loop()
{
Input = analogRead(0);
myPID.Compute();
/************************************************
* turn the output pin on/off based on pid output 基于PID输出,打开或关闭端口输出
************************************************/
if(millis() - windowStartTime>WindowSize)
{ //time to shift the Relay Window 继电器窗口时间
windowStartTime += WindowSize;
}
if(Output < millis() - windowStartTime) digitalWrite(RelayPin,HIGH);
else digitalWrite(RelayPin,LOW);
}
复制代码
作者:
ecpc
时间:
2019-1-12 12:52
没有解压密码
作者:
muelfox
时间:
2019-1-14 19:17
谢谢分享
作者:
HeiZu
时间:
2019-5-4 01:27
感谢分享
作者:
kb_001
时间:
2019-7-14 21:24
感谢分享
作者:
Markus0010
时间:
2019-11-1 17:26
谢谢分享
作者:
雷一刀
时间:
2020-2-5 22:58
感谢分享
作者:
way42
时间:
2024-1-17 16:08
楼主,请问为什么PID定义那里编译不过呢?会是什么原因?
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1