Code Monkey home page Code Monkey logo

autopid's People

Contributors

r-downing avatar sixtyfive avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autopid's Issues

Wrong sign on the derivative term.

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

figure_1-3

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

Documentation issue: Cooling Howto

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?

  • set OUTPUT_MIN to 100% and OUTPUT_MAX to 0% ?
  • Or to multiply the all values with "-1" (input and setpoint) ?

Kind regards,
Manon

Make this library available as ESP IDF component

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.

Why is the maximum Integral disabled?

The line

//_integral = constrain(_integral, _outputMin/_Ki, _outputMax/_Ki);
which contains the Integrator max is disabled. I'm curious why? Is there some inherent problem I'm not aware of? Furthermore, would you accept a PR for a function like setMaxIntegrator (100) ?

Example code produces incorrect results.

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:

figure_1

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.

Derivative error time factor equation

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

Turn of Bang-Bang

Is it possible to turn off the bangbang control e.g. in the setBangBang function?
Thanks!

How to tune the parameters. AutoTune?

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)

Relay temperature control

Hello, would it be possible to provide a working example of the AutoPID library using the AutoPIDRelay functions?

AutoPID SSR

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.

AutoPIDRelay output not reflecting the getPulseValue();

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));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.