With the rapid development of modern information technology, data collection technology is also constantly developing and plays an important role in information technology. Whether data is collected timely and accurately and how the data is collected have become the focus of attention. With the continuous development of embedded technology, various data acquisition systems are continuously used in various fields. Temperature collection is used in smart homes, industrial control, smart agriculture, etc. The lower computer of this temperature acquisition system uses the STC89C52 microcontroller as the main controller and the DS18B20 temperature sensor to collect the temperature. The upper computer uses VB to write programs, collect data through the serial port, store it in the Access database, and display the temperature change curve on the interface in real time.
1 Overall design of the system
The overall block diagram of this temperature acquisition system is shown in Figure 1. The lower computer of the system, the single-chip microcomputer system, uses a ready-made development board. The development board comes with a DS18B20 temperature sensor. The development board also comes with a temperature sensor that can maintain the normal operation of the single-chip computer. Peripheral circuits; Microsoft Visual Basic 6.0 Chinese version integrated development environment and Microsoft Office Access 2003 database development software used in the host computer.
2 Design and implementation of host computer
The main difficulty in the design of the host computer is that the serial port receives data from the host computer and sends the data to the database and displays the data with curves in real time. The overall design flow chart of the host computer is shown in Figure 2.
The Mscomm32.ocx control is mainly used to receive data from the serial port. To add this control in Microsoft Visual Basic 6.0, you need to set the COM port (modifiable), baud rate (9600), data bit (8), stop bit (1), calibration Check bit (0), etc., receive data through OnComm() event-driven method.
The database uses Microsoft Office Access 2003. The database must be established first. The established database is shown in Figure 3. It has 4 fields, namely number, temperature, collection date, and collection time. The corresponding data types are automatic number, number, Text, text.
To operate the database Access programmatically in Microsoft Visual Basic 6.0, first connect the data source, then open the database and set up the corresponding data operations, then update the database, and finally close the database. In the actual operation, the control Adodc is connected to the control Datagrid. , to connect the data source with the interface display.
2.1 Main design steps
1) First create a new EXE project in the VB development environment, and then place some necessary controls on the form, such as button (Command) controls, text boxes (Textbox), etc.;
2) Add Microsoft conmm control 6.0, Microsoft datagrid control 6.0 and Microsoft ADO data control 6.0 to these three controls in the added components;
3) Create a new database in the database software and create a new table temp;
4) Connect to the database Access and test whether the connection is successful;
5) Connect Adodc to Datagrid to connect data sources and interface display;
6) The corresponding functions can be realized by linking the Command button with the search, deletion, modification and addition of the database;
7) Realize the drawing function through the picturebox control;
8) Connect the serial port data with the database and picturebox control.
2.2 Host computer programming (program segment)
2.2.1 Serial port processing program
2.2.2 Write data to the database
3 Design and implementation of slave computer
3.1 Hardware and principles of slave computer
The lower computer of the temperature acquisition system uses the STC89C52 microcontroller as the main controller and the DS18B20 temperature sensor to collect the temperature. The hardware circuit diagram is shown in Figure 4.
STC89C52 microcontroller has:
1) It is a derivative of the MCS-51 series of microcontrollers. It is fully compatible with the standard 8052 microcontroller in terms of instruction system, hardware structure and on-chip resources. The DIP40 package series is Pin-to-Pin compatible with the 8051, making it easy to master when using it;
2) High speed (maximum clock frequency 90 MHz), low power consumption, low price, stable and reliable, widely used, highly versatile, programmable in the system/application (ISP, IAP), and does not occupy user resources. This system uses 1 interrupt, 2 timers and 4 ports P0~P3 of the STC89C52 microcontroller. An external 11.059 2 MHz crystal oscillator is used, and a 30 pF capacitor is used to ground to improve the stability and reliability of the system.
DS18B20 has: 1) Only one I/O port is required to achieve communication; 2) Each device in DS18B20 has a unique serial number; 3) In actual applications, temperature measurement can be achieved without any external components. ; 4) The measurement temperature range is between -55 ~ 125°C; 5) The resolution of the digital thermometer can be selected by the user from 9 to 12 digits; 6) There are internal upper and lower temperature limit alarm settings.
How to use DS18B20: DS18B20 uses the 1-Wire bus protocol. For the microcontroller STC89C52, we must use software methods to simulate the single-bus protocol timing to complete access to the DS18B20 chip. Since DS18B20 reads and writes data on an I/O line, it has strict timing requirements for the data bits read and written. DS18B20 has a strict communication protocol to ensure the correctness and integrity of data transmission. The protocol defines the timing of several signals: initialization timing, read timing, and write timing. All timings use the host as the master device and the single-bus device as the slave device. Each command and data transmission starts when the host actively initiates the write sequence. If the single-bus device is required to send back data, after the write command is issued, the host needs to initiate the read sequence to complete the data reception. Data and commands are transmitted low-end first.
3.2 Software design
The focus of the software design is to collect the temperature and send the collected temperature correctly through the serial port. The software design flow chart is shown in Figure 5.
The software begins to initialize various ports, timers, serial ports, etc., and determines whether an interrupt is generated. If it receives an If the interval is reached, start collecting the temperature and send the data, otherwise continue to determine whether an interrupt is generated.
4 test results
Figure 6 is a rendering of the actual operation of this temperature acquisition system.
5 Conclusion and prospects
This temperature acquisition system can collect the data collected by the DS18B20 temperature sensor through the microcontroller, and transmit it to the host computer in real time using the serial port; the host computer has the ability to receive data in real time, and store the data received in real time into the Access database; it can real-time The temperature curve can be displayed on the interface accurately; the database has four attributes: number, date, time and temperature; the database has the functions of searching, modifying, deleting, adding and searching the first record, next record, previous record and last record; it can Record start time, end time and time difference; display current time and date.
Previous article:Use 51 microcontroller to write an electric small fan solution
Next article:Design of STC8H8K64U microcontroller compatible with STC89C52 development board
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- DALSA P3-80-08K40 Line Scan Camera Teardown
- CircuitPython 6.0.0 Alpha 1 released
- I have a problem with the wire pulling. Version 21. Please help me.
- [ESP32-Audio-Kit Audio Development Board Review] 1. Unboxing photos and official information, first power-on
- EEWORLD University ---- Robust Control Theory
- 【GD32307E-START】+ TFT screen driver and icon interface drawing
- 【AT-START-F403A Review】Part 4: IIC driving OLED screen
- Reading notes on "Operational Amplifier Parameter Analysis and LTspice Application Simulation"
- MSP430 MCU key test KEY function
- MPS430F149 MCU_Wireless transmission module based on MSP430 MCU.c