Temperature control system designed using ATmega16L

Publisher:小熊掌心Latest update time:2011-10-06 Keywords:ATmega16L Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1 Introduction

With the advancement of science and technology, the testing industry has developed rapidly. In addition to the continuous expansion of testing items and content, more importantly, testing has become more scientific and functional, mainly reflected in the monitoring and display of the testing process and test results by computers. Multi-point temperature acquisition and control has been widely used in the testing industry in recent years. Among them, the monitoring technology with microcomputer as the core is low-priced, easy to use, and the most widely used.

This article mainly introduces the design of temperature control system based on ATmega16L microcontroller, including the acquisition and control of furnace temperature, LCD display and PC drawing of temperature change curve graph, etc. The hardware and software design adopts modularization concept, and the system integration is high.

2 System Hardware Design

Figure 1 is the overall structure of the system hardware. The system consists of a main controller, a temperature sensor, an operational amplifier circuit, a liquid crystal display circuit, a keyboard circuit, a serial communication circuit, etc. As can be seen from the structure diagram 1, there are many system modules, so the I/O port resources should be allocated reasonably, and each module is connected with the ATmega16L microcontroller as the core.


2.1 Main Controller

The main controller of the system adopts ATmega16L, which is a high-performance, low-power 8-bit AVR microprocessor with advanced RISC structure, large-capacity ROM, RAM, FLASH and EEPROM, integrated 4-channel PWM, SPI serial peripheral interface, and 8-channel 10-bit A/D converter. For the data acquisition system, no separate A/D converter is required, which can save costs. In addition, the microcontroller provides a JTAG debugging interface, and a self-made simple JTAG emulator can be used for program debugging.

2.2 Temperature acquisition circuit

Figure 2 is a temperature acquisition circuit. The circuit is mainly composed of a temperature sensor AD590 and a differential operational amplifier AD524. The temperature sensor AD590 is a new type of two-terminal constant current device. The excitation voltage range is 4 to 30 V, and the temperature measurement range is -55 to +150°C. When the current of AD590 flows through a 5 kΩ resistor, the temperature rises by 1 K, and the voltage on the resistor increases by 5 mV, which is converted to 5 mV/K. Therefore, when the temperature changes between 0 and 100°C, the resistor voltage changes between 1.365 and 1.865 V. The operational amplifier AD524 is used to convert absolute temperature into Celsius temperature.


2.3 Temperature Control Circuit

The circuit is mainly composed of a photocoupler and a thyristor, as shown in Figure 3. The control signal (PWM) sent by the microcontroller controls the working state of the photocoupler after passing through the driver. When the photocoupler works, the trigger pole of the bidirectional thyristor is at a high level, and the thyristor is in a conducting state, thereby controlling the operation of the heating rod.

2.4 Other circuits

(1) The display circuit system has many modules and the I/O interface is tight. The display uses the LCD TCl602A, and the interface adopts the high 4-bit data transmission method.

(2) The keyboard circuit system adopts a non-matrix keyboard, which has a simple structure, is easy to use, does not occupy a lot of I/O, and is suitable for occasions with a small number of keys.

(3) Serial port level conversion circuit Level conversion is completed by the MAX488 device. MAX488 is an RS-488 transceiver with a higher speed than MAX232. It is simple and easy to use, with a single +5 V power supply. A small number of external devices can complete the conversion from TTL level to RS-488 level.

3 System Software Design

The system adopts hierarchical control to ensure the stability of the temperature control system. The lower computer uses ATmega16L microcontroller as the hardware development core and is programmed in C language. The upper computer uses an industrial computer as the monitoring system and is programmed in Visual Basic6.0. RS-488 communication is used between the two layers to achieve data exchange. In the microcontroller part, the software design adopts a modular design method. The entire software can be divided into the main program, key processing program, A/D conversion program, incremental PID processing program, serial communication program and display processing program, data storage processing program, and watchdog processing program.

