ELECTRICAL ENGINEERING TECHNOLOGY PROGRAM EET 433 CONTROL SYSTEMS ANALYSIS AND DESIGN LABORATORY EXPERIENCES INTRODUCTION TO DIGITAL CONTROL PART 1: DESCRIPTION OF THE DIGITAL CONTROL SYSTEM 1. INTRODUCTION This set of experiments deal with the subject of Digital Control. Because of time limitations, the lectures in the EET 433 course do not address this type of control. However, I believe that because its importance in industry, students will benefit from being exposed to its principles. I have designed these experiments with the goal of giving students a basic overview of the subject. These experiences are not a substitute for a formal and thorough learning of the theory behind Digital Control. Albert Lozano, July 2008 2.- THE DIGITAL CONTROL SYSTEM The control system that we will be using for these experiences is based on a Basic Stamp module built around a PIC 16C57C microcontroller manufactured by Microchip as seen in the figure below. EET 433 PID Control Part 1 page 1
The Basic Stamp module is based interpreting the code rather than compiling it. This means that when running the program, the Basic Stamp module reads each instruction from its memory in an EEPROM, interprets it and performs the instruction. Once it finishes, it moves to the next instruction and so on. Therefore, a large amount of CPU time is used in reading instructions. On the other hand, it has the advantage of being able to use a very simple language, a form of BASIC that is very easy to learn and use. Given that the goal of this course is not on optimizing code and most control systems have relatively large response times (when compared to the time needed to execute an instruction), it makes sense to use it in these experiments to shift the emphasis on the issues related to control systems rather than programming and using microcontrollers. In an industrial setting, the step to take after having built and developed the appropriate code for a given control system to meet certain specifications using the Basic Stamp module would be to migrate it to a single microcontroller (for example the PIC 16C57). This will result in faster execution times and more importantly, will reduce the cost associated to the hardware for the control system. EET 433 PID Control Part 1 page 2
For these experiments, students will receive the source code and an explanation of how it works. Their interaction with the software will be limited to changing several parameters (constants) and evaluating how they affect the response of the system. 3.- THE GOAL OF THE DIGITAL CONTROL SYSTEM The goal of the digital control system used in this experiment is to maintain a certain environment at a given temperature. In our case, the environment to control is the temperature inside a film canister. There are two elements inside the film canister: - A resistor will be used to apply heat to the interior of the canister. - A LM34 temperature sensor (the same sensor used in one of the labs in EET 331) will be used to monitor the temperature of the canister. The figure below shows a picture of the environment for which we want to control its temperature. EET 433 PID Control Part 1 page 3
Once again, the goal of the system is to maintain a temperature as constant as possible inside the canister even with the presence of external perturbations. We will simulate external perturbations using a small fan as shown below: Controlling temperature is one of the most common requirements in several industrial processes. Industry applications as different as poultry incubators, mixing several molten metals, food processing, cryogenics, etc., rely on systems to measure and evaluate temperature as well as taking the appropriate actions to maintain that temperature in compliance with a set of specifications. 4.- THE ELEMENTS OF THE CONTROL SYSTEM Each one of the modules that make up the digital control system is described in the next sections. Because we will be using the same control system, it is better to leave it built in your breadboard. EET 433 PID Control Part 1 page 4
4.1 The Microcontroller Board As mentioned earlier, the core of this control system is a microcontroller board. It has 16 I/O Ports (P0 to P15). Each port can be configured as an input or as an output. The board is powered by 5 Vdc as shown below. BASIC STAMP MODULE PIC 16C57 Vdd Vss Vin RES P0 P1... P14 P15 5 V PB0 Each one of the pins is labeled in the microcontroller board. These names are reproduced in the figure above. Leave the input labeled as Vin not connected. The microcontroller board communicates with the host computer via a serial cable. PB0 is a normally-open pushbutton. When momentarily pressed, it brings the signal RES to ground, causing a reset in the program being executed by the microcontroller. That is, once it is depressed, the microcontroller will start executing the first program line. Build the circuit shown in the figure above. At this point, you don t connect any of the I/O ports. We will connect the appropriate I/O ports to the appropriate circuits as we build each module that will be used in the control system. EET 433 PID Control Part 1 page 5
4.2 The Heater Heating the canister is controlled by Port8 of the microcontroller as shown below. When P8 is high, there is enough current through the base of the transistor to saturate it, causing the collector voltage to be very close to zero volts. Therefore, the current flowing through the 47 Ω generates power that is dissipated as heat inside the canister. This situation also causes current flowing through LED1, that serves as an indicator of heat ON. 9V 5 47Ω Heating Resistor inside canister 4 To P8 2 470Ω 1 220Ω 3 LED1 0 0 When P8 is low the transistor cannot conduct current and therefore there is no current flowing through the heating resistance. In this case, there is no heat being produced inside the canister. When P8 is low, LED1 is also OFF. Notice that because the microcontroller cannot source or sink the current needed to generate the required heat, it is necessary to use a transistor. In this case, the transistor acts like a current amplifier. This approach is very common for the output ports of a microcontroller as it protects them against over current. Question 1: Calculate the power dissipated by the 47 Ω heating resistor. Question 2: What is the power rating Question 3: How can you reconcile the answers in Questions 1 and 2? What do you expect to happen? EET 433 PID Control Part 1 page 6
Build this module using the schematic above. Connect the 470 Ω and 220 Ω resistors to Port 8 of the microcontroller board. The 47 Ω heating resistor is located inside the canister. Connect one of the wires from the resistor to the 9 Vdc source and the other wire to the collector of the transistor. The following is the pinout for the NPN transistor. 4.3 Manual heat control During the first experiments, when characterizing the system to control (canister), we will turn the heat ON or OFF manually. This is accomplished by the following module: 5V VCC PB1 To P1 6 10kΩ 0 EET 433 PID Control Part 1 page 7
Build the circuit shown above. The 10 kω resistor is connected to Port 1 of the microcontroller (P1). When PB1 is open, there is no current flowing through the resistance and therefore P1 is at zero volts. When PB1 is closed, P1 is directly connected to 5 Volts. This is a widely used circuit to produce digital inputs to the microcontroller. 4.4 The temperature sensor and the Analog-to-Digital converter Temperature is sensed by the LM34 that has a sensitivity of 10 mv/f as you had experienced in the EET 331 laboratory experiences. This temperature sensor is located inside the canister. The color code for the three wires that come out from the canister is: - Red: 5 Vdc - Black: Ground - White: Vout (10 mv/f) Build the circuit shown in the figure below. Connect the three appropriate terminals to ports P3, P4 and P5 of the microcontroller board. RED Temperature sensor inside canister WHITE BLACK The core of this circuit is the ADC 0831 Analog-to-Digital converter. Contrary to the typical A/D converters studied in class, in which the output consists of 8 bits in parallel, the output of this A/D converter is streamed in serial mode through pin 6 (Dout). Although this structure has the drawback of being 8 times slower than a comparable parallel converter, serial A/D converters EET 433 PID Control Part 1 page 8
are normally used when using microcontrollers as it only needs one port of the microcontroller. A parallel A/D converter would need to use 8 microcontroller ports. Pin 1 (CS) is a select pin controlled by port P3 and pin 7 (CLK) is the clock signal generated by the microcontroller to synchronize the transfer of bits. As shown in the circuit above, this A/D converter is a differential converter. This means that the voltage that is actually converted is the difference between pins 2 and 3. We will use this fact to extend the dynamic range for our control system. If we assume that the temperature in the canister will not fall below 70 F (or if it is below this temperature, we will constantly apply heat until it reaches 70 F), the voltage that we will convert in the ADC will be the difference between the voltage at the output of the temperature transducer and the equivalent voltage that is 0.7 V. Adjust the potentiometer connected to Pin3 to 0.70 V. If using this circuit in different days, ensure that the voltage in Pin3 is 0.70 V before starting to work. This sets the zero point at 70 F, and the software will add 70 F to the equivalent readout at the output of the converter. Pin 5 (Vref) is used to set the temperature span. Because we do not expect to expect 120 F, we will set the temperature span to 50 F. Adjust the potentiometer connect to Pin5 to 0.50 V. Once again, ensure that the voltage is 0.50 V each day that you will work with this circuit. In summary, the microcontroller will read a digital value that corresponds to the temperature inside the canister. Moreover, the range of temperatures that are considered valid by this control system are from 70 F to 120 F. 4.5 The brushless fan to create disturbances We will create temperature disturbances by connecting directly the brushless fan to 5 Vdc or to 9 Vdc as indicated by the experiment outline. Do not connect the fan at this moment. EET 433 PID Control Part 1 page 9