Introduction : Currently, most of the main monitoring system software is implemented by configuration software or VB. Configuration software modularizes functions, and for smaller systems, some redundant functions are not used, resulting in a waste of resources. However, VB has limited functions and low operating efficiency. With the popularity of the Windows operating system and its powerful functions, more and more programs support the Windows operating system. Since VC is a Microsoft product, it has a powerful program interface and rich development resources to write Windows programs. In addition, VC has strict memory management, good allocation processing on the stack, small size of generated code, and high stability. Therefore, VC++ has become the mainstream development tool for current programs. This article mainly introduces how to use VC++ to write monitoring programs. This program is used in the data acquisition and wireless transmission system based on Lingyang microcontroller SPCE061A to monitor the data collected on site.
1. System framework and functions of each part
This system is divided into two parts: data collection and transmission part, data receiving part. As shown in Figure 1:
Figure 1 System Block Diagram
Among them: the data acquisition part collects the external voltage value and converts the analog value of the voltage into a digital value.
The wireless transmission module is responsible for sending and receiving the converted digital values.
The display module processes the digital value and displays the measured voltage value.
The data monitoring part processes the data received by the receiving module and displays the measured voltage value.
2. Design of data monitoring program
To realize the data monitoring function, three problems need to be solved:
1. How does the host computer (PC) receive data?
2. How to process the data after receiving it so that the data displayed on the screen is more intuitive.
3. Due to measurement errors, how to use software methods to reduce errors.
2.1 Receiving Data
After the wireless receiving module receives the data from a distance, it sends the data to the serial port of the host computer. The MSComm control provided by VC++ 6.0 sends and receives data through the serial port, providing serial communication functions for the application. When there are characters in the serial port receiving buffer, the OnComm event of the MSComm control can be used to capture and process these data. During the programming process, you can add your own processing code to the OnComm event processing function to process the obtained data.
2.2 Processing Data
The data received from the serial port is a 16-bit binary code. It is not intuitive to display it directly, so it needs to be converted into a voltage value.
2.2.1 . Format of raw data
Because this system collects two channels of data, in order to distinguish which channel the voltage value belongs to, we set the highest bit (15th bit) of the 16-bit binary code as the channel identification bit, 0 represents the first channel and 1 represents the second channel. The 14th to 10th bits of data are useless and are 0, and the 9th to 0th bits are voltage data. The structure is shown in Figure 2:
2.2.2 Data Processing
Assume that the received 16-bit data is X
First determine which voltage data is from: if X ≥ 32768 (the decimal number corresponding to the binary number 10000000000000000), it means the data comes from the second channel. Subtract 32768 from X to get the real voltage data Y, and then calculate the measured voltage value through the formula: the formula is: V=Y*6.6/1024 (this formula is determined according to the voltage acquisition module and will not be described in detail here). If X < 32768, it means the data comes from the first channel, and the voltage value V is directly obtained by the above formula.
2.3 Display voltage value
The program displays the two data in two text boxes, as shown in Figure 3:
Figure 3 Program interface
The first channel is displayed on the left and the second channel is displayed on the right. The data received first is displayed at the top of the text box and the data received later is arranged in sequence below. The text box is cleared when the "Clear" button is clicked.
2.4 Reduce Errors
Since the voltage acquisition module itself has a certain resistance, the voltage measurement value is always smaller than the actual value. We use the software method to multiply the Y obtained in 2.2.2 by a fixed number (this number is set to 1.023 after many experiments) to make the measured value closer to the actual value. The following are the experimental results:
The first A/D conversion is shown in Table 1.
Table 1 A/D1 conversion comparison table Unit: Volt
Actual voltage |
4.902 |
4.466 |
3.970 |
3.570 |
2.996 |
2.462 |
1.994 |
1.550 |
1.042 |
Display voltage |
4.9 |
4.5 |
4.0 |
3.5 |
3.0 |
2.5 |
2.0 |
1.5 |
1.0 |
Receiving voltage |
4.90 |
4.46 |
3.96 |
3.51 |
3.00 |
2.46 |
1.99 |
1.50 |
1.03 |
The second A/D conversion is shown in Table 2.
Table 2 A/D2 conversion comparison table Unit: V
Actual voltage |
4.982 |
4.472 |
4.040 |
3.464 |
2.992 |
2.504 |
1.990 |
1.538 |
0.996 |
Display voltage |
5.0 |
4.5 |
4.0 |
3.5 |
3.0 |
2.5 |
2.0 |
1.5 |
1.0 |
Receiving voltage |
4.98 |
4.47 |
4.03 |
3.47 |
2.99 |
2.50 |
1.98 |
1.53 |
0.99 |
2.5 Flowchart
As shown in Figure 4
Figure 4 Program flowchart
3. Conclusion
This article introduces the design process of the monitoring program based on VC++ in combination with practical applications. The designed program has the functions of receiving data, displaying data, and correcting errors. It has a simple structure, high operating efficiency, and occupies less system resources, which reflects the superiority of VC. In terms of the error correction function, an algorithm can also be designed for the error caused by A/D conversion to make the displayed voltage value more accurate, which will be further studied in the next step of work.
The author's innovation : Unlike most monitoring software that uses configuration software or VB, this article uses VC++ to write the monitoring program.
References :
1 Luo Yafei et al. Application Basics of Lingyang 16-bit MCU. Beijing: Beijing University of Aeronautics and Astronautics Press, 2005.
2 Chen Wei, Chen Faguo, Wang Shixun. Application of wireless data communication technology in TPMS. Journal of Wuhan University of Technology, 2005, 27 (5): 241~244
3 PTR8000.pdf. Xuntong Technology. www.freqchina.com
4 nRF905.pdf. Xuntong Technology. www.freqchina.com
5 Ding Libo, Jiang Xiaohua, Zhang He. Design of data acquisition system based on wireless digital transmission technology. Selection of wireless transmission/reception IC chips and data communication technology (2): 168~171
6 Shi Yunmei, Liu Meiyan, Yang Genxing. Research on Network Resource Management[J]. Microcomputer Information 2006(1);109-11
Previous article:Design and implementation of serial interface between single chip microcomputer and LCD
Next article:Design of high-speed data acquisition system based on MAX114
Recommended ReadingLatest update time:2024-11-16 21:29
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
- AD621 and AD620
- Introduction to the conventional methods and shortcut keys for drawing schematics in KiCad
- When a differential op amp is used as a voltage detector for a battery in a battery pack, what is the output voltage expression? Virtual short: V+=v- ...
- 520 is coming soon, the science and engineering man prepared a hardcore gift for his wife
- Automatic License Plate Recognition System Based on ARM Cortex
- come on
- MM32F103 Development Board Evaluation: User Experience Suggestions
- Why is Ie in this common emitter circuit negative?
- From distributor to service provider, how Avnet deploys the Internet of Things
- [Fudan Micro FM33LC046N] Similar timer module