Sanity Check on PID Controllers

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Sanity Check on PID Controllers

Post by QMESAR »

Hi All.

Please help me out here I am loosing all my faith in my maths ability

I have a SW that I easily can create Graphical user interfaces very similar to LABVIEW,(Graphical programming ) this SW has a PID component (controller block).
my problem is when I use a positive KI coeficient then the controller output is positive and when I use a negative KI then the controller output is negative.This to me is incorrect looking that the method of calculating the controller output,
a negative KI should help to reduce the intergal value and even when the complete term is negative the output should not change to negative as it is first term + Second term for example 2 + -1 = 1 not as in this case from the controller -1

The help file of the component shows this
1.JPG[/attachment Please help to clear my mind that I am not having error thinking in my head ,I fail to see how the second term can change the controller output to a negative when the Error is always positive ,and even when the error is negative a negative KI should not change sign of the output.This is also happening when the error is negative the output changes to a Positive with a negative KI . :oops: I am lost here please put some sanity in this for me [attachment=0]2.JPG
Attachments
2.JPG
2.JPG (39.96 KiB) Viewed 3591 times
1.JPG
1.JPG (22 KiB) Viewed 3592 times

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Sanity Check on PID Controllers

Post by Benj »

Hi Peter,

This is my simple PID formula I worked out at Uni and have implemented in a few places (including the Flowcode DSP Control component), seems to work well and be correct.

The equations they gave to us were horrible but boiling it down to the basics it's not actually that bad.
Error = (Setpoint - Feedback)
PrevError = Error from last cycle
PrevPrevError = Error from two cycles ago

Control Signal = P * (Error - Prev_Error + (Error / I) + D * (Error - (2 * Prev_Error) + Prev_Prev_Error))
Hopefully this should help.

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times

Re: Sanity Check on PID Controllers

Post by QMESAR »

Ben
Thank you very much this is very helpful :)

Post Reply