0 Up votes0 Down votes

27 views10 pagesApr 26, 2012

© Attribution Non-Commercial (BY-NC)

PDF, TXT or read online from Scribd

Attribution Non-Commercial (BY-NC)

27 views

Attribution Non-Commercial (BY-NC)

- Temperature measurement and calibration:
- PID
- Finned Tube Heat Exchanger
- pid
- temperature measurement
- Concentric heat tube exchanger
- temperature
- Temperature Measurement
- 32.05
- Overview of Temperature Measurement
- Lab View
- C Motor Using LabVIEW and Field Point - Developer Zone - National Instruments
- insulation
- Lab View
- Heat Ex Changers
- Insulation Thickness Linelist_update
- Data Sheet - Product Selection and Specification - Thermal Insulation for Piping
- Lab View
- Thickness Calculation
- Heat Exchanger Design Us Units

You are on page 1of 10

Author: N. Abbate

1. INTRODUCTION

Intention of this application note is to explain the implementation of a PID controller using the ST52x420 microcontroller. PIDs have a fundamental importance in the industrial controller field, for the simplicity of approach, the robustness of control and the immediacy of calibration. PID controller is a typology of regulator that implements proportional, integral and derivative action. In fig.1 is shown the control loop of a standard PID regulator. Figure 1. Control Loop

P

u(t)

e dt

e ---t

II

Error(t)

Sensor(t)

Reference In this regulator, the variable error, the derivative and the integral errors are performed to calculate the output variable u(t), function of the above. The PID algorithm is given by:

u (t ) = k p e (t ) + k i edt + k d

e t

where Kp, Ki, Kd are PID gain constants, u(t) is control signal and e(t) is error signal. To convert to discrete form, the integral term e d t is approximated with e i T , where T is the sampling interval and ei is the value of the error signal at sample time i, written as :

e dt e iT

September 2000

1/9

AN1298 - APPLICATION NOTE --If the sampling time is smaller, the differential term -- can be approximated like e t e e ( n ) e ( n 1 ) ----- ---- --------------- ----- -------- -t T

where e(n) and e(n-1) are values of the error signal e at time intervals n and n-1. The PID algorithm can now be approximated in discrete form by:

In this form it is simpler to implement an algorithm. The constants k(p,i,d) can be designed using various methods such as Ziegler Nichols, phase margin, critical frequencies, heuristic etc. The choice between these techniques depends on the type of application because it is extremely different to implement a PID regulator in a system where only the mathematical models is known (i.e. transfers function), or in a non-linear system, where only input/output measures are possible. A brief overview to some of the effects linked to the influence of proportional, integral or derivative action is shown in the following paragraph.

Three are the parameters that influence the performances of a PID controller: Proportional Integral and Derivative constants. Each one has a different impact on the system and an appropriate mix of these three parameters provides a good regulator. However, it is not necessary to use all the parameters at the same time. Proportional actions express the control action proportional to the error. This is very efficient to reduce external noise and disturbance in our system and guarantee stability of closed loop. Integral action is essential to make sure that the process output agrees with the set point in steady state. Derivative action may be interpreted as if the control is made proportional to the forecasted process output, where the prediction is made by extrapolating the error by the tangent to the error curve. Another main parameter is the integration time, but this is already inside the PID regulator. Extremely important is the Wind-up of integral action. When a large error is present in the system, for instance when a large step disturbance is encountered, the integrator continually builds up even though the output is saturated. This condition is called wind up. When the system exits from this condition, the integrator unwinds causing excessive oscillation. This integral PID implementation avoids this problem by stopping the action of the integrator during output variable duty saturation.

3. PID IMPLEMENTATION

ST52x420 has on-chip hardware multiplication between two bytes. This functionality is very important for the correct flow of the algorithm, because the variable error, created from difference between encoder and reference signals in an apposite folder called encoder, is manipulated by the PID regulator to generate the output control signal mainly using multiplication. FUZZYSTUDIO 4 development tool allows to design the regulator in a simple way. The main block of the controller is an ALU block called PID, where the input variable is manipulated and stored, to create the signed-byte control variable appsbyte that increments or decrements the value of the control variable duty. The Instruction set of ST52x420 allows to use different types of variables: word, signed-byte, word and byte. The problem consists in translating the information content in a multiplication between signed-byte and constants (obtaining signed-word variable) in a signed-byte variable. This operation is executed using a scaling between the variable increment (signed-word), using only the high side of double byte that represents the signed-word, and reduce this quantity of a value corresponding to 128; the result is stored in a signed-byte variable.

2/9

4. FUNCTIONAL DESCRIPTION

In this application, an external encoder acquires the angular speed of an asynchronous motor. After the acquisition, and the appropriate conditioning, the signal is stored in the variable speed. This action has been performed with an appropriate procedure called encoder. Figure 2. Speed acquisition task

START

ENCODER (External Timer)

STOP

SPEED COUNTER

PID

SPEED

Inside the interrupt routine of the PWM1 peripheral, a counter is used to modify the sampling time of regulator, to define the opportune integration time for each application. So the real regulators time loop vary from 50s to 50s*counter [byte/word] with an incremental software loop. The control sampling time is synchronized with 20KHz PWM of Timer_1 Peripheral, employed to supply the asynchronous motor with a patented board. Figure 3. PWM configuration

3/9

Figure 4. Interrupt routine PWM1 in FUZZYSTUDIOTM4 implementation

In each controls step, the variable called error (signed-byte), is computed and manipulated to perform the appropriate control law with the following procedure: The acquired signal speed is compared now with the requested reference ref and the difference is stored in the variable called error. An underflow/overflow control is actuated using the preset FUZZYSTUDIO 4 function. A variable called prop implements the proportional action, multiplying the error by the constant Kp. This constant is representative of the proportional PID parameter so like Ki and Kd represents respectively the integral and the derivative parameters, set like constants in FUZZYSTUDIO 4. The integral action is achieved updating the variable integral adding the current value of error; after the overflow/underflow control, the variable integ is computed like Ki*error [signed-word]. In this firmware an integrator anti-windup has already been implemented thus avoiding the wind-up problem by stopping the action of the integrator when the output variable duty is saturated. The derivative action is obtained calculating the difference between the current and the previous step error (error_old). The result is multiplied by Kd to obtain the signed-word der. The actual value of error to be used in the next step is stored in a support variable called error_old. After this phase, summing the quantity above, we obtain a signed-word variable called increment. Now, we need to scale them in a signed-byte with an opportune algorithm to maintain the 16-bit information content in an 8-bit signed variable. So we use a variable called appsbyte to perform an increment or a decrement of the output control variable (precisely the duty cycle of the 20 KHz PWM).

4/9

In the following figure is represented the ALU block inside the firmware that controls the washing machines motor. In FUZZYSTUDIO4 the ALU blocks allow to design a firmware in a C-like coding, with powerful dedicated functions to manipulate byte, word, signed, under/overflow control, peripherals setting, mathematical functions, variable assignation and more. Figure 5. ALU blockPID_Regulator in FUZZYSTUDIOTM4 implementation

This application shows a simple way to implement a PID controller with the ST52x420 micro. Using this approach it is possible to obtain a regulator with performances suited to the application, calibrating the typology of control action in function of the system. The strategy of calibration has not been treated here, but in reference [1] various techniques are discussed in depth. The following figures show the performances of a washing machine motors regulator in start-up condition, changing speed reference on-fly and load variation. This acquisition performed with an on-board serial communication software, represents the comparison between the simultaneous input speed and output duty-cycle of the asynchronous motor driver. The targets achieved are: 1. Reach the reference speed. 2. Noise and error disturbance reduction. 3. Low employment of the micro resources to allow other applications functionalities.

5/9

Figure 6. Start-up

Duty Cycle 250 Speed/Duty Cycle 200 150 100 50 0 0 1 2 3 Time [s] 4

Speed

Ref.

250 Duty Cycle 200

Speed /Duty cycle

Speed

150 100 50 0

0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36

Time [s]

6/9

Figure 8. Step stimulus and load variation

300

Start External Perturbation (Step disturbance)

250

Duty Cycle

Speed

Ref.

200

150

100

50

0

0 9 18 27 0,9 1,8 2,7 3,6 4,5 5,4 6,3 7,2 8,1 9,9 10,8 11,7 12,6 13,5 14,4 15,3 16,2 17,1 18,9 19,8 20,7 21,6 22,5 23,4 24,3 25,2 26,1 27,9 28,8 29,7 30,6 31,5 32,4 33,3 34,2

Time [s]

REFERENCES

[1] K.J. strm, T. Hgglund PID Controllers, 2nd Edition, Instrument Society of America 1995. [2] FUZZYSTUDIO 4.0 User Manual, STMicroelectronics 2000

35,1

36

7/9

//***********************Init*************** error=rif-speed; if(IsOverflow()) error=127; else if(IsUnderflow()) error=-128; //********** Proportional action**************** prop=kp*error; //sword variable=costant*sbyte variable //actual error=reference-actual speed acquisition //error saturation

//************** End_proportional action ****************** //************** Integral action ************************** if(duty<=255) {integral=integral+error; if(IsOverflow()) integral=127; //integral action with anti-windup //actualisation of integral factor //saturation of signed byte variable

//**************** End_integral action******************** //******************** Derivative action ***************** derivative=error-error_old; if(IsOverflow()) derivative=127; //actualisation of derivative component //saturation of signed byte variable

else if (IsUnderflow()) derivative=-128; der=kv*derivative; //*************** End_derivative action ****************** error_old=error; //store actual error for next control step

//*************** Scaling 16bit-->8bit ******************* increment=prop+integ; increment=increment+der; appsbyte=increment.high-128; //sum of component integral and proportional //sum of component derivative //from sword variable to signed byte variable with scaling if(IsOverflow()) appsbyte=127; //saturation of signed byte variable

else if (IsUnderflow()) appsbyte=-128; //******* Compute of actual output variable duty ******** duty=duty+appsbyte; //actual variable if(IsOverflow()) duty=255; else if (IsUnderflow()) duty =0; //******************* End of PID regulator ************* //output variable running from 0 to 255 duty previous duty+actual output control

