×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Resetting Time for Integrator

Resetting Time for Integrator

Resetting Time for Integrator

(OP)
I'm trying to model a PI controller.  

The way it works is that for every 5 minutes of positive error an integrator number is incremented by 1.  I want to know how to "reset" the timer for the discrete-time integrator so that when there is a zero crossing (i.e. positive to negative) a timer will start at 0 (and if it stays at negative for 5 minute) decrease integrator number by 1...

Please help if you can, I am new to Simulink.

RE: Resetting Time for Integrator

What you are trying to do isn't right in so many ways.
The PI equation should be put in an interrupt that occurs every T seconds or minutes. The operating system should take care of ensuring the interrupt occurs at intervals of T.

Never use a timer to activate an even every T.  You will accumulate error between the time the timer expires and the time it is reset.  Use interrupts or a free running clock if you must.

Here is how you implement a simple PI.

E(n)=SP(n)-PV(n)
CO(n)=CO(n-1)+Kc*((T/Ti)*e(n)+(e(n)-e(n-1)))

Where:
n is the period index
E is the error at period n
SP is the set point
PV is the process variable ( feeback )
CO is the control output
Kc is the controller gain
T is time between sample n and n-1.
Ti is the integrator time constant.

One can simplify the equation above
K0 = Kc*(1+T/Ti)
K1 = -Kc
CO(n)=CO(n-1)+K0*e(n)+K1*e(n-1)

Now the PI controller is just a couple of multiplies and adds.  Simple.  It is best to use floating point or at least 32 bit math.  The trick is finding the right values Kc and Ti.




Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources