Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

PID algorithm to simulate generator reponse

Status
Not open for further replies.

GeorgeEllwood

Mechanical
Aug 22, 2006
134
Hello,
I'm hoping someone can help me, I'm trying to recreate a PID controlled generator output using a in Fortran.

Here's the code:

error = setpoint - measured_value
integral = integral + (error*dt)
derivative = (error - previous_error)/dt
Output = ((KP * error) + (KI * integral) + (KD *derivative))
previous_error=error

The output from the generator can vary between 0 & 4000Nm. I'm trying to get something to hold at 1.0.
The output from the PID loop is very small ~ 10Nm unless I make the KP term very high ~ 20000000. I seem to have made a fundamental error somewhere but I don't know where.
Can anyone advise?
Thanks
George
 
Replies continue below

Recommended for you

A typical generator governor setting may be:
Proportional band - 3%
Integral - zero
Derivative - zero.

For isochronous operation, dial in a little integral. Look for a correction time of several seconds.

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
Hi Bill,
Thanks for the response. I think I'm some way off getting to the putting in the settings you suggest.
I can't seem to be able to get a sensible output from my PID loop, the numbers it supplies are tiny in comparison to the output they need to supply for the task, so in order to get any reaction I need have a huge value of P. I've made a fundamental error somewhere but I can't see how to fix it.
Thanks
George
 
Maybe your error coming in is not scaled correctly? Seems like your error is a size logrithmic (x10-x) too small.
 
I would use;
I don't do Fortran, but in arithmatic,

For 60 Hz, setpoint = 60 Hz + 3% = 61.8 Hz.
Proportional band = 3%
3% error (1.8 Hz) = 100% output.
Gain and proportional band are reciprocal. If your program wants one and you inadvertantly add the other, you will be a long way out in the wilderness.

Bill
--------------------
"Why not the best?"
Jimmy Carter
 
I'm confused about what you are trying to accomplish.

You have apparently a crude model of a PID controller which is supposed to "control a generator"

Is it controlling the prime mover? What type of prime mover? Do you have model of the system to include things like rotating inertia, power system characteristics?



=====================================
(2B)+(2B)' ?
 
Some diagrams in this link might be useful, if you fancy doing Laplace transforms in Fortran. Sounds like torture to me - easier to buy a piece of software to do the work!

The governor models are from one of the IEEE standards, but I can't remember which one. The standard for the generator and AVR model is IEEE 421 if I recall correctly. You'll need this latter one if you want to model how your machine interacts with the grid.


----------------------------------
image.php

If we learn from our mistakes I'm getting a great education!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor