System Overview
This system consists of a signal preprocessing circuit, a single-chip microcomputer AT89C2051, a systematic LED display module, a serial port data storage circuit and system software. The signal preprocessing circuit includes signal amplification, waveform transformation and waveform shaping. The purpose of amplifying the signal to be measured is to reduce the amplitude requirement of the signal to be measured; the waveform conversion and waveform shaping circuit are used to convert the amplified signal into a TTL signal that can be connected to the single-chip microcomputer; the internal timer T1 can control the pulse input pin T0 through the setting of the single-chip microcomputer, so that the number of pulses detected per unit time added to the T0 pin can be accurately calculated; the speed display in the design uses an LED module, and the mileage converted by speed uses the I2C bus and is stored through E2PROM, which not only saves the port lines and peripheral devices of the required single-chip microcomputer, but also simplifies the software programming of the display part. The principle block diagram of the system is shown in Figure 1.
Figure 1 System block diagram
Working principle
This design can display the measured speed and accumulated mileage in real time. It mainly measures the frequency of the pulse signal input from the sensor to the single-chip microcomputer (the sensor converts different vehicle speeds into pulse signals of different frequencies) in real time. Considering the influence of signal attenuation, interference, etc., the signal should be amplified and shaped before it is sent to the single-chip microcomputer, and then the speed and mileage are calculated by the single-chip microcomputer. The obtained data is then stored in the serial port data storage, and the measured speed and mileage are alternately displayed by the LED display module. The mileage algorithm of this design is an approximate algorithm (assuming that the bicycle is moving at a constant speed within a certain period of time, the product of the average speed and time is the mileage).
When designing, the speed measurement accuracy and system response time should be considered comprehensively. This design uses the measurement pulse frequency to calculate the speed, so it has a higher speed measurement accuracy. The ideal state of the bicycle is taken when calculating the mileage. In practice, the error is controlled within a few meters, which is not very large relative to the entire mileage. In order to ensure the real-time performance of the system, the system's speed conversion module and display data conversion BCD code module both use fast algorithms. In addition, the versatility and efficiency of other submodules should be guaranteed as much as possible during programming. The speed and mileage values of this design are displayed in 6 digits and include two decimal places.
Hardware Design of the System
1 Pulse Generator
Pulse Generator This design uses the ST1101 infrared photoelectric sensor for non-contact detection. When an object is blocked between the infrared photoelectric light-emitting diode and the highly sensitive phototransistor, the sensor will output a low level, and when there is no object blocking the middle, the output is a high level, thus forming a pulse. The system extends an aluminum plate at the axis of the rear wheel of the bicycle in a direction parallel to the rotating section of the wheel, digs out several circular vias at the edge of the aluminum plate, and places the detection part of the sensor at the center of the circular hole. Whenever the aluminum plate rotates with the rear wheel, the sensor will output several pulses. These pulses are shaped into a TTL level that can be recognized by the microcontroller through a series of waveforms, and the instantaneous rotation speed of the wheel can be calculated. The number of circular holes in the aluminum plate determines the accuracy of the measurement. The more holes there are, the higher the accuracy. In this way, as many pulses as possible can be obtained per unit time, thus avoiding the large error caused by the car stopping between the vias or before the next via because the distance between the two vias is too large.
This design uses 11 vias in the design of the aluminum plate vias, leaving 10 equal spacings. This makes it easier to calculate the speed mileage in future software designs. The hardware structure diagram of the pulse generator is shown in Figure 2.
Figure 2 Pulse source hardware structure diagram (left is the front view, right is the side view)
2 Signal preprocessing circuit
The signal preprocessing circuit is shown in Figure 3. The signal preprocessing circuit of the system consists of a two-stage circuit. The first stage is a zero-bias amplifier composed of a switching transistor. The use of a switching transistor can ensure that the amplifier has a good high-frequency response. When the input signal is zero or negative voltage, the transistor is cut off and the circuit outputs a high level; when the input signal is a positive voltage, the transistor is turned on. At this time, the output voltage decreases as the input voltage rises, which enables the speed odometer to measure the frequency of any square wave signal and the frequency of the sine wave signal. Since the amplification function of the amplifier reduces the amplitude requirement of the signal to be measured, the system can measure any sine wave and pulse signal greater than 0.5V. The second stage of the preprocessing circuit uses an inverter DM74LS14 with a Schmitt trigger to convert the single-phase pulse generated by the amplifier into a square wave signal compatible with the COMS level (as shown in Figure 4), and at the same time, the output signal is added to the P3.4 port of the microcontroller. [page]
Figure 3 Signal preprocessing circuit diagram
Figure 4 Pulse shaping by Schmitt trigger
Using the positive feedback effect in the state transition process of Schmitt trigger, a periodic signal with slow edge change can be transformed into a rectangular pulse signal with steep edge. As long as the amplitude of the input signal is greater than VT+, a rectangular pulse signal of the same frequency can be obtained at the output end of the Schmitt trigger.
The rectangular pulse obtained from the sensor often undergoes waveform distortion after transmission. When the capacitance on the transmission line is large, the rising edge of the waveform will be significantly deteriorated; when the transmission line is long and the impedance of the receiving end does not match the impedance of the transmission line, oscillation will occur on the rising and falling edges of the waveform; when other pulse signals are superimposed on the rectangular pulse signal through the distributed capacitance between the wires or the common power line, additional noise will appear on the signal. Regardless of which of the above situations occurs, a relatively ideal rectangular pulse waveform can be obtained by shaping with a Schmitt inverting trigger. As long as the VT+ and VT- of the Schmitt trigger are set appropriately, a satisfactory shaping effect can be achieved.
Application of OM AT24C02AT24C02
is a CMOS 2048-bit serial E2PROM, organized internally into 256×8 bits. The AT24C02 features a serial interface and software protocol that allows it to work on a simple two-wire bus.
As shown in Figure 5, in this design, the SDA end of the chip AT24C02 is connected to the P3.7 port of the microcontroller, and the SCL end is connected to the P3.5 port of the microcontroller. Because there is only one device on this I2C bus, the address of AT24C02 is set to 000, that is, A0, A1, and A2 are all grounded. The mileage data calculated by the microcontroller is transmitted to the AT24C02 through SDA and SCL. The microcontroller first sends a write signal to the AT24C02, and when confirmed, it extracts data from the data storage unit inside the microcontroller and then transmits data to the internal address of the AT24C02. When displaying mileage, the microcontroller first sends a read signal to AT24C02, and then after confirmation, the microcontroller reads data from the address inside AT24C02 to the read unit byte of the microcontroller for display.
Figure 5 Interface circuit between AT24C02 and single-chip microcomputer Figure
4 Display part
The display module of this design includes MC14511BCP, CD4076, 74LS138 and 6 LED display tubes. MC14511 is a "three-in-one" device that integrates three functions of latch, decoding and driving. The function of the latch is to avoid the phenomenon of skipping during the counting process, which is convenient for observation and recording. The decoder is used to convert the BCD code into a 7-segment code, and then it passes through a large current inverter to drive the common cathode LED digital tube. The decoder is a non-sequential circuit, and its output state is independent of the clock and only depends on the input BCD code.
The function of 74LS138 is equivalent to the function of bit selection. When the inputs of C, B, and A are "000, 001, 010, 011, 100, 101" respectively, different MC14511 are selected respectively, so that different numbers and decimal points are displayed on different bits. CD4076 is a CMOS 4-bit three-state output D register. Y6 and Y7 of 74LS138 are used to control the operation of its CP, so that CD4076 can control the decimal point display. Figure 6 is the display module block diagram.
Figure 6 is the block diagram of the display module
. Figure 7 is the circuit of the system display part. In the system, Y0~Y5 of 74LS138 is used to select MC14511 to drive the LED display, and Y6 and Y7 are used to control the CP of CD40756, so as to achieve the display of the decimal point by Q1~Q4 of CD4076. The other CD4076 only uses its Q1 and Q2. The corresponding characters in the figure indicate that their pins are connected. [page]
Figure 7
Software design of the circuit system of the system display part
1 The system software block diagram
is shown in Figure 8. The system software adopts a modular design method. The entire system consists of an initialization module, a frequency measurement module, a speed and mileage calculation module, a data conversion BCD code module, a speed display module, a mileage display module, a data storage and reading module, a timer interrupt service module and other functional modules.
Figure 8 System software block diagram
2 Data processing
The signal to be measured is added to the P3.4 (T0) pin of the microcontroller after the preprocessing circuit, which can provide an effective input signal for the microcontroller to measure the signal frequency. The microcontroller determines whether to start the frequency measurement program by detecting the level of the P3.4 pin. When the pin is high, the system is in a waiting state and will not start measuring the frequency until the pin is low. We can know the distance between the two vias on the circumference of the aluminum plate of the hardware. And this distance M just plays a basic data storage role for calculating speed and distance. At the same time, the N pulses detected by the microcontroller within two seconds can be known from the TL0 register. And M×N is exactly the distance S that the aluminum plate travels on the circumference within these two seconds. (At this time, it is assumed that the car is moving at a constant speed within these two seconds). The distance S divided by the time of 2s can roughly calculate the linear speed of the aluminum plate within these 2s. Then, based on the fact that the aluminum plate and the bicycle wheel maintain the same angular velocity, the relationship between the linear velocity of the aluminum plate and the linear velocity of the wheel is obtained, so as to calculate the average speed of the bicycle in these 2 seconds.
As for the calculation of mileage, according to the analysis of speed calculation, after obtaining the distance traveled by the aluminum plate on its circumference within 2 seconds. According to the certain proportional relationship between it and the distance traveled by the circumference of the bicycle wheel (through the algorithm with the same angular velocity of both), the distance S1 traveled by the bicycle in these two seconds can be calculated by the single-chip microcomputer. Adding this distance S1 to the original mileage in the memory can get the current total mileage. The speed and mileage data calculated by the single-chip microcomputer must be converted through BCD code before they can be output to the display module. The display of the total mileage is set to appear when the electric bicycle is started and the single-chip microcomputer is turned on and initialized, so that the user can clearly know how many kilometers his car has run. The speed display is displayed immediately after the speed mileage is calculated, reflecting real-time performance.
Conclusion
This design takes AT89C2051 as the core, and uses photoelectric sensors to detect the operation of the bicycle to realize the speed and mileage calculation of the electric bicycle, as well as the accumulation and storage of mileage. Finally, a 6-bit LED can intuitively display the speed and mileage to the user, and automatically alarm the user when the speed exceeds a certain value, thus achieving an intelligent speed odometer.
Previous article:Multifunctional temperature measuring instrument based on DS18DB20
Next article:Design of Intelligent Satellite Power Supply VT Curve Control System
Recommended ReadingLatest update time:2024-11-16 17:56
- Popular Resources
- Popular amplifiers
- Learning MCU Technology from Scratch (Liu Jianqing)
- Wireless doorbell alarm based on AT89C2051 single chip microcomputer
- Infrared remote control LED electronic clock using real-time clock chip DS1302+AT89C2051
- Infrared remote control LED electronic clock using real-time clock chip DS1302+AT89C2051.rar
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
- c8051f040 can communication
- [Gizwits Gokit3 Review] Part 3: One-click Internet access, can you get started?
- Design Principle of Analog Biquad Four-Channel Notch Filter
- 【NUCLEO-F746ZG Motor】Introduction to NUCLEO-F746ZG Development Board
- 【GD32307E-START】+Return of the GD32F307E development board
- Can the 2.4GHz and 5GHz frequency bands supported by CC3135MOD work online at the same time?
- [Problem Feedback] Anlu TangDynasty download program speed selection problem
- Encoder Problems
- FPGA Black Gold Development Board Core Board Schematic Diagram.pdf
- Help, there is a chip that I don't know what it is.