Sie sind auf Seite 1von 17

Process Temperature Control Using PID and LabVIEW

Problem Peter was asked by his science teacher to incubate a few chicks for a science project. After searching through some websites, he found the following information:

Maintain the temperature in the 37.2-38.2 C temperature range (37.7-38.3 C, if possible). Overheating the embryo is much more damaging than is under heating it; overheating speeds up embryo development, lowers the percentage of hatchability, and causes abnormal embryos. Long periods of low temperatures will reduce the rate of embryo development. Excessively low temperatures will kill the embryos. Avoid temperatures outside the 36.139.4 C. range. If the temperature remains beyond either extreme for several days, hatchability may be severely reduced.

Can you help Peter?

Objective
y y y

Learn Interfacing Electronics to the USB Data Acquisition Module. Control Lamp output using PWM (Pulse Width Modulation) Using PID VI Prerequisite

Must be familiar with Data Acquisition and LabVIEW (preferably have completed the exercises in the Build the Light Intensity

Logger instructional guide)


y

Basic electronics (simple resistor and transistor circuits - preferably have breadboarded simple circuits before) You should have the following folder PID Temperature Control. Folder available for customers only.

Part List
y y y y y y y

EMANT300 Low Cost USB DAQ module Protoboard or Solderless BreadBoard R1 1.5K 1/4W resistor RT1 Thermistor 10K NTC Q1 MPSA13 Darlington R2 22ohm 3W resistor R3 220 1/4W resistor

y y

D1 LED LabVIEW Development System ver 7.0 or later Warning: The information described is for instructional use only.

PID Control Solution One way to heat up the incubator would be to use a heating element. However, it is difficult to keep the temperature fairly constant using a lamp without some form of control. In our exercise, we will make use of a 22ohm 3W resistor to simulate the heating element.

A basic control solution comprises the following

We measure the temperature using a thermistor and heat up the incubator using a 22 ohms 3W resistor. We will use the proportional (P), the integral (I), and the derivative (D) controls (PID Control).

PID Control

First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above. The variable (e) represents the tracking error, the difference between the desired input value (R) and the actual output (T). This error signal (e) is sent to the PID controller. The signal (u) output from the controller is equal to the proportional gain (Kp) times the magnitude of the error plus the integral gain (Ki) times the integral of the error plus the derivative gain (Kd) times the derivative of the error.

y y y

Kp = Proportional gain Ki = Integral gain Kd = Derivative gain This signal (u) will be sent to the lamp, and the new output (T) will be obtained. This new output (T) will be sent back to the sensor again to find the new error signal (e). The controller takes this new error signal and computes its derivative and its integral again. This process goes on and on.

A proportional controller (Kp) will have the effect of reducing the rise time and will reduce, but never eliminate, the steady-state error. An integral control (Ki) will have the effect of eliminating the steady-state error, but it may make the transient response worse. A derivative control (Kd) will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response.

The PID.vi has already been created for you. Go to the PID Temperature Control folder and open PID.vi Study the VI if you wish. It is basically our LabVIEW implementation of the above formula. Thermistor

Thermistors are widely used because of their sensitivity, small size, ruggedness and low cost. Thermistors have an electrical resistance that varies non-linearly with temperature. The Resistance -Temperature

characteristics of most thermistors One way to heat up the incubator would be to use a heating element. However, it is difficult to keep the temperature fairly constant using a lamp without some form of control. In our exercise, we will make use of a 22ohm 3W resistor to simulate the heating element.

A basic control solution comprises the following

We measure the temperature using a thermistor and heat up the incubator using a 22 ohms 3W resistor. We will use the proportional (P), the integral (I), and the derivative (D) controls (PID Control).

PID Control

First, let's take a look at how the PID controller works in a closed-loop system using the schematic shown above. The variable (e) represents the tracking error, the difference between the desired input value (R) and the actual output (T). This error signal (e) is sent to the PID controller. The signal (u) output from the controller is equal to the proportional gain (Kp) times the magnitude of the error plus the integral gain (Ki) times the integral of the error plus the derivative gain (Kd) times the derivative of the error.

y y y

Kp = Proportional gain Ki = Integral gain Kd = Derivative gain This signal (u) will be sent to the lamp, and the new output (T) will be obtained. This new output (T) will be sent back to the sensor again to find the new error signal (e). The controller takes this new error signal and computes its derivative and its integral again. This process goes on and on.

A proportional controller (Kp) will have the effect of reducing the rise time and will reduce, but never eliminate, the steady-state error. An integral control (Ki) will have the effect of eliminating the steady-state error, but it may make the transient response worse. A derivative control (Kd) will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response.

The PID.vi has already been created for you. Go to the PID Temperature Control folder and open PID.vi Study the VI if you wish. It is basically our LabVIEW implementation of the above formula. Thermistor

