Figure 1 System structure diagram
1.1 Signal conditioning circuit
The functions that the signal conditioning circuit needs to complete are: program-controlled amplification and superimposed DC component. The function of program-controlled amplification is: when the amplitude of the input signal is very small, the input signal needs to be amplified so that the measured signal can be displayed as clearly as possible on the LCD. The function of superimposed DC component is: the A/D of ATmega16 is a single power supply, and it is impossible to input negative voltage, while the signal to be measured often has negative voltage. At this time, such a circuit is needed to raise the negative voltage to above the 0 level.
Figure 2 Schematic diagram of signal conditioning circuit
R1 and R2 are connected to different resistors by an analog switch CD4051. Different R1 and R2 can be connected by the formula: In this way, the programmable amplification function can be realized. The adjustable resistor R9 is used to set the size of the DC component added by the signal conditioning circuit. The amplified signal and the DC component are finally superimposed and output by the U3 analog adder.
The relationship between the input signal and the output signal: As long as the resistance values of R4, R6, and R7 are the same, the relationship between the input and output of the conditioning circuit is simplified to: .
Ux is the output voltage of U3, and the voltage value of the output voltage is the same as the voltage of the middle tap of the adjustable resistor R9.
1.2. Main control chip software design
The main control chip of this system is Atmel's AVR series microcontroller ATmega16, which can reach a maximum instruction speed of 16MPIS. ATmega16 has 16K flash, 1K SRAM, 512B EEPROM, and a 10-bit precision successive approximation analog-to-digital converter with built-in sampling/holding circuit. The ADC clock is programmable. In this design, in order to achieve the highest sampling frequency of 100KHz, the ADC clock is set to 2MHz. The trigger source of the ADC is selected as the overflow of timer/counter 0, and the clock source of the timer of ATmega16 is also programmable. In this way, the sampling frequency of the ADC can be controlled by controlling the interrupt frequency of the overflow of timer/counter 0.
Figure 3 Simple oscilloscope system program flow chart
1.2.1 Keyboard Function
There are 7 buttons in this system: run and stop, increase magnification, decrease magnification, increase sampling frequency, decrease sampling frequency, trigger level up, and trigger level down.
Run and stop buttons: This is achieved by turning on and off the ATmega16 ADC conversion completion interrupt.
Increase and decrease of magnification: ATmega16 controls analog switch CD4051 to realize digital control of magnification. CD4051 is an 8-channel analog switch, so the programmable amplifier can have 8 levels.
Increase and decrease of sampling frequency: The sampling frequencies required by the system are achieved by controlling the clock source of ATmega16's timer 0 and the initial value of the timer. The interrupt frequency of timer 0 is equal to the sampling frequency of ADC.
The up and down movement of the trigger level: when the sampled data is digitally triggered, when the binary value of the data increases and the size of a certain data is exactly the same as the binary value of the digital trigger, the waveform data after this will be stored in the display RAM.
When any of these 7 buttons is triggered, the corresponding flag will be set to refresh the corresponding display information on the LCD screen.
1.2.3 Digital trigger function
How to achieve triggering? Using hardware will increase the complexity of the system hardware circuit. I thought of a way to achieve the triggering function with software. The implementation process is as follows:
for (ik=0;ik<500;ik++){
if (k0_ram){
if (box_buff[ik] < trigger) {
kk_ram = 1 ;
}
if (kk_ram){
if ((box_buff[ik] >= trigger) & (ik < 402)){
en_ram = 1 ;
k0_ram = 0 ;
kk_ram = 0 ;
}}}
if (en_ram){
boxing[adc_data]=box_buff[ik];
adc_data++;
if (adc_data > 96){
adc_data = 0x00;
en_ram = 0 ;
}}}
The size of the trigger can be set by pressing the trigger level up and trigger level down buttons.
1.2.3. Restore the waveform
GDM12864A is a dot matrix LCD with 128 dots x 64 dots. According to the characteristics of the selected LCD, there are only 64 dots on the Y axis, so the data range that can be displayed is 0 to 63 and the sampled data is 8-bit binary data from 0 to 255. In order to display it on this LCD, only the upper 6 bits of the 8-bit data are taken. So how to convert the upper 6 bits of binary data into the Y axis coordinates and data values on the LCD? I thought of a calculation method like this:
The vertical direction of LCD is divided into 8 addresses from top to bottom, 0 to 7, and each address segment has 8 data points. If you want to light up these bits from top to bottom in a certain data segment, you need to send data 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80 to this address segment in turn. After sending 0x00, the 8 data points in this address segment will not be lit. The specific process of implementation is shown in Figure 4.
dat = dat>>2 |
y = 7 |
dat >= 8 ? |
dat = dat – 8; y--; |
y == 1 ? |
dat > 7 ? |
dat = 7 ; |
dat = 0x80 >> dat |
write_add(y,x); |
write_data(dat); |
no |
no |
no |
Figure 4 Flowchart of the program to restore data to points on the waveform
1.2.4 ADC sampling frequency control
The sampling frequency of ADC has been mentioned above. The calculation formula of ADC interrupt is: , The frequency can be changed by setting the lower 3 bits CS02, CS01, CS00 of ATmega16's special function register TCCR0. Then, by setting TCNT0 to different values, the sampling frequency values required by this system can be obtained. The data in Table 1 are calculated by the above formula and then debugged and corrected by the actual system.
Table 1 Sampling frequency settings
Sampling frequency (KHz) |
100 |
50 |
20 |
10 |
5 |
2 |
1 |
0.5 |
0.2 |
0.1 |
0.05 |
0.0033 |
TCCR0 |
0x02 |
0x02 |
0x02 |
0x02 |
0x02 |
0x03 |
0x03 |
0x04 |
0x04 |
0x05 |
0x05 |
0x05 |
TCNT0 |
250 |
235 |
204 |
149 |
42 |
189 |
123 |
188 |
89 |
169 |
89 |
4 |
2. System performance indicators and errors
2.1 System performance indicators
The main performance indicators of the system are shown in Table 2.
Table 2 Main performance indicators of the system
System operating voltage |
+5V and -5V power supplies |
Frequency measurement range |
0.33Hz ~ 3KHz |
Voltage measurement range |
10mV ~ 2V |
2.2 System Error
The error of the system mainly comes from the signal conditioning circuit, because the analog switch has a certain internal resistance of about 80Ω, which will have a certain impact on the amplification factor of the conditioning circuit. The resistance value calculated by the calculation formula in 1.1 does not exist in reality, and there will still be a certain error when it is realized by connecting several resistors in series. The balancing resistor R3 is fixed. When R1 and R2 change, the balancing resistor may not be balanced, which will also introduce a certain error to the operational amplifier.
2.3 Areas for improvement
The area where the system can be further improved is the signal conditioning circuit. By selecting analog switches and operational amplifiers with better performance and more reasonable resistor selection, the amplification accuracy of the signal conditioning circuit can be improved, and the performance of the entire system can be further improved.
2.4. Actual working status of the system
The information displayed on the LCD includes the waveform image, the horizontal axis scale on the top of the waveform, the system operation status (Run / Stop) on the right side of the screen, Time is the time length of the entire waveform frame, Volt- is the voltage range, and there is a small dot between the waveform frame and the information frame for the trigger level of the signal. The frequency of the signal = the number of cycles of the signal in the waveform frame / Time.
3. Conclusion
This method can be used to realize a simple oscilloscope. The whole system structure is simple and clear. The internal resources of the AVR microcontroller are fully utilized to simplify the system circuit. Even the system's working clock is built into the AVR. Through testing, the system has a very small error in the direction of measuring frequency, and can be used to measure the frequency of the test signal more accurately.
[References]
[1] Liu Haicheng. AVR MCU Principles and Measurement and Control Engineering Applications [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2008.3.
[2] Gao Jixiang. National College Student Electronic Design Competition Training Series [M]. Beijing: Publishing House of Electronics Industry, 2007.6.
[3] Liu Zugang. Fundamentals of Analog Circuit Analysis and Design [M]. Beijing: Machinery Industry Press, 2007.10.
Previous article:Design of a high-power lead-acid battery charger controlled by P89LPC93X single-chip microcomputer
Next article:Design of LED screen image data decoding based on ATmegal28
Recommended ReadingLatest update time:2024-11-16 19:31
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Metronom Real-Time Operating System RTOS for AVR microcontrollers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
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
- Sketching the halogen lamp driver power supply schematic diagram solution
- Evaluation Weekly Report 20220926: Python Programming Learning Main Control Board, Hangkong Board, Infineon PAS CO2 Sensor Waiting for You to Test~
- [Environmental Expert's Smart Watch] Part 5: Data Communication Design between Devices
- Pocket Experiment Platform for MSP430G2553
- Urgent, help, please help me analyze the circuit, I am confused
- The national competition topic has been released. Have you chosen your topic yet?
- Questions about channel selection and multiplexing
- Memory Technology R&D System Latest Recruitment Information 202010
- What is Wearable Technology
- EEWORLD University Hall----GPS Principles and Applications