This paper proposes a method to export data from the memory and use MATLAB to perform data conversion and drawing. The drawn graphics can well reproduce the analog signal source signal, which is helpful for microcontroller debugging and analysis.
1 Theoretical Analysis
The A/D converter is a bridge connecting analog signals and digital signals. Existing single-chip microcomputer chips usually have built-in ADC modules, and A/D sampling values are usually stored in the on-chip memory in the form of bytes. To draw the A/D sampling data in RAM or Flash, set a breakpoint at the end of the storage during debugging, then export the stored data to the PC in the form of a notepad, design MATLAB software to convert the hexadecimal data in the notepad into decimal data, and finally draw the graph. Compare the drawn graph with the oscilloscope test simulation source graph to verify whether the drawn graph can accurately reproduce the original signal.
2 System Hardware Design
The system structure block diagram is shown in Figure 1. The entire system is designed with the MSP430 microcontroller as the core. This method is universal for other 16-bit microcontrollers. The system samples the data using the on-chip A/D converter and stores it in the RAM area. Then, the debugging breakpoint is set. With the help of the IAR debugging platform, the data is stored in the form of bytes to the PC. After conversion to decimal data by MATLAB, the data is plotted and analyzed, and compared with the waveform of the analog signal source measured by the oscilloscope.
Figure 1 System structure diagram
This system uses TI's single-chip microcomputer MSP430F5438 as the core of this system, and its features are as follows:
◆Reduced instruction set CPU core.
◆12-bit on-chip SAR ADC with programmable conversion rate up to 200 kbps.
◆16 KB internal data RAM and 256 KB Flash memory.
◆Three 16-bit counters with compare capture function, SPI and four general serial communication interfaces.
◆Low power consumption, down to 165μA@8 MHz in active mode, with multiple power-saving sleep and shutdown modes.
3 System Software Design
3.1 A/D sampling storage program
This system uses the A/D module to set the query working mode, the sampling rate is configured to 4 ksps, the conversion resolution is 12 bits, and the internal reference voltage is 2.5 V. Due to the harsh industrial field environment, the collected signals cannot be used directly without processing. Therefore, the collected A/D values are averaged and filtered to prevent the sampled values from jittering. The sampled values are averaged every 16 values and stored in the area with the starting address of 3000H in the RAM area. 157 numbers are stored, and after the data is stored, other digital signal processing processes are transferred. The A/D sampling and storage program flow is shown in Figure 2.
Figure 2 A/D sampling storage program flow
Run the program through the IAR debugging platform, set breakpoints, and save the data stored in RAM to the PC in a notepad file. The data format is shown in Figure 3. The data is stored in word format, that is, two bytes are one A/D conversion value, with the low byte first and the high byte last.
Figure 4: Graph drawn after A/D sampling value format conversion
This paper proposes a method to export data from the memory and use MATLAB to perform data conversion and drawing. The drawn graphics can well reproduce the analog signal source signal, which is helpful for microcontroller debugging and analysis.
1 Theoretical Analysis
The A/D converter is a bridge connecting analog signals and digital signals. Existing single-chip microcomputer chips usually have built-in ADC modules, and A/D sampling values are usually stored in the on-chip memory in the form of bytes. To draw the A/D sampling data in RAM or Flash, set a breakpoint at the end of the storage during debugging, then export the stored data to the PC in the form of a notepad, design MATLAB software to convert the hexadecimal data in the notepad into decimal data, and finally draw the graph. Compare the drawn graph with the oscilloscope test simulation source graph to verify whether the drawn graph can accurately reproduce the original signal.
2 System Hardware Design
The system structure block diagram is shown in Figure 1. The entire system is designed with the MSP430 microcontroller as the core. This method is universal to other 16-bit microcontrollers. The system samples the data using the on-chip A/D converter and stores it in the RAM area. Then, the debugging breakpoint is set. With the help of the IAR debugging platform, the data is stored in the form of bytes to the PC. After conversion to decimal data through MATLAB, the data is plotted and analyzed, and compared with the waveform of the analog signal source measured by the oscilloscope. [page]
Figure 1 System structure diagram
This system uses TI's single-chip microcomputer MSP430F5438 as the core of this system, and its features are as follows:
◆Reduced instruction set CPU core.
◆12-bit on-chip SAR ADC with programmable conversion rate up to 200 kbps.
◆16 KB internal data RAM and 256 KB Flash memory.
◆Three 16-bit counters with compare capture function, SPI and four general serial communication interfaces.
◆Low power consumption, down to 165μA@8 MHz in active mode, with multiple power-saving sleep and shutdown modes.
3 System Software Design
3.1 A/D sampling storage program
This system uses the A/D module to set the query working mode, the sampling rate is configured to 4 ksps, the conversion resolution is 12 bits, and the internal reference voltage is 2.5 V. Due to the harsh industrial field environment, the collected signals cannot be used directly without processing. Therefore, the collected A/D values are averaged and filtered to prevent the sampled values from jittering. The sampled values are averaged every 16 values and stored in the area with the starting address of 3000H in the RAM area. 157 numbers are stored, and after the data is stored, other digital signal processing processes are transferred. The A/D sampling and storage program flow is shown in Figure 2.
Figure 2 A/D sampling storage program flow
Run the program through the IAR debugging platform, set breakpoints, and save the data stored in RAM to the PC in a notepad file. The data format is shown in Figure 3. The data is stored in word format, that is, two bytes are one A/D conversion value, with the low byte first and the high byte last.
Figure 4: Graph drawn after A/D sampling value format conversion
3.2 A/D sampling value data format conversion drawing program
The data format is converted and plotted using MATLAB software, and the plotted graph is shown in Figure 4. The oscilloscope screenshot of the direct measurement of the analog signal source is shown in Figure 5.
Figure 5 Oscilloscope directly measuring analog signal source
By comparing Figure 4 and Figure 5, it can be found that the value converted by A/D sampling data can correctly reproduce the original analog signal. This design method not only makes up for the deficiency that the microcontroller debugging platform cannot directly draw the data in the memory, but also shortens the debugging cycle of the microcontroller system, laying the foundation for subsequent digital signal processing.
Conclusion
This paper discusses the technology of drawing the A/D sampling data stored in RAM or Flash during the debugging process of the single-chip microcomputer, which makes up for the deficiency that the data in the storage area of the single-chip microcomputer debugging platform cannot be directly drawn. The MSP430 single-chip microcomputer was tested as an example. The test results show that the design method is feasible in engineering practice and has high practical value.
Previous article:Design of a low power medical data recorder
Next article:SD storage and applications based on S3C2410
- Popular Resources
- Popular amplifiers
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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Car maintenance oscilloscope detection Volvo S80 fan does not rotate
- The reason why the temperature coefficient of resistance is expressed in positive and negative
- Submit your IoT application ideas and win multimeters, Bluetooth headsets, Xiaomi power strips, JD.com cards and other gifts!
- [Evaluation of Anxinke Bluetooth Development Board PB-02-Kit] First Look
- Can the lower tube in the transistor pair structure have a smaller power?
- [AutoChips AC7801x motor demo board review] + Different PWM configurations for motor control
- Senior FPGA engineers tell beginners...
- In just three steps, we will teach you how to quickly use a multimeter to determine the polarity and type of a transistor!
- Today's Live Broadcast: ON Semiconductor's Advanced Image Sensor Solutions for the Internet of Things
- [Experience] Namisoft reviews the measurement methods of motor torque