1. Working principle of computer mouse
Six groups of infrared sensors are installed around the computer mouse to sense the left, left front, front, right front and right respectively. The transmitting end emits infrared with a certain frequency. The receiving end judges whether there is an obstacle through the reflected waves in six directions, stores the data of the cell in real time, and controls the computer mouse to complete obstacle avoidance, turning and Acceleration and other actions, use the intelligent algorithm to traverse some or all cells of the maze, and store the maze information in an effective data structure. The microcontroller uses the maze efficient algorithm to find an optimal path according to these recorded information, so as to realize the maximum sprint from the starting point to the end point.
2 hardware circuit designIn order to complete the maze detection and sprint tasks, the computer mouse needs to have the following functional modules: the ARM microprocessor acts as the control core to coordinate the normal operation of each functional module; The motor and drive module control the motor start and braking in real time; Infrared detection module is responsible for infrared detection and perception; The power supply supplies a stable voltage for the whole system. The gyroscope and compass module determine the computer mouse orientation, and analyze the coordinates according to the distance traveled. The hardware composition is shown in Figure 1.2.1 power module
Linear voltage stabilizing devices (such as lm7805) are usually used as power regulating devices, which have the advantages of adjustable output voltage and high voltage stabilizing accuracy. However, its linear adjustment mode has large "heat loss" in operation, resulting in low power utilization and can not meet the requirements of portable and low power consumption. The switching power supply regulator, different from the linear voltage stabilizing device, works in the way of complete on or off. By controlling the on and off time of the switching tube, it can effectively reduce the "heat loss" in work and improve the power utilization. In this design, the power module provides three different voltages for the system. The 12V power supply is used to drive the motor. The switching power supply lm2596 is used to reduce the 12V DC voltage to 5V to supply power to the infrared module and human-computer interaction module, and then the 5V is reduced to 3.3V through ams1117 for ARM processor and other modules.
2.2 microprocessor module
Microprocessor is the core of the whole control system. It completes the functions of obtaining path information from infrared detection module, collecting instantaneous speed, data processing, control algorithm operation, outputting real-time control quantity and so on. In order to ensure the practicability and easy scalability of the system, the control system adopts the "enhanced" series stfm32f103rct6 launched by stm32f103xx, and the enhanced series stm32f103xx uses the high-performance arm correx-m3 32-bit RISC core, the working frequency is 72mhz, and the built-in high-speed memory (up to 128K bytes of flash memory and 20K bytes of SRAM), Rich enhanced I / O ports and peripherals connected to two APB buses. All models of devices include two 12 bit ADCs, three general 16 bit timers and a PWM timer, as well as standard and advanced communication interfaces: up to two I2C and SPI, three USART, one USB and one can, which meet the requirements in terms of storage capacity and operation speed.
2.3 motor and drive module
In order to improve the system power and reduce the power consumption, the driving circuit adopts the integrated circuit chip L298N based on pulse width modulation. The most common is the L298N in 15 pin muliwart package, which contains a four channel logic drive circuit, that is, a high-voltage and high current double full bridge driver with two h bridges, which can drive and control two DC motors. The chip adopts dual power supply for motor power supply and logic level power supply, and can accept standard TTL logic level signal to drive motors below 46v and 2A, And can drive inductive load. ENA and ENB are control enable terminals, in1, in2, in3 and in4 are control level input terminals, and the circuit is shown in Figure 2. The hollow cup DC motor is used in this design, which has outstanding energy-saving characteristics, sensitive and convenient control characteristics and stable operation characteristics. The maximum efficiency is generally more than 70%, and some products can reach more than 90%; Start and brake quickly and respond very quickly; Its weight and volume are relatively reduced by 1 / 3-1 / 2, and the pulse duty cycle is adjusted by PWM.
2.4 infrared detection moduleThe infrared detection module is mainly responsible for maze environment monitoring and processing. The infrared ray is modulated and sent out by the transmitting tube, and the receiving tube receives the reflected light from the labyrinth wall, and judges the distance from the partition wall according to the strength of the received reflected signal. Compared with traditional infrared detection methods, the system has the following characteristics:(1) The number of infrared sensors increased from 5 to 6. In addition to the two 45 degree oblique angles of front, left, right and front, a group of infrared sensors are added in front. Through the fusion of the information of the two groups of sensors in front, the 45 degree oblique crossing is realized. Compared with the previous 90 degree right angle adjustment, it saves time and improves efficiency.
(2) The amplifier design based on dual-t frequency selection network is adopted, and the infrared sensor realizes the ranging between computer mouse and obstacle according to the strength of reflected signal. In the past, the integrated infrared receiving sensor (such as irm8601s) was used, and the automatic gain control circuit, band-pass filter circuit, decoding circuit and output driving circuit were integrated in the receiving head. However, since the detection signal outputs a digital signal, it can only judge whether there are obstacles or not, and the distance can not be calculated according to the output strength of the detection signal. In this design, the frequency selective amplification design based on dual-t frequency selective network and tlc084 is adopted to amplify the useful signals with different frequencies and different gains, so as to filter or suppress the useless signals.
(3) Transmit three frequency modulated waves to reduce the interference between signals. The six groups of sensors are divided into three groups. The left and right groups of sensors are responsible for detecting whether the computer mouse is walking on the middle line, so as to make posture correction in time; The front left and front right sensors mainly check whether there is an intersection ahead; The front two groups of sensors cooperate with the motor to realize 45 degree turning. The higher the infrared light emission frequency is, the farther the propagation distance is. In this design, because the distance between the maze walls is 16.8cm (cell 18cm. Wall thickness 1.2cm), the width of the computer mouse is generally about 10cm, and the distance between the vehicle body and the walls on both sides is only about 3cm, so the emission frequencies on the right and left sides are 33khz, the emission frequencies on the left and right sides are 35kHz, and the distance in the front is the farthest, The transmission frequency is 38kHz. See Figure 3 for details.
In this design, the hardware circuit is improved. The STM32 timer outputs three PWM signals. Each two groups of infrared transmitting tubes share one PWM signal and return after encountering obstacles. The infrared receiving tube collects the signal, amplifies the useful signal through the frequency selection amplifier and sends it to the 12 bit successive approximation AD converter of STM32. Due to the delay of rectification and filtering, AC sampling is adopted here. ADC needs 1.5 12.5 ADC cycles at the highest speed, and reaches the speed of 1msps at the 14m ADC clock. The infrared ranging circuit is shown in Fig. 4. When the receiving tube receives infrared, D2 is turned on, and the stronger the reflection, the smaller the D2 resistance. When no infrared is received, the D2 resistance is infinite, which is equivalent to cut-off; Two 10K resistors R3 and R4 provide a DC bias of 2.5V.
3 software system designThe software module is an important part of the system. The computer mouse obtains the surrounding information through infrared detection to complete the basic actions such as forward, turning, sprint and stop. In addition, it also obtains the information to realize the search of the optimal path and complete the final sprint. This design uses modular design and calls various functional subroutines through the main program. The main program flow chart and interrupt flow chart are shown in Figure 5 (a) (b).4 experimental verification and analysis
(1) The amplification design based on frequency selection network is used in the infrared sensor ranging system. Due to the selection of national standard for resistance and capacitance, the center frequency cannot fall at 38kHz. The center frequency of dual t frequency selection network is F0 = 1 / 2 RC, R / C = 10K / 430pf, F0 = 37khz. The amplitude frequency characteristics simulated by Multisim are shown in Figure 6. The hardware experimental circuit is built, and the center frequency does not fall at 37khz but 30kHz, Reduce the RC value for multiple tests. When R / C = 9.1k/430pf, the center frequency falls at 38kHz.
(2) The labyrinth wall is made of hollow white plastic, and a large part of infrared light is transmitted, coupled with the influence of sunlight. Therefore, the transmitting tube can be sleeved with a black outer tube to reduce external interference; The ARM microprocessor generates PWM signal and sends it to the infrared transmitting tube, and the receiving tube receives the modulated infrared signal; The level conversion is realized by triode, the transmission power is increased by adjusting potentiometer, the signal is adjusted and amplified to the best range of a / D conversion, and the desired processing accuracy is obtained. A set of data of infrared measurement distance and output voltage are obtained through multiple measurements in the experiment. Taking the obstacle distance s as the abscissa and the voltage value u after frequency selection amplification as the ordinate, the curve is drawn with MATLAB. The relationship between voltage value and distance is u = 0.1195 4.5962 * s-1, as shown in Figure 7.
(4) Using the STM32 timer function, the required PWM signal is modulated through software programming to control the motor and transmit infrared. Figure 8 shows the PWM signal of ch1 channel of timer4 with output frequency of 38kHz and duty cycle of 30%.5 ConclusionIn this paper, a computer mouse control system based on stm32f103rct6 is designed. Based on MATLAB and muhisim simulation, the RC parameters of frequency selection network are determined, and the relationship diagram between distance and voltage value is obtained through experiments, which reflects the good frequency selection characteristics of symmetrical RC dual T network; Hollow cup DC motor with high efficiency and fast response is selected for motor and drive module. The test shows that the design scheme can meet the system requirements.