Design of computer mouse control system based on STM32F

Publisher:eta17Latest update time:2016-09-20 Source: eefocusKeywords:STM32F Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
A computer mouse (micromouse) is a micro-robot controlled by a microprocessor that integrates multiple functions such as environmental perception, dynamic decision-making and planning, behavior control and execution. At present, most computer mice use Luminarv Micro Stellaris R series LM3S101, LM3S102, LM3S615 or single-chip microcontrollers. Its infrared detection module uses an integrated infrared sensor, which can only determine whether there are obstacles but cannot measure distance. The motor part uses a stepper motor, which consumes a lot of power and has a slow speed. In addition, the software system mostly uses traditional center-left or center-right algorithms, which are inefficient. This paper designs a 32-bit ARM chip STM32F103RCT6 based on the Cortex-M3 core as the operation control center, which generates PWM signals to modulate infrared transmission and reception to achieve distance measurement, and is equipped with a hollow cup DC motor. By improving the intelligent maze algorithm, the computer mouse can complete the maze search and sprint tasks excellently and efficiently.

1 How does a computer mouse work?

Six groups of infrared sensors are installed around the computer mouse, which sense the left, left front, front, right front, and right respectively. The transmitting end emits infrared rays of a certain frequency, and the receiving end determines whether there are obstacles through reflected waves in six directions, and stores the information of the cells in real time. The maze information fed back by the six groups of infrared sensors is used to control the computer mouse to complete obstacle avoidance, turning, acceleration and other actions, and the intelligent algorithm is used to traverse part or all of the cells of the maze, and the maze information is stored in an effective data structure. The microcontroller uses the maze efficient algorithm to find an optimized path based on the recorded information, thereby achieving the maximum sprint from the starting point to the end point.

2 Hardware Circuit Design

