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.
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
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- mmWAVE SDK does not support AWR2243
- I would like to ask about the CORTEXT M0+ memory erase and write problem
- Arteli AT32F4xx_Use of Window Watchdog
- CCS5.2/CCS5.3/CCS5.4 Simulation Debugging Tips
- Bluetooth keyboard driven by nRF52840
- Many people choose ESP32-S2/S3 for design. Let’s discuss the differences between the various product lines of the ESP32 family.
- Happy Mid-Autumn Festival! Chipcoin exchange for mooncakes has started!
- Measure the capacitance ratio of two capacitors, the capacitance is in microfarads
- Analysis of the whole process of IAR microcontroller programming software from project establishment to program burning
- Atom development board module for sale