Skip to content

Calculation of Derivative Output #8

@Gord1

Description

@Gord1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions