1 Principle
The 51 series microcontroller has more than two 16-bit dual-channel timers (TIME0 and TIME1), and each channel can be selected as an input capture mode to measure the pulse width. We use the on-chip 16-bit timer to connect an external op amp and comparator to realize dual-integration A/D conversion. The schematic diagram is shown in Figure 1 (the power supply and the 51 microcontroller peripheral circuit are the same as the conventional circuit). TL082 is a JFETINPUT op amp; LM358 is a comparator; MC4066 is a multiplexer. P10, P11, and P12 of the 51 microcontroller P1 port are used as outputs to control the input selection of the MC4066 multiplexer; INT0 is used as an interrupt input port to capture the output level jump of the LM358 comparator. C1 is an integral capacitor, usually a polypropylene capacitor of about 0.22μF, R2 is an integral resistor, which can be about 500k, U2A is an integral op amp, U2A, C1, and R2 constitute an integrator, and U2B is a zero-crossing detection op amp. VIN is the input voltage, VREF is the reference voltage, and AGND is the reference zero point of the converter. VREF and the reference zero point are generated by voltage division by R9, R10, and R11.
Before measurement, TK3=1, TK2=0, TK1=0, turn on the U1C and U1D analog switches, make the integrator input equal to AGND, and enter the zeroing stage. The time for the first start-up conversion is 300ms; the zeroing time after startup is 40ms. When the conversion starts, TK3=0, TK2=0, TK1=1, the integrator input is connected to the input voltage, so that VIN charges C1 through the integration resistor R2, and the integration time is set to T. Then, TK3=0, TK2=1, TK1=0, that is, the integrator input is connected to the reference voltage VREF, and the capacitor C1 begins to discharge reversely to VREF through R2. When the output of the op amp is lower than the C2 capacitor voltage, the comparator output reverses. Then, TK3=1, TK2=0, TK1=0, turn on the U1C and U1D analog switches, and enter the zeroing stage again. Let the time of reverse charging be t, then we have
In the above formula, VIN is the measured voltage, T is the forward integration time, t is the reverse integration time, VREF is the reference voltage, and AGND is the reference zero point of the converter. The integrator output waveform is shown in Figure 2.
The program consists of an initialization program, an input capture interrupt service program, a TIME0 interrupt service program, and an interface program that calls the program module.
When the program is initialized, set TK3=1, TK2=0, TK1=0, and the software delays for 300ms to perform initial zeroing; when performing forward integration, turn off INT0, set TK3=0, TK2=0, TK1=1, turn on TIME0 (set TIME0 to work in timing mode), and perform timed forward integration; after the forward integration is completed, set the timing TIME0 to work in input capture mode, turn on INT0, set TK3=0, TK2=1, TK1=0, and perform reverse integration. TIME0 is used for timing, and another register is used to count the number of timer overflows; when the comparator output reverses and the INT0 interrupt occurs, the microcontroller automatically turns off TIME0 and completes a double-integration A/D conversion. AD value (HEX) = register count value * 100 + TIME0.
The source program list is as follows:
(1) The charge and discharge time (T and t) should generally not exceed 2RC. If this is exceeded, the linear error will increase.
(2) When designing the PCB board, the ground of the analog and digital power supply should be separated and connected at a single point; the connection lines of the AD conversion components should be as short as possible, and these components should be separated from the digital components; the PCB board should use a thicker copper foil.
(3) Keep the PCB board and components clean, and the analog part should be coated with waterproof glue.
(4) The integrating capacitor should be a polypropylene capacitor with low leakage, and the reference voltage divider resistor and integrating resistor should be resistors with small temperature coefficient and noise.
Previous article:Proteus simulation 51 single chip microcomputer C language - single chip microcomputer sends a string to the host
Next article:Very simple 8×8LED dot matrix c51 source code
Recommended ReadingLatest update time:2024-11-16 16:46
- Popular Resources
- Popular amplifiers
- Microgrid Stability Analysis and Control Microgrid Modeling Stability Analysis and Control to Improve Power Distribution and Power Flow Control (
- Signal and System Experiment Tutorial (Edited by Jin Bo)
- Effective Unit Testing (Lasse Koskela)
- Operational Amplifier Practical Reference Handbook (Edited by Liu Changsheng, Zhao Mingying, Liu Xu, etc.)
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
- Show off the Sony headphones I got from EEWORLD
- Single tube amplifier
- TMS320F28335 SVPWM source program
- 【RPi PICO】CircuitPython Firmware
- Microwave Circuit Appreciation
- Microcontroller learning notes, teach you how to learn in three steps!
- msp430f5529 uart pwm adc
- WiFi NeoPixel Cube
- [Help] In the design of lithium battery power modules, why is every 1V of lithium battery voltage very valuable?
- [DIY Bing Dun Dun] + Limited Edition Homemade Dun Dun is here