ControlSim  The PID controller and process simulator based on MS Excel spread sheets.    $45.00 Click here to get more details, buy, and download

Buy and download my eBook: The PID Control Algorithm: How It Works, How To Tune It, and How to Use It. 2nd ed. 62pp
Adobe .pdf file                      only $15

visa-mclogo.gif (2156 bytes) Most major credit cards accepted.
Get more details, buy, and download

PID Algorithm Code - Improved

 

 

 

 

The PID algorithmn in basic code suitable for implementation in Visual Basic or convertable to any programming language.


Buy and download my eBook: The PID Control Algorithm: How It Works, How To Tune It, and How to Use It. 2nd ed. 62pp
Includes expanded information about cascade, feedforward, and other control schemes.
Adobe .pdf file                      only $15

visa-mclogo.gif (2156 bytes) Most major credit cards accepted.
Get more details, buy, and download
ControlSim  The PID controller and process simulator based on MS Excel spread sheets.    $45.00 Click here to get more details, buy, and download

Improved PID code

The method of implementing automatic reset described in using a positive feedback loop was first used with pneumatic analog controllers. It can easily be implemented digitally.

block diagram of PID algorithm

There are several advantages of this algorithm implementation. Most important, it eliminates the problems that cause the output to pull away from a limit inappropriately. It also allows the use of external feedback when required.

Variables:
Input Process input
InputD Process input plus derivative
InputLast Process input
Err Process input
SetP Set point
OutPutTemp Temporary value of output
OutP Output of PID algorithm
Feedback Result of lag in positive feedback loop
Mode value is ‘AUTO’ if loop is in automatic
Action value is ‘DIRECT’ if loop is direct acting

The PID emulation code:

1.  IF Mode = ‘AUTO’THEN
2.     InputD=Input+(Input-InputLast)*Derivative*60  derivative
3.     InputLast = Input
4.     Err=SetP-InputD         Error based on reverse action.
5.     IF Action = ‘DIRECT’ THEN Err=0 – Err Change sign if direct.
6.     ENDIF
7.     OutPutTemp = Err*Gain+Feedback Calculate the gain time the error and add the feedback.
8.     IF OutPutTemp > 100 THEN OutPutTemp =100Limit output to between
9.      IF OutPutTemp < 0 THEN OutPutTemp =0       0 and 100 percent.
10.     OutP = OutPutTemp                           The final output of the controller.
11.     Feedback=Feedback+(OutP - Feedback)*ResetRate/60
12.   ELSE
13.     InputLast=Input  While loop in manual, stay ready for bumpless switch to Auto.
14.     Feedback=OutP
15.  ENDIF

If external feedback is used, the variable "OutP" in line 11 is replaced with the variable containing the external feedback.


ControlSim  The PID controller and process simulator based on MS Excel spread sheets.    $45.00 Click here to get more details, buy, and download

Buy and download my eBook: The PID Control Algorithm: How It Works, How To Tune It, and How to Use It. 2nd ed. 62pp
Adobe .pdf file                      only $15

visa-mclogo.gif (2156 bytes) Most major credit cards accepted.
Get more details, buy, and download

Apartments in Ballantyne in South Charlotte, NC.

Buy and download e-books on other subjects,
such as relationships and making money online Click Here


Mens Divorce Secrets -- Download book for men who may go through a divorce.
The Survey Zone -- Get paid for surveys - $10 to $85 per survey.