r-downing / autopid Goto Github PK
View Code? Open in Web Editor NEWArduino AutoPID library
Home Page: https://r-downing.github.io/AutoPID/
License: MIT License
Arduino AutoPID library
Home Page: https://r-downing.github.io/AutoPID/
License: MIT License
Hello! While validating my own PID controller I've been testing against other PIDs available for Arduino. Here's a plot of AutoPID vs. a reference that matches the excellent work done here:
https://github.com/br3ttb/Arduino-PID-Library
The difference is that your D-term has the wrong sign:
https://github.com/r-downing/AutoPID/blob/master/AutoPID.cpp#L62
Compare that to Brett's ArduinoPID:
https://github.com/br3ttb/Arduino-PID-Library/blob/master/PID_v1.cpp#L83
And my FastPID:
https://github.com/mike-matera/FastPID/blob/master/src/FastPID.cpp#L96
Can this library drive a boolean heater as well?
Hello,
I want to use AutoPID for Cooling, What would be the best looking at setBangBang I would have to somehow invert the logic.
What would be the best way to do so?
Kind regards,
Manon
While development in the Arduino environment is fun and certainly has its place, sometimes it is necessary to use more powerful frameworks, such as ESP IDF.
It would be great if this library would be available as an ESP IDF compatible component.
Hey Ryan, Is it just me or the page linked to from this pages Full Documentation (http://ryandowning.net/AutoPID) has a redirect hack on it?
I keep being redirected to
http://ww1.ryandowning.net/?sub1=b0a5465e-46cf-11ed-9b84-64fbf2c10ea3
Then some article on the domain
https://businessinsiders.pro/
I have found the document at through google.
https://r-downing.github.io/AutoPID/
The line
Line 61 in fea6b99
setMaxIntegrator (100)
?Hello!
I'm the developer of FastPID (https://github.com/mike-matera/FastPID). I've developed simulation models to test the correctness of my controller. As a part of that process I've tested its performance against your PID and I've found errors in your example code.
Here's how AutoPID performs against a reference implementation:
The problem is that your PID controller produces differential values, but you are not summing those values into an accumulated output. The problem can be fixed in BasicTempControl.ino by the following change to loop():
void loop() {
static unsigned long int accumulator = 0;
updateTemperature();
setPoint = analogRead(POT_PIN);
myPID.run(); //call every loop, updates automatically at certain time interval
accumulator += outputVal;
analogWrite(OUTPUT_PIN, accumulator);
digitalWrite(LED_PIN, myPID.atSetPoint(1)); //light up LED when we're at setpoint +-1 degree
delay(4000); // Must not over accumulate!
}//void loop
While your PID implementation is correct according to references like Wikipedia, those control systems are designed to actuate a physical valve. The PID output drives a motor that changes the valve and the state of the valve is a form of memory. The analogWrite()
function has no memory so the valve state is simulated with the accumulator
variable.
It is very likely that many users have this issue and don't know it.
It appears that the equation for the derivative error (line 62) uses the wrong operator to convert from milliseconds to seconds. The integral error (line 60) uses Seconds (_dT / 1000) as the time unit, but the derivative error uses Microseconds (_dT * 1000).
I think the correct formula would include a pair of brackets as follows in order to keep the units consistent with the integral error:
double _dError = (_error - _previousError) / (_dT / 1000.0); //derivative
In order to use multiplication instead of division, the formula could be rewritten as follows:
double _dError = (_error - _previousError) * 1000.0 / _dT; //derivative
Is it possible to turn off the bangbang control e.g. in the setBangBang function?
Thanks!
Can the PID tune itself?
Are there any hints?
I've got a thermobox, with a pelter element I can control the heat/cool from -1024 to 1024 with pwm.
An oscilation time of around 5 minutes and an overshoot of 1.5C if I go from full heat to full cool around the setpoint (unrealistic, but to find the parameters of the system)
Hello, would it be possible to provide a working example of the AutoPID library using the AutoPIDRelay functions?
Hi, How can i use autopid to control digital output like relay or Solid State Relay? It will be very helpfull if the library has seconde exemple witch use digital output.
The Relay output does not correctly operate. The instruction while should be if...
See example below...
void AutoPIDRelay::run() {
AutoPID::run();
if ((millis() - _lastPulseTime) > _pulseWidth) _lastPulseTime += _pulseWidth;
*_relayState = ((millis() - _lastPulseTime) < (_pulseValue * _pulseWidth));
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.