The angle measuring instrument is a key component of the aiming device in a certain control system. In the past control systems, most of them relied on the operator's eyes to aim at the designated target and then make corresponding controls. This brought a series of problems, such as the operator's experience and the empty return of the aiming device turntable, which may seriously affect the accuracy of the aiming target, thereby seriously affecting the accuracy of the control system. In order to improve the aiming accuracy of the control system, an angle measuring instrument component is added to the aiming device of the control system. The angle value after the operator aims at the target can be accurately and quantitatively displayed on the operation panel, helping the operator to aim at the target more accurately, thereby greatly improving the control accuracy of the control system.
The angle measuring instrument uses a photoelectric encoder to read the angle value, and uses the AT89S51 single-chip computer to realize the digital display of the angle value and the LED indication function of the angle value deviation range (there are three indicator lights, indicating: high, low, and moderate). Whether in terms of the complexity of operation or the accuracy of measurement, it is incomparable to the traditional eye sighting method, scale measurement and marking method.
As an important technical improvement of the aiming device of a certain control system, the application of this instrument has greatly improved the aiming accuracy of the control system, increased the readability of the aiming deviation range, eliminated the traditional method of measuring and marking angles with scales, and significantly improved the overall performance of the control system. In addition, the angle measuring instrument can be widely used in other industrial control systems with only a slight modification.
1 Basic Principles of Hardware
First, the angle measuring instrument uses a single-chip microcomputer to read the angle value measured by the photoelectric encoder, and then converts the angle value into a mil value and displays it on the digital screen (note: mil is an angle unit, mil 100 = angle 6°). The single-chip microcomputer determines the deviation range of the current angle value and gives a control signal to light up the corresponding LED indicator. In addition, the angle measuring instrument can also realize the lighting of the sight and the automatic defrosting of the sight in a low temperature environment through the switch control on the control panel. The main function of the single-chip microcomputer is to realize the digital tube display of the angle value and the LED indication of the angle value range. The difficulty of this system lies in ensuring the conversion accuracy of the angle value into the mil value and the working reliability of the system in an abnormal temperature environment.
The hardware is divided into the following modules: control panel, single chip microcomputer, photoelectric encoder, power supply, digital display, light emitting diode matching indicator, periscope and direct sight mirror lighting and defrosting, as shown in Figure 1.
Figure 1 Circuit Module Diagram
1.1 Selection of MCU
First, according to the project requirements analysis, the main functions of the microcontroller are: after reading the angle value from the photoelectric encoder (data bus width is 15 bits), compare the angle value with the system preset angle value, determine the angle range of aiming, and light up the corresponding indicator light. Then convert the angle value read from the photoelectric encoder into a dense value, send it to the serial LED display driver MAX7219, and display it on the LED display.
From the above analysis, we can know that the MCU that meets this requirement should have at least 3 8-bit parallel I/O ports (of which the photoelectric encoder occupies 2 ports and the others occupy 1 port) to work effectively. As we all know, the quality level of products is usually divided into three levels: military grade, industrial grade and commercial grade, among which the military grade is the highest and the commercial grade is the lowest. Since this industrial control equipment usually works outdoors and the working environment is relatively harsh, the quality level of the MCU is also an important factor to be considered.
At present, the MCS-51 series of single-chip microcomputer technology is mature, there are many teaching materials and technical data used for development, and the development tools are complete. There are rich product varieties on the market, high cost performance, easy to purchase, and the development language is simple and easy to learn (you can use assembly or C51). Therefore, this series of products is widely used and enduring.
After comprehensive consideration, the single-chip microcomputer adopts the AT89S51 chip (industrial-grade product of MCS-51 series single-chip microcomputer) produced by ATMEL, which is compatible with MCS51 microcontroller, 4 K bytes of FLASH memory supports 1000 erase cycles of in-system programming (ISP), 128 bytes of on-chip RAM, working voltage 4.0 V to 5.5 V, full static clock 0 Hz to 33 MHz, three-level program encryption, 4 8-bit programmable I/O ports, 2/3 16-bit timers/counters, 6/8 interrupt sources, full-duplex UART, low power consumption supports Idle and Power down modes, Powerdown mode supports interrupt wake-up, dual data pointers, power-on reset flag. The 89 series single-chip microcomputers produced by ATMEL have extremely wide applications in industry, transportation, instrumentation, automatic production process, aviation, transportation, automobiles, home appliances and other fields. The model selected is AT89S51-24PI from ATMEL, industrial grade, which can adapt to the working environment of -45℃~+80℃.
The I/O port resource allocation of the microcontroller is: P0 and P2 ports are allocated to the photoelectric encoder, and P1 port is allocated to the display driver and matching indicator LED control and MAX813.
1.2 Design of the main peripheral circuits of the microcontroller
Monitoring circuit: In order to improve the reliability of the microcontroller in harsh environments, a μP monitoring circuit must be used to increase the stability and anti-interference ability of the microcontroller. The hardware monitoring circuit has the following functions: (1) Power-on reset: Ensure that the system can start correctly when powered on. (2) Power-off reset: When the power fails or the voltage drops below a certain voltage value, a reset signal is generated to reset the system. (3) Watchdog timer: When the processor encounters interference and the program runs chaotically and "deadlocks", the system is reset. The military-grade chip MAX813LMJA from MAXIM is used here.
Display driver circuit: In order to save the I/O port resources of the microcontroller and reduce the calculation amount of the microcontroller, the serial LED display driver MAX7219 is selected. It can control 8-bit common cathode LED digital tubes, has 16 levels of brightness control, flexible decoding, all light-emitting diodes are turned off when powered on, and only occupies three microcontroller I/O port lines.
The principle of the microcontroller and main peripheral circuits is shown in Figure 2.
Figure 2 Circuit diagram
1.3 Data communication between microcontroller and peripheral devices
Single chip microcomputer and photoelectric encoder: Because the speed at which the photoelectric encoder obtains angle values is much greater than the working speed of the single chip microcomputer, the single chip microcomputer can assume that the data on the photoelectric encoder is always in a "ready" state. The single chip microcomputer can read valid data at any time. The 16-bit angle value is divided into two readings, the high 8 bits and the low 8 bits, and the data between them is transmitted in parallel and unconditionally.
MCU and MAX7219: From the working speed of MCU and MAX7219, the time interval between CPU sending data to MAX7219 is enough to ensure that MAX7219 is always in "ready" state when MCU accesses MAX7219. MAX7219 is a serial LED display driver, so the data transmission between MCU and MAX7219 is serial unconditional transmission.
MCU and MAX813: Because when the MCU sends data to MAX813, MAX813 only waits to receive the initialization data of the MCU and has no other work. Its working speed is fast enough, so it can be considered that MAX813 is always in the "ready" state. Therefore, the data transmission between the MCU and MAX813 is also serial unconditional transmission.
2 Software Design Principles
After the angle measuring instrument starts working, the working process of the single-chip microcomputer is: after the system starts, initialize the external watchdog, initialize the display driver chip MAX7219, assign an initial value to the watchdog counter, read the angle value obtained by the photoelectric encoder, and when the angle deviation value is in a certain range, the single-chip microcomputer sends a control signal to light up the indicator light corresponding to the range, convert the current angle value into a dense value and display it on the digital screen, and re-assign the initial value to the watchdog counter to enter the next working cycle. The workflow of the main function is shown in Figure 3.
Figure 3 Main function flow chart
Please note that in the flowchart, the rectangular box with double lines indicates that the part is a function. In the software design of this topic, C51 programming language is used because programming with C51 is not only efficient but also very readable.
The source code of the main function is given below.
void main (void)
{
WDI = 0; // Initialize watchdog
InitMax7219(); // Function to initialize MAX7219
while (1) {
WDI = 1; //"Feed the dog"
WDI = 0; //"Feed the dog"
GetAngle(); //Function to read angle value
MachView(); // Function to display indicator light matching
GetMil(); //Function to calculate the density value
DisplayMil(); // Function to display the density
}
}
Among the several functions called by the main function, the function of InitMax7219() is to initialize the LED display driver MAX7219. The microcontroller sends the information of shadow control, brightness, scanning range and decoding mode to MAX7219.
The function of GetAngle() is to read the angle value from the photoelectric encoder, first read the upper 8 bits, then read the lower 8 bits, then combine the upper 8 bits and the lower 8 bits, and finally discard the lowest bit (the effective data of the photoelectric encoder is 15 bits).
The function of MachView() is to match the angle deviation indicator light display, compare the angle value with the system preset angle value, and judge whether the aiming angle value is high, low or moderate. If the angle value is high, the microcontroller will issue a control command to light up the high indicator light, if it is low, the low indicator light will light up, otherwise the moderate indicator light will light up.
It is worth noting that when writing the code for the function GetMil() that calculates the mil value, the conversion accuracy of the angle must be considered. In this project, the long type variable in C51 is used to store the integer and decimal parts of the mil respectively, and the decimal part of the angle is magnified 100,000 times before participating in the calculation to ensure the conversion accuracy.
The function of DisplayMil() is to drive MAX7219 to display the mil position. First, the mil position is displayed to determine whether the angle is in the preset area. If so, the symbol light is turned off and each position displays "0". If not, it is determined whether the angle value is negative. If so, a negative sign is displayed. If positive, a negative sign is not displayed. Then the angle value is displayed on the LED display.
Due to space limitations, the source code of the program is not given.
3 Conclusion
In order to make the angle measuring instrument work properly in various possible harsh environments (such as high temperature, low temperature, vibration, etc.), the issues that need to be considered in the entire design process are the reliability of hardware and software. The following are the precautions during design: (1) The rated power of the power chip should be selected with a margin. (2) Industrial or military grade components should be selected. (3) A hardware watchdog solution is used to prevent the microcontroller program from being locked. The prototype designed in this project is in the testing stage and has passed the tests of normal temperature and various environmental tests.
Previous article:Research on laboratory intelligent control system based on STC89C52 single chip microcomputer principle
Next article:Introduction to software reset method of MCS51 series microcontroller
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- MOSFET turn-on schedule question
- The gift redemption speed is really fast
- VMM Image Measurement Software
- msp430F149 PWM adjustment
- Album information compilation: Power supply simulation, those who need it, please enter!
- Detection circuit
- A scientist who continues to live as a cyborg
- Adafruit IO Time Tracking Cube
- Look at this board, guys.
- Misunderstandings about Embedded Flash Technology