(1) Main Program The main program of the system mainly completes the initialization operation of each component of the system. In addition, it waits for key processing after the system starts running. Figure 4 is its flow chart.


(2) Key Handler The keyboard handler usually uses a query method to identify keys. Whenever the CPU is idle, it calls the keyboard scanner to query the keyboard, identify the key value, and process it.

(3) A/D conversion program ATmega16 has a 10-bit successive approximation A/D converter including a sample-and-hold circuit. This converter is connected to an 8-channel analog multiplexer and can sample 8 single-ended input voltages from port A. The A/D converter can be started by setting ADEN in the ADCSRA register. Only when ADEN is set, the reference voltage and input channel selection will take effect. Writing "1" to the A/D converter start conversion bit ADSC can start a single conversion. This bit remains high during the conversion process until the conversion ends and an interrupt is triggered. It is then cleared by hardware.

(4) Incremental PID Processing Procedure The temperature control system has hysteresis, time-varying and nonlinearity. It is impossible to establish an accurate mathematical model of the system. Therefore, it is very difficult to achieve satisfactory control effect if conventional linear control theory is used. The use of incremental digital PID controller can solve this problem.

Incremental PID means that the output of the digital controller is only the increment of the control quantity. Since the computer outputs the increment, the impact on the output when it malfunctions is small. The determination of the control increment is only related to the most recent k, k-1, and k-2 samplings, so it is easier to obtain a better control effect through weighted processing. In addition, for digital control systems, due to the limitation of the number of bits of the A/D converter, its output control quantity is limited by the minimum and maximum values, and the system adds the anti-integral saturation method to optimize it. Figure 5 is the program flow of the incremental PID control algorithm.

The following is the program code for incremental PID control:

(5) Serial communication program system uses RS-488 serial data transmission method with the host computer. The microcontroller uses interrupt method to receive data and query method to send data.

(6) Display Processing Program LCD-TC1602A LCD interface design adopts 4-bit control mode, using 4-bit data lines D4~D7 to control the timing of transmission in two times, first transmitting the high 4 bits of data and then the low 4 bits of data.

(7) Data read and write processing program The ATmega16 microcontroller has an internal integrated 512 Byte EEPROM, which exists as an independent data space. The ATmega16 microcontroller reads and writes the EEPROM byte by byte by operating the relevant registers.

(8) Watchdog Handler The ATmega16 microcontroller has an internal hardware watchdog, which is driven by an independent oscillator on the chip. The steps to set the watchdog are: first initialize and turn on the watchdog, and then put the watchdog feeding instruction in the loop program.

4 System Test Analysis

After the test of each module is completed, the lower computer is connected to the PC through the serial port by the hardware of the test end to form a complete temperature test system. The monitoring program written in Visual Basic is run in the upper computer, and the temperature of the heating furnace is set to 80℃ through the keyboard of the lower computer. Click "Open Communication Port", select the port to communicate, and click "Start Temperature Measurement". At this time, the lower computer will send the real-time temperature value to the upper computer and draw the temperature trend curve in real time.

When "End" is clicked, the whole system stops working. The temperature trend curve displayed by the host computer is shown in Figure 6. The test results show that the system is relatively accurate in collecting and controlling the temperature of the heating furnace.

5 Conclusion

The system fully utilizes the internal resources of the AVR ATmega16 microcontroller, and has a high degree of system integration. The system uses an incremental PID algorithm to change the output value of PWM, and then controls the switch of the thyristor, and finally makes the temperature value of the controlled object tend to the given temperature value. The system is easy to operate, reliable, and has high practical value. In terms of its sampling frequency and resolution, it belongs to the medium-speed type, which is suitable for applications where the data sampling frequency requirements are not particularly high.

Keywords:ATmega16L Reference address:Temperature control system designed using ATmega16L

Previous article:Implementation of multi-channel remote control switch encoding and decoding based on AVR microcontroller
Next article:Design of ozone therapy device based on AVR microcontroller

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号