1 / 14

# Advanced Embedded Systems Design - PowerPoint PPT Presentation

Advanced Embedded Systems Design. Lecture 14 Implementation of a PID controller BAE 5030 - 003 Fall 2004 Instructor: Marvin Stone Biosystems and Agricultural Engineering Oklahoma State University. Goals for Class Today. Questions over reading / homework ( CAN Implementation )

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Lecture 14 Implementation of a PID controller

BAE 5030 - 003

Fall 2004

Instructor: Marvin Stone

Biosystems and Agricultural Engineering

Oklahoma State University

BAE 3023

• Questions over reading / homework (CAN Implementation)

• Zigbee and 802.14.5 – (Kyle)

• PID implementation (Stone)

BAE 3023

• Review elements and variables

BAE 3023

Output (qout) is readily calculated as a function of:

Setpoint (qset)

Manipulation is a simple function of the controller TF and error.

BAE 3023

• If sampling rate is fast and holds are employed, this system approaches the analog system

BAE 3023

One of the conventional models used to express a PID controller is:

Where:

BAE 3023

A convenient way to implement this equation in a controller is as the derivative of manipulation known as the velocity form of the equation as shown below:

In a practical system this equation will work well and does not require any steady-state references, but eliminating the ti and td term completely results in:

or,

This equation has no positional reference and error accumulation is a problem. Use velocity form only for PI or PID modes.

BAE 3023

To begin the conversion of the PID equation to a difference equation, the equation is multiplied by dt.

Note that since M is a differential and ess is zero, this equation conveniently applies to the absolute variables as well as the deviation variables.

For small Dt, the equation can be approximated as:

BAE 3023

The equation can be simplified with the assumption that Dt is constant:

Each of the differences (D) can be expressed as discrete values of each of the variables (m and e ) at the times 0, 1, and 2 as shown below:

BAE 3023

Replacement of the differences (D) with the discrete

variables ( m ande ) results in:

Note that Dt is assumed to be a constant. If Dt varies, the equations should be derived with that in mind.

BAE 3023

This equation can be solved for the current manipulation, m2, in terms of values known at time t2: m1,e2, e1, and e0.

The other parameters in the equation are constants.

or,

Where C1,C2, and C3 are constants and the current manipulation is expressed in terms of known values, the current and past errors.

BAE 3023

This equation may be translated directly into a computer language, for example:

m2 = m1 + k*(C1*e2 – C2*e1 + C3*e0);

Within a computer program, the current error

is calculated from the current measurement of

the controlled variable and the setpoint, for example:

e2 = T_setpoint – T_measured;

The current manipulation m2 is then computed using the previous controller equation, and finally, at the end of the time step, each of the variables is shifted forward for the next calculation.

BAE 3023

For example in C, the code might look like:

measure_and_manipulate() //Call once per delta T

begin

T_measured = measure_T(); //Get the measured temperature

e2 = T_setpoint – T_measured //Calculate the current error

m2 = m1 + k*(C1*e2 – C2*e1 + C3*e0); //Calculate the manipulation

set_manupilation(m2); //Output the manipulation

e0 = e1; //Shift the error and manipulation

e1 = e2; //forward one time step

m1= m2;

end;

Note that the time step Dt is controlled by the time required to execute the loop. C1,C2 and C3 are all functions of Dt. The equation will probably be executed as floats! (Or very special care must be taken with scaling.

BAE 3023

• Complete CAN message demo

• Turn in course portfolio by 5:00 PM Wednesday Dec. 8th

BAE 3023