In order to complete the maze detection and sprint tasks, the computer mouse needs to have the following functional modules: the ARM microprocessor as the control core coordinates the normal operation of each functional module; the motor and drive module controls the motor start and brake in real time; the infrared detection module is responsible for infrared detection and perception; the power supply provides stable voltage for the entire system, and the gyroscope and compass module determine the position of the computer mouse, and analyze the coordinates according to the distance traveled. The hardware composition is shown in Figure 1. 2.1 Power Supply Module The power supply regulation device usually uses a linear voltage regulator (such as LM7805), which has the advantages of adjustable output voltage and high voltage regulation accuracy, but its linear adjustment working mode has a large "heat loss" during operation, resulting in low power utilization and cannot meet the portable low power consumption requirements. The switching power supply regulator, unlike the linear voltage regulator, works in a fully on or off mode. By controlling the on and off time of the switch tube, it effectively reduces the "heat loss" during operation and improves 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 switch-mode power supply LM2596 is used to reduce the 12V DC voltage to 5V to power the infrared module and the human-machine interaction module. Then, the 5V is reduced to 3.3V through the AMS1117 for the ARM processor and other modules. 2.2 Microprocessor Module The microprocessor is the core of the entire control system. It completes the functions of obtaining path information from the infrared detection module, collecting instantaneous speed, performing data processing, controlling algorithm calculations, and outputting real-time control quantities. In order to ensure the practicality and scalability of the system, this control system uses the "enhanced" series STFM32F103RCT6 launched by STMicroelectronics. The STM32F103xx enhanced series uses a high-performance ARM Correx-M3 32-bit RISC core with an operating frequency of 72MHz, 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 device models include two 12-bit ADCs, three general-purpose 16-bit timers and a PWM timer, as well as standard and advanced communication interfaces: up to two I2Cs and SPIs, three USARTs, one USB and one CAN, meeting the requirements in terms of storage capacity and computing speed. 2.3 Motor and drive module In order to increase system power and reduce power consumption, the drive circuit uses the L298N integrated circuit chip based on pulse width modulation. The more common one is the L298N in the 15-pin Muliwart package, which contains a four-channel logic drive circuit, that is, a high-voltage and high-current dual full-bridge driver with two H bridges, which can drive and control two DC motors. The chip uses a dual power supply for supplying motor power and logic level power, and can accept standard TTL logic level signals, drive motors below 46V and 2A, and can drive inductive loads. Among them, ENA and ENB are control enable terminals, IN1, IN 2, IN3, and IN4 are control level input terminals, and the circuit is shown in Figure 2. This design uses a coreless DC motor, which has outstanding energy-saving characteristics, sensitive and convenient control characteristics, and stable operation characteristics. The maximum efficiency is generally above 70%, and some products can reach above 90%; it starts and brakes quickly, and responds very quickly; its weight and volume are relatively reduced by 1/3-1/2, and the speed is adjusted by adjusting the pulse duty cycle through PWM. 2.4 Infrared detection module The infrared detection module is mainly responsible for maze environment monitoring and processing. The infrared light is modulated and emitted by the transmitting tube, and the receiving tube receives the reflected light from the maze wall. The distance to the partition wall is determined based on the strength of the received reflected signal. Compared with the traditional infrared detection method, this system has the following characteristics: (1) The number of infrared sensors has increased from 5 to 6. In addition to the two 45-degree oblique angles in front, left, right, and front, an additional group of infrared sensors is added in the front. The 45-degree oblique walking at the intersection is achieved by integrating the information of the two groups of sensors in the front. Compared with the previous 90-degree right-angle adjustment, it saves time and improves efficiency. (2) Adopting the amplifier design based on the double T frequency selection network, the infrared sensor can measure the distance between the computer mouse and the obstacle according to the strength of the reflected signal. In the past, an integrated infrared receiving sensor (such as IRM8601S) was used. Its receiving head integrates automatic gain control circuit, bandpass filter circuit, decoding circuit and output drive circuit. However, since the detection signal output is a digital signal, it can only determine whether there is an obstacle or not, and cannot calculate the distance according to the strength of the detection signal output. In this design, a frequency selection amplifier design based on the double T frequency selection network and TLC084 is adopted to achieve different gains for different frequencies, amplify the useful signal, and filter out or suppress the useless signal. (3) Emit three frequency modulation waves to reduce interference between signals. The 6 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 center line so as to make posture corrections in time; the left front and right front groups of sensors are mainly used to check whether there is an intersection ahead; the two front groups of sensors cooperate with the motor to achieve a 45-degree turn. The higher the infrared light emission frequency, the longer the propagation distance. In this design, the distance between the maze walls is 16.8cm (cell 18cm, wall thickness 1.2cm), and the width of the computer mouse is generally about 10cm, and the distance between the car body and the two walls is only about 3cm, so the emission frequency is selected as 33kHz for the left and right sides, 35kHz for the left front and right front, and 38kHz for the front distance, which is the farthest. As shown in Figure 3. This design has improved the hardware circuit. The STM32 timer outputs three PWM signals. Every two groups of infrared emission tubes share one PWM signal. After encountering obstacles, they return. The infrared receiving tube collects signals, amplifies the useful signals through the frequency-selective amplifier, and sends them to the 12-bit successive approximation AD converter of the STM32. Since there is a delay in rectification and filtering, AC sampling is used here. The ADC needs 1.5 to 12.5 ADC cycles at the highest sampling speed, reaching a speed of 1Msps under the 14M ADC clock. The infrared distance measurement circuit is shown in Figure 4. When the receiving tube receives infrared rays, D2 is turned on, and the stronger the reflection, the smaller the resistance of D2. When no infrared rays are received, the resistance of D2 is infinite, which is equivalent to cutoff. The two 10K resistors R3 and R4 provide a 2.5V DC bias. 3 Software system design The software module is an important part of the system. The computer mouse obtains surrounding information through infrared detection and completes basic actions such as moving forward, turning, sprinting, and stopping. In addition, it also needs to obtain information to realize the search of the optimal path and complete the final sprint. This design uses modular design, and calls each functional subroutine 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 infrared sensor ranging system uses an amplifier design based on a frequency selection network. Since the resistors and capacitors are selected according to the national standard, the center frequency cannot be exactly 38kHz. The center frequency of the double-T frequency selection network is f0=1/2πRC. R/C=10k/430pF and f0=37kHz are selected. The amplitude-frequency characteristics simulated by multisim are shown in Figure 6. The hardware experimental circuit is built. The center frequency does not fall at 37kHz but 30kHz. The RC value is reduced for multiple tests. When R/C=9.1k/430pF, the center frequency falls at 38kHz. (2) The maze wall is made of hollow white plastic, and a large part of the infrared light is transmitted. In addition, the sunlight affects it. Therefore, a black outer tube is used for the transmitting tube to reduce external interference. The ARM microprocessor generates a PWM signal and sends it to the infrared transmitting tube. The receiving tube receives the modulated infrared signal. The triode is used to realize level conversion. The potentiometer is adjusted to increase the transmitting power so that the signal is adjusted and amplified to the optimal range of A/D conversion to obtain the desired processing accuracy. Through multiple measurements in the experiment, a set of data on infrared measurement distance and output voltage was obtained. The obstacle distance S was taken as the horizontal coordinate and the voltage value U after frequency selection and amplification was taken as the vertical coordinate. The curve was drawn using Matlab. The relationship between the voltage value and the 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 emit infrared. Figure 8 shows the PWM signal with an output frequency of 38kHz and a duty cycle of 30% on the CH1 channel of Timer4.

5 Conclusion

This paper designs a computer mouse control system based on STM32F103RCT6. Based on matlab and muhisim simulation, the RC parameters of the frequency selection network are determined, and the relationship between distance and voltage value is obtained through experiments, which reflects the good frequency selection characteristics of the symmetrical RC double-T network; the motor and drive module use high-efficiency and fast-response hollow cup DC motors. The design can meet the system requirements after experimental verification.

Keywords:STM32F Reference address:Design of computer mouse control system based on STM32F

Previous article:Design and implementation of home intelligent control terminal based on ARM and GPRS technology
Next article:Design of driving circuit for DMD projector based on STM32

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号