Giter Site home page Giter Site logo

minipid's People

Contributors

tekdemo 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

minipid's Issues

Use PID to control car steering

Hi, I am using this code as my autocar steering PID. Imagine I sit inside the car. My steering target is center of the road 5 meters in front me. I want to steer my car so it points to the target. I use sensor to measure my car current orientation. The different of these two, let's call it D, is how much I want to steer my car. So when I call getOuput, I should use:

steer = getOutput(D, 0)

Correct?

How to set P/I/D parameters

Hi, I am using this code as my autocar steering PID. Imagine I sit inside the car. My steering target is center of the road 5 meters in front me. I want to steer my car so it points to the target. I use sensor to measure my car current orientation. The different of these two, let's call it D, is how much I want to steer my car. So when I call getOuput, I should use:

steer = getOutput(D, 0)

Correct?

Time component for outputRampRate

Nice project congratulation!
I would expect to be possible to acknowledge time component for outputRampRate. Now everything is cpu speed dependent - so if you can include time component - one could be sure that effect of same ramp rate limit will be on fast and slow mcus - theoretically...

So if possible it would be great if you could add dependence to time in uSec (getMicros()).

Why reset the errorSum when the output reaches the maximum value?

I'm trying to use MiniPID as a temperature controller. I measure the current temperature in °C, and drive a PWM (with a value between 0 and 400) relay to heat the space.

For now, I set arbitrary settings for P, I and D, just to see how the system reacts.

I initialize my pid :
pid = new MiniPID(1.0, 0.1, 0.1); pid->setOutputLimits(0.0, 400.0);

and call getOutput() in a loop:
auto out = pid->getOutput(0.0, 20.0);

The value of 'out' increases each time getOutput() is called (2.0, 4.0, 6.0,...) until it reaches the maximum value (400).
The next value will be 4, while I thought it would return 400 forever, until the current value increases (which won't happen in this example, of course).

I think it happens on line 240 of MiniPID.cpp, when errorSum is set to the current error. As the error is lower, the PID returns a lower value.

In my case, it would mean that the setting of the heater would increase up to the max value, then set to nearly 0, and increase again.

Is this behavior expected? Is my understanding of MiniPID correct? Should I use it another way?

Thanks for your help!

JF

Calculation of Derivative Output

Hi,
I like your code and documentation, but I think that you have a few problems in the calculation of your derivative output for the general PID case.

You have:
Doutput= -D*(actual-lastActual);
lastActual=actual;

Your method does provide proper feedback, but only in the case were the setpoint in a constant.

For the general PID case the derivative should be based on the change in error, not the change in sensor (actual) feedback.

It should be written (note no -D):
Doutput = D * (error - lastError);
lastError = error;

If you think about it, if the setpoint changes you want the derivative to kick in and provide more movement to the output. Say the setpoint increases, the change in error increases, therefore the Doutput increases and adds to the output, increasing the motor speed, heating element PWM on time, etc.

Gord_W

Variables related to term I are not being updated when using setPID

When using the setPID () method, the errorSum and maxError variables are not being updated.

This can cause problems in a situation like

m_pid = new MiniPID (10, 0, 0); // I = 0
m_pid-> setOutputLimits (-100, 100); // maxError = 0, maxIOutput = 200
m_pid-> setPID (10,10,10); // maxError continues 0

the output of term I will always be 0 due to the following line

Ioutput=I*errorSum;

.....

else if (maxIOutput! = 0) {
        errorSum = clamp (errorSum + error, -maxError, maxError);
}

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.