Thermistors are widely used because of their sensitivity, small size, ruggedness and low cost. Thermistors have an electrical resistance that varies non-linearly with temperature. The Resistance -Temperature

characteristi

the Steinhart-Hart equation can be described by the Steinhart-Hart equation:

1/T = A + B*(Ln RT) + C*(Ln RT)3

RT is the resistance of the Thermistor, T is the absolute temperature (in Kelvin) and A, B, and C are constants which can be determined by measuring calibration. three sets of resistance and temperature values during

Most thermistors have a negative temperature coefficient (NTC), their resistance decreases with increasing temperature. Thermistors are specified according to its nominal resistance at 25 oC and commonly available thermistors range from 250 ohms to 100 kohms

The thermistor that we are using has the following characteristics

y y

Nominal resistance @ 25 oC: 10 kohms negative temperature coefficient (NTC)

As the DAQ module Analog Input measures only voltage, we will need to provide a current source to convert the resistance to voltage. We will use the 8 bit current DAC (digital to analog converter) and set the current to 100uA.

As the thermistor VI has been already developed and explained in the application note Measuring Temperature using Thermistor, we will use the sub VI Temp Control Thermistor.VI

Heater We will be using a 22ohm 3W resistor to act as the heating element. To reduce the heat from the electronics, we will drive the resistor by PWM (Pulse Width Modulation) using a darlington NPN transistor.

A PWM circuit works by making a square wave with a variable on-to-off ratio; the average on time may be varied from 0 to 100 percent. In this manner, a variable amount of power is transferred to the load.

The main advantage of a PWM circuit over a power amplifier is the efficiency. At a 50% level, the PWM will use about 50% of full power, almost all of which is transferred to the load.

The darlington transistor is used over a regular NPN transistor to reduce the current output requirement of the digital output.

Build the PID Temperature Control circuit Construct the following circuit either using a solderless breadboard or a protoboard.

Parts List

y y y y

R1 1.5K 1/4W resistor RT1 Thermistor 10K NTC Q1 MPSA13 Darlington R2 Heating Resistor 22 ohm 3W Optional Components

y y

R3 220 1/4W resistor D1 LED

Connection diagram

Circuit constructed using ProtoBoard

1. DO NOT CONNECT THE EMANT300 TO THE USB PORT YET. 2. Connect the components. Take note of the connections for the transistor. Connect the 22 ohm load resistor and thermistor in a way that they make good thermal contact. 3. Connect to the EMANT300. If you are using the Light Application Adaptor. PWM, IDAC, AIN3, VDD, GND are available as screw terminals. Note: If you are using the Light Application Adaptor, REFIN- is already connected to AGND. If you are connecting directly to the EMANT300, it is important that this connection is made, otherwise your analog input measurements will be wrong. This connection allows the internal reference to be connected correctly.

4.

Connect the EMANT300 to the USB port.

5.

Open Temperature Control for Hatching Chicks.vi from the PID Temperature

Control folder. You will use this VI to verify that your circuit is built correctly. LabVIEW Front Panel

LabVIEW Block Diagram

1. The VI first configures the EMANT300 to use the PWM output rather than the counter. 2. The sub VI Temp Control Thermistor.VI returns the temperature in Celsius as measured by the thermistor. 3. In normal operation, this measured temperature value is then compared with the set value to generate the PID output. 4. The PID output is between 0 to 100% and is used to drive the PWM output. 5. The VI also allows you to control the heater output manually by setting the manual override. Note that setting the PWM output to 0 turns off the heater and 100 turns on the heater completely. 6. One way to check the your circuit is to observe the temperature when you change the PWM output. The temperature should change. If you have

connected the optional LED, the LED intensity should also change as you adjust the heater output. 7. As the load resistor is not designed to be a heating element, you may not be able to heat up the area around the thermistor to above 38 C (this will depend on the environment of the room you are working in). 8. Click the Run button to run the VI.

9. Switch the Manual Override down. This will set the heater output to manual override. When you change the manual heater setting dial, the gauge output and the LED intensity will change. If you observe the LED intensity changing,your circuit is connected OK. 10. Set the PWM to 0. Call the temperature measured Tamb. Set the PWM

to 100. Call the temperature measured Tmax. 11. Observe the temperature reading, is it giving the correct values? If

yes, then you are ready to set the temperature and put the heater under PID Control. Set the control temperature between Tamb and Tmax that you measured earlier. Use the P, I and D values as shown in the front panel. 12. You can experiment with different set points as well as different PID

values. To understand how to set the PID values is outside the scope of this exercise but information on PID tuning is readily available from the web or textbooks on control.

13.

Press

to stop the VI.