Abstract: This article introduces a low-cost A/D conversion circuit and method based on AT89C1051/2051. This circuit uses general-purpose, cheap devices, uses linear sawtooth waves and the timer inside the microcontroller to obtain the A/D conversion results, and has a simple interface with the microcontroller. In addition to achieving a faster conversion speed using this method, the conversion resolution can also be set flexibly, which has certain practical value.
In the design process of low-cost intelligent instruments, the priority is the cost issue. As the core component, the single-chip computer usually uses a low-end 8-bit computer or a 4-bit computer. As far as the current situation is concerned, low-end single computers with built-in A/D conversion are expensive, and when data collection is required, external A/D conversion devices are often used, which greatly increases the cost of the system. For example, the current retail price of AT89C2051 microcontroller is only 7 to 8 yuan, while the price of medium-speed A/D conversion devices is mostly more than 20 yuan. The low-cost A/D conversion method introduced in this article can achieve medium-speed A/D conversion speed and less than 16-bit conversion resolution using only two general-purpose, cheap devices.
1 Principle
There is a sawtooth wave signal with good linearity, the maximum amplitude is Vmax, the scanning time of the positive path (0 ~ Vmax) is t2 (straight line OB in Figure 1), the voltage Vt corresponding to a certain moment t during the positive scanning period is Vmax (t/t2). The curve CD in Figure 1 is an analog signal to be measured. The two signals intersect at point A and the time is t1. It is not difficult to understand that the amplitude of the linear sawtooth wave at point A is the size of the analog signal to be measured, and its value Vt1 can be expressed It is: Vt1=Vmax(t1/t2). That is to say, a method can be used to compare the analog signal to be measured with the linear sawtooth wave. When the amplitude of the linear sawtooth wave exceeds the amplitude of the analog signal to be measured at a certain moment, it will cause the comparator output state to change. Therefore, by measuring the time when the comparator output state flips, the size of the analog signal to be measured can be calculated.
2 Circuit and A/D conversion process
Figure 2 shows an A/D conversion circuit with 8-bit resolution. In the figure, IC1 is the AT89C2051 microcontroller. In addition to the functions of general I/O port lines, IC1 is also the non-inverting input terminal and inverting input terminal of the internal analog comparator. The output result of the comparator is internally Connect to P3.6. IC2 and IC3 are linear sawtooth wave generating circuits, and the moment when they start scanning is controlled by P3.7 of the microcontroller. IC3 is a dual-input NAND gate buffer driver, which is equivalent to a switch here. When P3.7=0, the switch is turned off, C1 is charged through R1 and W1, the linear sawtooth wave begins to scan in the normal process, and at the same time, the internal timer 0 of the microcontroller starts counting, and the counting pulse is the internal clock of the microcontroller. The analog signal to be measured is input from P1.1. Because the linear sawtooth wave voltage increases linearly from 0, P3.6 is 0 at the beginning of the normal scan. When the sawtooth wave voltage linearly increases to exceed the value to be measured When the voltage of the analog signal is simulated, the output of the comparator flips and P3.6 is 1. At this time, the value of timer 0 is the result of A/D conversion, which is t1 shown in Figure 1. It can be obtained by the previous formula The value of the analog voltage to be measured. Its program block diagram is shown in Figure 3.
3. Determination of linear sawtooth wave circuit parameters
Timer 0 of the AT89C2051 microcontroller is a 16-bit counter, so the highest resolution that this method can achieve is 16 bits, and the longest time to complete an A/D conversion at the highest clock frequency (24MHz) is about 33ms. In actual applications, such a high resolution may not necessarily be used. The longest time to complete an A/D conversion is 128 μs at 8-bit resolution. The following uses 8-bit resolution as an example to introduce the method of determining sawtooth wave circuit parameters.
For the circuit in Figure 2, when the output of P3.7 is low, the sawtooth wave normal scan begins, C1 is charged through R1 and W1, and its voltage Vc1 is:
V c1 =V cc ×(1-e-(t/τ))
Where τ = (R 1 +R w1 ) C 1
If op amp IC2:B amplifies V c1 10 times, its output is:
Vo1=[1+(R 3 /R 2 )]V c1
=10V cc (1-e-(t/τ))
Because the output of IC2:B is not a linear sawtooth wave, a level of IC2:A is added for nonlinear compensation, and its output voltage V o2 can be expressed as:
V o2 =V i2 =(V o1 +V c3 )/2
=[10V cc (1-e-(t/τ))+V o2 (1-e-(t/η)12)]/2
In the formula: Vcc=5V; η=(R5+Rw2)C3
After sorting the above formula, we can get:
V o2 =50(1-e-(t/τ))/(1+e-(t/η))
The above formula is the theoretical expression of a linear sawtooth wave. By reasonably selecting the values of τ and eta, a sawtooth wave with good linearity can be obtained.
In actual design, we can use a C language program to theoretically obtain the optimal values of τ and eta based on the above formula, and then adjust them based on the experimental results. The procedure is as follows:
#include
#include
int main(void)
{
int τ=640, η=610; /*Preset the values of τ and η*/
double result,result-bak=0;
double t,x,y;
system("cls"); /*clear screen*/
for(t=0;t<=127;t+=0.5)/*At 8-bit resolution, the positive path of the sawtooth wave is 128 microseconds*/
{
x=-t/τ;
y=-t/η;
result=50*(-exp(x))/(1+exp(y));
printf(“%4fmV”,(result-result-bak) 1000);/*Increasing voltage (mv) every 0.5 microseconds*/
result-bak=result;
}
}
When τ=640μs, η=610μs, through the above programming process, the sawtooth wave can be made very close to linear, and the linear error per μs is within 0.1mV, which can fully meet the requirements of 8-bit resolution A/D conversion.
4 Error analysis and compensation
There are two main sources of errors in A/D conversion using this method. The first is the error caused by the nonlinearity of the sawtooth wave. According to the above description, the nonlinearity of the sawtooth wave basically does not affect the results of the A/D conversion. The second is caused by the microcontroller controlling the A/D conversion process, which includes three aspects: First, it is impossible for the microcontroller to complete the two actions of "turning on the conversion switch" and "timer starting counting" at the same time. ; The second reason is that the process of the microcontroller determining the on-chip analog comparator flipping requires two machine cycles, and the minimum counting unit of the counter is 1 machine cycle; the third reason is that the microcontroller confirms that the analog comparator output state flips and turns off the timer. Probably done at the same time. For the errors caused by the first and third situations, since they are indeed caused by instruction execution, the value of the error depends on the instruction execution time. Therefore, at the end of the conversion, this time can be subtracted from the value of timer 0. ; and the error caused by the second situation cannot be compensated.
5 Conclusion
The data acquisition system designed using the method described in this article has low cost, simple interface, and high performance-price ratio. It should be pointed out that in order to ensure the long-term stability of the system, highly stable integrating capacitors (C1, C3) should be used.
Previous article:DC-DC converter with digital/analog conversion function
Next article:DSD/A digital-to-analog converter DSD-1700
Recommended ReadingLatest update time:2024-11-16 16:48
- High signal-to-noise ratio MEMS microphone drives artificial intelligence interaction
- Advantages of using a differential-to-single-ended RF amplifier in a transmit signal chain design
- ON Semiconductor CEO Appears at Munich Electronica Show and Launches Treo Platform
- ON Semiconductor Launches Industry-Leading Analog and Mixed-Signal Platform
- Analog Devices ADAQ7767-1 μModule DAQ Solution for Rapid Development of Precision Data Acquisition Systems Now Available at Mouser
- Domestic high-precision, high-speed ADC chips are on the rise
- Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
- Using capacitive PGA, Naxin Micro launches high-precision multi-channel 24/16-bit Δ-Σ ADC
- Fully Differential Amplifier Provides High Voltage, Low Noise Signals for Precision Data Acquisition Signal Chain
- 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
- Disable AD auto-start JLink
- Seeking guidance - stc microcontroller remote upgrade program
- Problems with creating sheet symbols for multi-page schematics
- Zigbee Z-Stack 3.0.1 Modify channels using broadcasting
- SHT31 Review + My Review Summary
- Using AT89S series microcontroller
- 【McQueen Trial】Use IPAD to program McQueen's car
- The STM32 FFT library calculates the amplitude normally, but the phase is different each time. Has anyone encountered this problem?
- EEWORLD University----UCD3138 Analog Front End (AFE) Module
- "Show goods" to come to a wave of commonly used development boards