Design of Temperature Control System Based on Single Chip Microcomputer (Part 2)[Copy link]
1 Keyboard unit In the microcontroller application system, except for the reset button which has a special reset circuit and a dedicated reset function, other buttons or keyboards are used to set control functions or input data based on the switch state. Reliable input of key switch status: In order to remove jitter, I use a software method. When a key is detected to be pressed, a 10ms delay program is executed, and then the key level is confirmed to be still in the closed state level. If the closed state level is maintained, it is confirmed to be a real key pressed state, thereby eliminating the jitter effect In this single-chip computer system of a matrix keyboard and non-encoded keyboard, the keyboard processing program first executes the program segment of waiting for the key to be pressed and confirming whether there is a key pressed. When it is confirmed that a key is pressed, the next step is to identify which key is pressed. There are usually two methods for key recognition: one is the commonly used line-by-line scanning query method; the other is the faster line inversion method. Compare the 4*4 keyboard in the figure to explain the working principle of the line inversion method. First, identify whether there is a key pressed in the keyboard. The microcontroller I/O port sends a full scan word to the keyboard, and then reads the row line status to judge. The method is: output the full scan word 00H to the row line, set all the column lines to a low level, and then read the level state of the column line into the accumulator A. If a key is pressed, there will always be a row line level pulled to a low level so that the row line is not all 1. Determining which key in the keyboard is pressed is achieved by setting the column line to a low level column by column and then checking the row input state. The method is: send a low level to the column line in turn, and then check the status of all row lines. If all are 1, the pressed key is not in this column; if not all are 1, the pressed key must be in this column, and it is the key at the intersection with the zero-level row line. The keyboard has 16 keys for easy temperature setting.
[font=Arial, [Songti]2 Temperature control and over-temperature and over-temperature alarm unit When the collected temperature exceeds the specified upper temperature limit after processing, the microcontroller outputs a control signal through P1.4 to drive the transistor D1, so that the relay K1 turns on the cooling device (compression refrigeration device): When the collected temperature is lower than the set lower temperature limit after processing, the microcontroller outputs a control signal through P1.5 to drive the transistor D2, so that the relay K2 turns on the heating device (heater 1). When the ambient temperature changes too drastically or the heating or cooling equipment fails, or the temperature sensor head fails, resulting in the inability to adjust the ambient temperature to the specified temperature limit within a period of time, the microcontroller drives the speaker through the transistor to sound a siren. The specific circuit connection is shown in Figure 5-1. 3The temperature test unit uses the temperature chip DS18B20. The use of integrated chips can effectively reduce external interference, improve measurement accuracy, and simplify the circuit structure. 4The temperature control device circuit The single-chip microcomputer controls the on and off of the relay through the transistor, and finally achieves the purpose of controlling the electric heater. When the temperature does not reach the requirement, the microcontroller sends a high-level signal to make the transistor saturated and turned on, and the relay connects the power supply to the electric heater, and the electric heater heats up. The temperature rises slowly. When the temperature rises to the preset temperature, the microcontroller sends a low-level signal to make the transistor enter the cut-off state, and the spring of the relay hits the other side, disconnecting the electric heater from the power supply, and the electric heater stops heating. There is a protection circuit for the transistor 8050 in the relay circuit, that is, a diode is reversely connected to the two ends of the transistor. The connection method is shown in Figure 5-2.
The principle is: when the relay is suddenly powered off, the relay generates a large reverse current. The role of the diode is to shunt the reverse current, so that the current flowing through the triode 8050 is relatively small, so as to protect the triode 8050. 5. Seven-segment digital tube display unit This part of the circuit mainly uses seven-segment digital tubes and shift register chip 74LS164. The single-chip microcomputer transmits the data signal to be displayed to the shift register chip 74LS164 for storage through the I2C bus, and then the shift register controls the display of the digital tube, thereby realizing the shift register to light up the digital tube display. Since the clock frequency of the single-chip microcomputer reaches 12M, the shift speed of the shift register is quite fast, so we can't see the data being transmitted one by one. From the perspective of human vision, it seems that all digital tubes are displayed at the same time. See the actual connection diagram as shown in Figure 5-3. When the clear terminal (CLEAR) is low, the output terminals (QA-QH) are all low. The serial data input terminals (A, B) can control the data. When either A or B is at a low level, new data input is prohibited, and Q0 is at a low level under the rising edge of the clock pulse (CLOCK). When one of A or B is at a high level, the other allows data input and determines the state of Q0 under the rising edge of CLOCK. The logic package diagram is shown in Figure 5-3:
Terminal symbols: CLOCK clock input terminal; CLEAR synchronous clear input terminal (low level is valid); A, B serial data input terminals; QA-QH output terminals. Truth table: Table 5-2
6-interface communication unit max232 data introduction: This product is a chip compatible with the RS232 standard launched by Texas Instruments (TI). Since the RS232 level of the computer serial port is -10V +10V, and the signal voltage of the general microcontroller application system is TTL level 0 +5V, max232 is used for level conversion. The device contains 2 drivers, 2 receivers and a voltage generator circuit to provide TIA/EIA-232-F level. The device complies with the TIA/EIA-232-F standard. Each receiver converts the TIA/EIA-232-F level into a 5-V TTL/CMOS level. Each transmitter converts the TTL/CMOS level into a TIA/EIA-232-F level. Main features: 1. Single 5V power supply 2. LinBiCMOSTM process technology 3. Two drivers and two receivers 4. ±30V input level 5. Low power supply current: typical value is 8mA 6. Meet or even exceed ANSI standard EIA/TIA-232-E and ITU recommended standard V.28 7. ESD protection is greater than 2000V of MIL-STD-883 (method 3015) standard 5 1 The microcontroller has a full-duplex serial communication port, so serial communication can be easily carried out between the microcontroller and the computer. When carrying out serial communication, certain conditions must be met. For example, the serial port of the computer is RS232 level, while the serial port of the microcontroller is TTL level. There must be a level conversion circuit between the two. I used a dedicated chip MAX232 for conversion. Although several transistors can also be used for analog conversion, it is still simpler and more reliable to use a dedicated chip. In this design, a three-wire serial port is used, that is, only three wires are connected to the 9-pin serial port of the computer: GND on the 5th pin, RXD on the 2nd pin, and TXD on the 3rd pin. This is the simplest connection method, but it is enough for me. The circuit is shown in the figure below. The 10th pin of MAX232 is connected to the 11th pin of the microcontroller, the 9th pin is connected to the 10th pin of the microcontroller, and the 15th pin is connected to the 20th pin of the microcontroller. The serial port communication is shown in Figure 5-5.
6 Power input part The main control part of the control system needs to be powered by a 5V DC power supply. The circuit is shown in Figure 6-1, which converts a single-phase AC voltage with a frequency of 50Hz and an effective value of 220V into a 5V DC voltage with a stable amplitude. Its main principle is to convert single-phase AC power into stable DC power through power transformer, rectifier circuit, filter circuit and voltage stabilizing circuit. Since the input voltage is the grid voltage, the value of the required DC voltage is generally different from the effective value of the grid voltage, so the role of the power transformer is revealed to play a voltage reduction role. After the voltage reduction, it is still AC voltage, so a rectifier circuit is needed to convert the AC voltage into DC voltage. Since the voltage rectified by the rectifier circuit contains a large AC component, it will affect the normal operation of the load circuit. It needs to be filtered through a low-pass filter circuit to smooth the output voltage. The function of the voltage stabilizing circuit is to make the output DC voltage basically unaffected by the fluctuation of the grid voltage and the change of the load resistance, so as to obtain a DC voltage with sufficient stability. This circuit uses the integrated voltage stabilizing chip 7805 to solve the problem of power supply voltage stabilization. png[/img] 6 Power input part The power supply of the main control part of the control system needs to be powered by a 5V DC power supply. The circuit is shown in Figure 6-1. The single-phase AC voltage with a frequency of 50Hz and an effective value of 220V is converted into a 5V DC voltage with a stable amplitude. Its main principle is to convert the single-phase AC power into a stable DC voltage through a power transformer, a rectifier circuit, a filter circuit, and a voltage regulator circuit. Since the input voltage is the grid voltage, the value of the required DC voltage is generally different from the effective value of the grid voltage, so the role of the power transformer is revealed to play a voltage reduction role. After the voltage is reduced, it is still an AC voltage, so a rectifier circuit is required to convert the AC voltage into a DC voltage. Since the voltage rectified by the rectifier circuit contains a large AC component, it will affect the normal operation of the load circuit. It needs to be filtered through a low-pass filter circuit to make the output voltage smooth. The function of the voltage regulator circuit is to make the output DC voltage basically unaffected by the fluctuation of the grid voltage and the change of the load resistance, so as to obtain a DC voltage with sufficient stability. This circuit uses an integrated voltage regulator chip 7805 to solve the problem of power supply voltage regulation. png[/img] 6 Power input part The power supply of the main control part of the control system needs to be powered by a 5V DC power supply. The circuit is shown in Figure 6-1. The single-phase AC voltage with a frequency of 50Hz and an effective value of 220V is converted into a 5V DC voltage with a stable amplitude. Its main principle is to convert the single-phase AC power into a stable DC voltage through a power transformer, a rectifier circuit, a filter circuit, and a voltage regulator circuit. Since the input voltage is the grid voltage, the value of the required DC voltage is generally different from the effective value of the grid voltage, so the role of the power transformer is revealed to play a voltage reduction role. After the voltage is reduced, it is still an AC voltage, so a rectifier circuit is required to convert the AC voltage into a DC voltage. Since the voltage rectified by the rectifier circuit contains a large AC component, it will affect the normal operation of the load circuit. It needs to be filtered through a low-pass filter circuit to make the output voltage smooth. The function of the voltage regulator circuit is to make the output DC voltage basically unaffected by the fluctuation of the grid voltage and the change of the load resistance, so as to obtain a DC voltage with sufficient stability. This circuit uses an integrated voltage regulator chip 7805 to solve the problem of power supply voltage regulation.