Belt drive is a common transmission device used in industrial production. Its commonly used speed detection device is a photoelectric encoder installed at the rotating end of the motor. However, in the long-term use of the equipment, due to unpredictable conditions such as wear, the motor speed and the belt drive speed are seriously inconsistent. This semi-closed loop control method has a large error in the belt drive speed control that requires higher precision. Grating rulers are expensive and have high requirements for the on-site environment, so they are often not very suitable for the modification of belt drive devices in ordinary working conditions. In view of this, this paper proposes to use a general commercial photoelectric mouse to replace the traditional detection device, and realize the on-site PID control through the AT89S51 microcontroller, so that the belt drive speed can meet our satisfactory requirements.
1. Hardware composition of the detection system
1.1OM02 optical sensor chip and mouse controller
This optical COMS sensor is a non-contact photoelectric mouse chip for personal computers. It integrates a digital signal processor (DSP), a dual-channel orthogonal output port, etc. There is a photosensitive eye at the bottom of the chip, which can continuously take pictures of objects and send the two previous and subsequent images to the DSP for processing to obtain the direction and distance of movement. The displacement value generated by the DSP is converted into a dual-channel orthogonal signal, and the dual-channel orthogonal signal is converted into a PS/2 data format that can be processed by the microcontroller in conjunction with the mouse controller. The device is installed on a set of plastic optical lens devices and is equipped with a high-intensity LED. In addition, it can provide a resolution of up to 400 dots/inch and a speed detection of less than 16 inches/second.
Figure 1 is the installation diagram of the mouse chip. Because the OM02 chip is a COMS sensor, it must be equipped with a high-intensity light-emitting diode that is compatible with it, and the emission angle and the bottom plate angle are within the range of 30°~45°. After standard installation, the effective distance between the bottom plate and the working surface is within 0mm~2mm, and the OM02 chip can perform normal data reception and detection.
1.2 Detection and control principle
This system adopts a full closed-loop control method, as shown in Figure 2 below. The displacement increment detected by the mouse is fed back to the microcontroller, and digital PID control is performed. The calculation result is transmitted to the inverter through the D/A conversion chip , thereby controlling the speed of the motor.
This experimental system is mainly composed of a prime mover, a transmission part, an execution part and a control part. As an important part of the machine, the mechanical transmission system should not only be able to achieve the expected function, but also have good performance. To this end, this experiment uses a three-phase AC asynchronous motor (Y2-63M1-4, 0.12KW), a frequency converter (Fuji FRN0.4C1S-4C), a 30:1 worm gear reducer, a v-type B-phase belt transmission device, a P204 ball bearing and a bearing seat as the main transmission and execution parts of the simulated industrial equipment. By adjusting the output voltage U of the digital-to-analog converter through the single-chip microcomputer, the output frequency of the frequency converter can be changed, thereby changing the motor speed.
2. MCU Programming
2.1 Principle of Mouse Communication Protocol
The data communication method between the mouse and the microcontroller adopts the PS/2 communication protocol.
The physical interface of the PS/2 mouse is a 6-pin circular interface, and only 4 pins are needed for use: 1-pin Data, 3-pin GND, 4-pin +5VPower and 5-pin Clock.
The mouse implements a bidirectional synchronous serial communication protocol, sending or receiving data serially under the action of the clock signal. Usually, the microcontroller has bus control priority on the bus and can suppress the communication from the mouse at any time. The data from the mouse to the microcontroller is read on the falling edge of the clock, and conversely, the data from the microcontroller to the mouse is read on the rising edge of the clock. The clock signal is always provided by the internal chip of the mouse, and the clock frequency is generally 10~20KHz.
2.1.1 MCU to mouse communication
According to the protocol requirements, the MCU only needs to pull down the clock line for at least 100us to disable its communication, and the MCU pulls down the data line to put it in the request to send state. As shown in Figure 3, when the clock line rises to a high level and is pulled down again by the PS/2 device, the MCU can start communicating with the mouse.
2.1.2 Mouse to MCU Communication
Because the MCU has control over the bus, when the mouse wants to send information to the MCU, it must first check whether the clock line is at a high level. As shown in Figure 4, when the clock line is at a high level and the data line is at a low level, it indicates that the mouse requests to send and the MCU can accept data from the mouse.
2.1.3 Control data sent by the microcontroller
According to the PS/2 protocol specification of the mouse, when programming, first send 0xff to the mouse to reset it. The default sampling frequency is 100 times/second, the scaling ratio is 1:1, and data reporting is prohibited. Use the 0xea command to enter the stream mode, and use 0xe8 and 0x03 commands to set the resolution to 8 points/mm. Use the 0xf4 command to enable data reporting. In conjunction with the timer function of the AT89S51 microcontroller, set its time constant to 0.1s, and send the 0xeb command to read the displacement data information each time an interrupt occurs. Each time it is issued, the displacement data packet received by the microcontroller contains the displacement information and key action information. The specific format is shown in Table 1. When compiling, you only need to extract the valid data packet of X3, that is, the displacement increment in the Y direction.
2.2PID control software algorithm
The system was simulated and tested in Matlab using neural network PID adaptive control, and the results were quite satisfactory. However, the multi-order matrix operations of its input layer, hidden layer, and output layer greatly increase the operation time of the single-chip microcomputer, resulting in an increase in the uncertainty of time. Compared with the incremental PID control, although the latter requires adjustment of three control parameters, it can also achieve the expected accuracy and the operation time is greatly reduced. Therefore, the incremental PID algorithm can still be used as the control. The control algorithm of the incremental digital PID is:
U(k)=U(k-1)+*(e(k)-e(k-1))+*e(k)+*(e(k)-2e(k-1)+e(k -2))
Where e(k) is the change between the current displacement increment and the previous displacement increment. Similarly, e(k-1) and e(k-2) are the displacement changes in the previous time interval.
By using the serial interrupt receiving function of the microcontroller, the kp, ki, and kd parameters of the PID can be adjusted in real time on the PC.
3. Host computer monitoring design
Send through the serial port of the microcontroller, write a program in LabVIEW to complete the PC control data communication equipment to exchange data, directly receive external data through the serial port and display it graphically, and store the data in a txt file. In Labview, direct serial port data communication is mainly achieved through VISA controls, and data communication is achieved through RS-232 serial interface and Labview.
The readstring control can be used for display. Data reception is not continuous, but with a certain delay. In order to achieve uninterrupted reception of serial data packets sent by the microcontroller, the previous write and delay must be removed. Because the data received by the serial port is character type, the data is converted to single-precision integer through forced conversion. Create an array to combine data and array initialization to obtain a complete array. The real-time display and recording of the host computer can be achieved through the Waveformgraph control and shift register.
4. Detection and control performance evaluation
The maximum constant frequency of the PS/2 interface is 33kHz. This experimental microcontroller uses a 12MHz crystal oscillator, which can easily complete the interface function. However, due to the characteristics of its chip, although the highest resolution that can be used by the OM02 mouse chip is 400DPI, when using a higher resolution, the error rate of the mouse transmission will increase, and its displacement accuracy will also be questioned. In order to ensure the accuracy of the displacement, a resolution of 200DPI is used, and with the watchdog, the accuracy error and program stability will be greatly improved.
5 Conclusion
Using an optical mouse as a speed sensor to detect belt movement is cheap, accurate and easy to use. Combined with the digital PID control of a single-chip microcomputer and the graphic detection of labview software, it can be well modified for equipment with low speed requirements and not very high precision, so that it can achieve stable output speed. In addition, because the optical mouse technology has become mature, the requirements for the detection surface are not high under general resolution conditions, and it can still ensure smooth operation under relatively harsh working conditions. The laser mouse launched in recent years has a resolution of up to 0.01 mm, which is very effective. The experiment was tested on-site in a semiconductor company in Beijing, and the effect was ideal.
Previous article:LED--8051 driver test program
Next article:Implementing multiple serial ports with STC89C51RC/RD+
Recommended ReadingLatest update time:2024-11-15 14:39
- Popular Resources
- Popular amplifiers
- Analysis and Implementation of MAC Protocol for Wireless Sensor Networks (by Yang Zhijun, Xie Xianjie, and Ding Hongwei)
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Introduction to Internet of Things Engineering 2nd Edition (Gongyi Wu)
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- LIS2MDL array magnet displacement data acquisition for magnetic nail navigation AGV
- Domestic Bluetooth BLE chip
- EEWORLD University Hall----Digital Image Processing (MATLAB) Shandong University (Jiang Mingyan)
- [RT-Thread reading notes] First acquaintance
- How the Circuit Works
- Did you know? TI's 77Ghz single-chip mmWave sensor enables automated parking
- Analog Dialogue Collection
- How to concatenate 8 sbits of data into one? Bitwise operation? How to implement it?
- Ask a question about bit fields
- Circuit - What does HVCCR mean?