8/9

Information furnished is believed to be accurate and reliable. However, STMicroelectronics assumes no responsibility for the consequences of use of such information nor for any infringement of patents or other rights of third parties which may result from its use. No license is granted by implication or otherwise under any patent or patent rights of STMicroelectronics. Specification mentioned in this publication are subject to change without notice. This publication supersedes and replaces all information previously supplied. STMicroelectronics products are not authorized for use as critical components in life support devices or systems without express written approval of STMicroelectronics. The ST logo is a trademark of STMicroelectronics 2000 STMicroelectronics - All Rights Reserved FUZZYSTUDIOTM is a registered trademark of STMicroelectronics STMicroelectronics GROUP OF COMPANIES http://www.st.com Australia - Brazil - China - Finland - France - Germany - Hong Kong - India - Italy - Japan - Malaysia - Malta - MoroccoSingapore - Spain - Sweden - Switzerland - United Kingdom - U.S.A. 9/9

This datasheet has been download from: www.datasheetcatalog.com Datasheets for electronics components.

- Temperature measurement and calibration:Uploaded byMorosanu Andreea-Diana
- PIDUploaded byMaintenance Circle
- Finned Tube Heat ExchangerUploaded byanil chejara
- pidUploaded byMohammed Yahya
- temperature measurementUploaded bySushil Goswami
- Concentric heat tube exchangerUploaded byShivani Patel
- temperatureUploaded byRonnie Mangundayao Lagurin
- Temperature MeasurementUploaded byFarrukh Shahzad
- 32.05Uploaded byBrinto Varghese
- Overview of Temperature MeasurementUploaded byReddy Karthik
- Lab ViewUploaded bynjbhange6418
- C Motor Using LabVIEW and Field Point - Developer Zone - National InstrumentsUploaded byMohiuddin Ahmed Ranju
- insulationUploaded byadam150161
- Lab ViewUploaded byNithesh Chakravarthi Nekkanti
- Heat Ex ChangersUploaded byTahir Alam
- Insulation Thickness Linelist_updateUploaded byPankaj Pradhan Patil
- Data Sheet - Product Selection and Specification - Thermal Insulation for PipingUploaded byDaniella Fergusson
- Lab ViewUploaded byBhavin Gajjar
- Thickness CalculationUploaded byAkash Mehrotra
- Heat Exchanger Design Us UnitsUploaded byvvijaybhan
- ThicknessUploaded byrishit_a
- Pipe Thickness CalculationUploaded byAmit Hadke
- exchangersUploaded byPeter Armaos
- InsulationUploaded bySam Choi
- Group 1 Experimental and MeasurementUploaded byDon Pope
- Lab ViewUploaded byPedro Solis
- Thickness(1)Uploaded by123hmag
- Pid Control of Line Following Robot Cheu Kai Wee TJ223.P55.C43 2007Uploaded byUma Mageshwari
- chpUploaded byHamza Moussa

- Declarative IndexesUploaded byNageswara Rao Addala
- decrypt encrypted foldersUploaded bydanny_dan_18
- Winforms & AdoUploaded byMadhuri Kishore
- Hp Laserjet 1160 SpecUploaded bysg06
- X79 Extreme11Uploaded byMehdi FC Braça
- 262778209-Gds-Installation-Manual.pdfUploaded byFlorin Monea
- Voice recognition module vr3 ManualUploaded byMuni Sankar Matam
- USB Connection_rev 20150923Uploaded byAntero Casani
- how to format a computer-windows7-.pptxUploaded byLyndon Alfonso
- npUploaded bysuru_bh25
- SolidityUploaded byCiussepe
- Ct2ea Lcd With Rs 485Uploaded byPrabhu Natarajan
- Section-4-Regression-Testing.pptxUploaded bySyed Usman Ahmed
- C++ProgrammingUploaded byperiketi_prashanth4182
- Verilog Tips & RulesUploaded bySharan Chaitanya
- cutsheet_k4Uploaded byCarlos Bonatto
- PROGRAMMABLE LOGIC CONTROLLERSUploaded bygpz10
- Support Microsoft Com Default Aspx Scid Kb en Us Q315669Uploaded byzet
- User Manual Wireless Space EnUploaded byadrian_dl
- Brosur 2012 Terbaru MaretUploaded byakreditasi
- mini link craft User GuideUploaded byM A Ebeid
- 212 Cloud VirtualizationUploaded byMartin Schweighart Moya
- Clariion SPCollects for CX, CX3, CX4Uploaded byrajib_bd
- Application Control Best PracticesUploaded byKent White
- CoreJava_Uploaded bypolash
- Mload Locks _ Teradata ForumsUploaded bySoumya Ranjan Pradhan
- Chapter 19Uploaded byjeetmajum007
- Hash Example.txtUploaded byprasadpandit123
- opnetUploaded byFadi Shehab
- Log for errorring errorUploaded byAlex Enacica

## Much more than documents.

Discover everything Scribd has to offer, including books and audiobooks from major publishers.

Cancel anytime.