1. Working principle of computer mouse
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 a stable voltage for the entire system, and the gyroscope and compass module determine the direction of the computer mouse, and analyze the coordinates according to the distance traveled. The hardware composition is shown in Figure 1.
2.1 Power Module
Power regulators usually use linear voltage regulators (such as LM7805), which have the advantages of adjustable output voltage and high voltage regulation accuracy. However, their linear adjustment working mode has a large "heat loss" during operation, resulting in low power utilization and failure to meet the requirements of portable low power consumption. Switching power regulators, unlike linear voltage regulators, work 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 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 power the infrared module and the human-computer interaction module. The 5V is then 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 calculation, and outputting real-time control quantity. 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 models of devices include 2 12-bit ADCs, 3 general 16-bit timers and a PWM timer, as well as standard and advanced communication interfaces: up to 2 I2C and SPI, 3 USARTs, a USB and a CAN, which meet the requirements in terms of storage capacity and computing speed.
2.3 Motor and drive module
In order to improve the system power and reduce power consumption, the drive circuit uses the integrated circuit chip L298N based on pulse width modulation. The more common one is the 15-pin Muliwart package L298N, 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 to drive 46V, 2A or less motors, 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. In this design, a hollow cup DC motor is used, 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 more than 90%; starting and braking are fast, and the response is extremely fast; its weight and volume are relatively reduced by 1/3-1/2, and the speed is adjusted by adjusting the pulse duty ratio through PWM.
2.4 Infrared detection module
The infrared detection module is mainly responsible for monitoring and processing the maze environment. 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 features:
(1) The number of infrared sensors has been increased from 5 to 6. In addition to the two 45-degree angles in front, left, right, and front, an additional set of infrared sensors is added in the front. By integrating the information of the two sets of sensors in the front, a 45-degree angle can be achieved at the intersection. Compared with the previous 90-degree right-angle adjustment, this saves time and improves efficiency.
(2) Using an amplifier design based on a dual-T frequency-selective network, the infrared sensor measures the distance between the computer mouse and the obstacle based on the strength of the reflected signal. In the past, an integrated infrared receiving sensor (such as IRM8601S) was used, which has an automatic gain control circuit, a bandpass filter circuit, a decoding circuit, and an output drive circuit integrated in the receiving head. However, since the detection signal output is a digital signal, it can only determine whether there is an obstacle, and cannot calculate the distance based on the strength of the detection signal output. This design uses a frequency-selective amplifier design based on a dual-T frequency-selective network and TLC084 to achieve different gains for different frequencies, amplify useful signals, and filter out or suppress useless signals.
(3) Emit three frequency modulation waves to reduce interference between signals. The six groups of sensors are divided into three groups. The two groups of sensors on the left and right are responsible for detecting whether the computer mouse is walking on the center line, so as to make posture corrections in time; the two groups of sensors on the left front and right front are mainly used to check whether there is an intersection ahead; the two groups of sensors in the front 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, since 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, the distance between the vehicle body and the walls on both sides is only about 3cm, so the emission frequency of the left and right sides is selected as 33kHz, the left front and right front are 35kHz, and the front is the farthest, with an emission frequency of 38kHz. See Figure 3 for details.
This design has improved the hardware circuit. The STM32 timer outputs three PWM signals. Every two groups of infrared transmitting tubes share one PWM signal. After encountering an obstacle, 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+12.5 ADC cycles at the highest sampling speed, and reaches a speed of 1MSPs at a 14M ADC clock. The infrared ranging 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; R3 and R4, two 10K resistors, 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 obtains information to search for the optimal path and complete the final sprint. This design uses modular design, calling 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 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 characteristic simulated by mul TI sim is 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 walls of the maze are made of hollow white plastic, and a large part of the infrared light is transmitted. In addition, due to the influence of sunlight, 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, and the receiving tube receives the modulated infrared signal; the triode is used to realize the level conversion, and the potentiometer is adjusted to increase the transmission 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 infrared measurement distance and output voltage data is obtained, with the obstacle distance S as the horizontal coordinate and the voltage value U after frequency selection amplification as the vertical coordinate. The curve is drawn using matlab, and 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 TI mer4.
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.
Previous article:Porting μC/OS-II to AndesCore™ N1033A-S Processor
Next article:7 wonderful design examples based on STM32 microcontroller
- Popular Resources
- Popular amplifiers
- 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
- Solution to the error "Unable to connect to localhost:3333" when downloading the Xianji development board
- Eight working modes of LoRa
- Testing methods and diagnostic analysis for DSP-containing circuit boards
- IoT development kits simplify application design
- Hands-on experience with Erha's image recognition artificial intelligence vision sensor.
- [Project source code] Set a password for the root of the Ubuntu system
- Pingtouge RVB2601 board-GUI and operating system tasks
- MSP430G2553ADC conversion program
- How to choose the right fuse for your design
- Build an IP surveillance camera system using low-cost FPGA