0 Introduction
With the rapid development of microelectronics technology, single-chip microcomputers have been widely used in automobiles, communications, office automation, industrial control, advanced toys, household appliances, etc. If Proteus is used as a single-chip microcomputer system simulation tool, there is no need to make circuit boards, but Proteus can be used for system virtualization. This can not only complete the required functional design verification, but also reduce the consumption of hardware costs, thereby shortening the entire design cycle and fundamentally improving the development efficiency of electronic products.
Speed measurement is a common problem in industrial and agricultural production. Based on the various advantages of single-chip microcomputers, it is of great significance to apply single-chip microcomputers to speed measurement systems. For speed measurement technology, the first thing to solve is the sampling problem. When using analog technology to make speed measurement equipment, the speed measuring generator method is often used, that is, the shaft of the speed measuring generator is connected to the shaft to be measured, and the voltage of the speed measuring generator reflects the speed; when using a single-chip microcomputer for speed measurement, a simple pulse counting method can be used.
As long as the shaft generates one or more fixed pulses every time it rotates, and the pulses are sent to the microcontroller for counting, the number of pulses per unit time is finally calculated, and the relevant information of the speed can be obtained. This article will complete the pulse counting based on the capture function of the PIC16F877 microcontroller, use software programming to realize the conversion of relevant physical relationships, and finally obtain the gear linear speed and display it on the digital tube.
1 Principle of tachometer
1.1 CCP1 Capture Function
There are two CCP modules in the PIC16F877 microcontroller, which have basically the same structure and are denoted as CCP1 and CCP2. Each CCP module can be configured as one of the three functional modes: Capture, Compare and Pulse Width Modulation (PWM).
The capture mode of CCP1 has the following three functions: first, it can capture the jump of RC2/CPP1 pin and save the content of TMR1 count register at that time; second, it has a prescaler, which can realize capture once every 1 pulse, every 4 pulses or every 16 pulses; third, the capture time can generate an interrupt.
1.2 CCP tachometer principle
In capture mode, the microcontroller can capture the time value when the pin level changes, that is, the precise time value when the rising or falling edge of the pin input pulse occurs.
When the CCP1 module of PIC16F877 works in capture mode, when a specific transition edge occurs, the count value of the TMR1 timer will be immediately copied to CCPR1H and CCPR1L and an interrupt signal will be generated. This 16-bit count value is read in the interrupt service program. When the capture function of the CCP1 module is used to measure the time interval between two adjacent rising edges, this time interval is the period g-Period of the input signal. Since the main frequency is 4 MHz, that is, each instruction cycle is 1 μs, the pre-scaling ratio is set to 1:1, and the unit of the measured period result is microseconds. Therefore, the final measured speed value speed is obtained by the following formula:
speed=(1M*60s*0.01m*pi)/g_Period
Among them, pi is the value of pi; 0.01m is the diameter of the gear being measured, which is measured by physical methods.
speed=(1M*60s*0.01m*pi)/g_Period
Among them, pi is the value of pi; 0.01m is the diameter of the gear being measured, which is measured by physical methods.
2 Function Implementation
2.1 System Design Block Diagram
The tachometer function can be realized by several parts including the main control module based on PIC16F877, the display module, and the module under test consisting of gears and photoelectric sensors.
The module under test and the measuring submodule are connected through the RC2/CCP1 pin of the microcontroller. During the Proteus software simulation, the signal generator SG1 and the frequency meter are connected as hardware devices. SG1 is used to simulate the signal generated by the module under test. F1 operates in the frequency meter mode to display the current signal frequency and is used as a reference value to compare with the display module data, that is, the speed measurement result value of the speed meter, to verify whether the speed measurement result of the speed meter is correct. The connection relationship between the modules is shown in Figure 1. [page]
2.2 Solution Design and Implementation
The design and implementation of this simple speedometer is mainly based on the CCP module function of PIC16F877. Here we first configure CCP1 of PIC16F877 to capture mode, set the prescaler ratio to 1:1, and trigger on every rising edge.
When the jump is captured, the CPP1 interrupt flag is set and the interrupt method is used directly for processing, that is, the value or state change of the relevant register is processed in the interrupt service subroutine, and the relevant physical quantity is calculated and stored. The above settings are all completed by software programming.
2.2 Design and Implementation
The design and implementation of this simple speedometer is mainly based on the CCP module function of PIC16F877. Here we first configure CCP1 of PIC16F877 to capture mode, set the prescaler ratio to 1:1, and trigger on every rising edge.
When the jump is captured, the CPP1 interrupt flag is set and the interrupt method is used directly for processing, that is, the value or state change of the relevant register is processed in the interrupt service subroutine, and the relevant physical quantity is calculated and stored. The above settings are all completed by software programming.
3 Functional Simulation
3.1 Construction of simulation circuit under Proteus
To complete the simulation of the tachometer function in Proteus, you should first create a new design file in its interface and build a simulation circuit diagram. The circuit diagram of the tachometer function in this example is shown in Figure 4. [page]
When simulating in Proteus software, each electronic module in the library has an integrated drive function, so each module and the microcontroller only need to be connected with a simple connection line without any external drive circuit. However, when actually making the circuit board, it is still necessary to add the drive circuit of each module and consider the spacing between each device to avoid electromagnetic interference.
3.2 Functional Simulation
The code for each module is written in MPLAB IDE 8.90, a dedicated development environment for PIC series microcontrollers. After compilation and running, the design file created in Proteus software is loaded and run using the debugging tool Proteus VSM. The result is shown in Figure 5.
3.3 Simulation Results Analysis
As shown in Figure 5 above, when the signal frequency is configured to 3 000 Hz, the simulation result, i.e. the speed of the tachometer, is displayed as 5 660 m/s, and fluctuates within a small range with the speed value as the center. The speed value calculated theoretically is about 5 655 m/s, which is basically the same as the simulation value. In fact, by taking the average value after continuous measurement of n cycles, the error between the theoretical value and the simulation value will be significantly reduced.
4 Conclusion
This paper proposes a simple tachometer design based on the capture function of the PIC16F877 microcontroller. After simulation verification under Proteus software, the design basically meets the expected results. The entire tachometer design in the scheme is simple and convenient, low cost, small speed measurement error, and easy to implement. After modularization, it can be directly used as an integrated speed measurement module in other designs.
Previous article:Portable electronic scale based on single chip microcomputer
Next article:Portable electronic scale based on PIC16F628 microcontroller
Recommended ReadingLatest update time:2024-11-16 15:58
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
- Dear brothers, do you have any information about designing a mobile phone smart fast charger using stm32?
- Portable Formaldehyde Tester Work Submission
- Water suspension device
- Introduction to TI's operational amplifier and comparator solutions in new energy vehicle applications
- A summary of the principles of drones that you must read (I) Principles of flight
- Based on AM335X development board (ARM Cortex-A8)——Linux system user manual (medium)
- Operator precedence and associativity in C language
- Application of variable diameter rectifier in vortex flowmeter
- Design of Video Image Acquisition Interface for TMS320C54x DSP
- DaVinci Digital Media Processor TMS320DM8127