1 Introduction
The SRF05 ultrasonic sensor imported from the UK was used in the project development. Its echo feedback and ranging method are special compared with the commonly used ultrasonic sensors, and it is slightly difficult to implement in ARM. However, the sensor has a high accuracy of up to 1cm. Therefore, the use of this sensor eliminates the infrared ranging module used for close-range ranging and saves hardware resources.
The minimum system of the robot is a touch screen module, an ultrasonic module, a camera image acquisition module, and a DC motor closed-loop control system. Distance measurement is the most important part of the entire system, which directly affects the accuracy of the motor's running distance and the image acquisition control within the effective range. The entire system is completed in the ARM9 and Linux platforms, and each module is implemented in a device driver manner to make the module control more convenient.
2 SRF05 Ultrasonic Distance Measurement Method
Provide a 10us pulse to trigger the ultrasonic sensor, SRF05 will emit 8 cycles of overclocked pulses with a frequency of 40khz. At this time, the level on the echo port becomes high, and the timer starts timing. When the echo becomes low, it proves that there is an obstacle and the timing is stopped. The width of the high pulse is proportional to the distance measured. The effective ranging range of the ultrasonic wave is 1cm~4m. Therefore, if there is no obstacle or the obstacle is greater than 4m, the echo will still become low and the timer time is 30ms. Therefore, when measuring the distance, the period of the timer should be greater than 30ms so that the distance can be effectively measured.
The principle is shown in Figure 1.
3. Ultrasonic ranging software implementation
Figure 2 is the flow chart of ultrasonic ranging.
3.1 Echo detection acquisition method
The detection of ultrasonic echo is difficult, because in ARM, a port interrupt can only set one trigger mode. If it is set to rising edge trigger, the timer can be turned on, but the falling edge cannot be captured, and the timer cannot be turned off, so the distance cannot be measured. Therefore, it is implemented in software. First, two time delay functions usdelay() and msdelay() are set, so that the ultrasonic trigger can be turned on after giving a high pulse of 10us, and then the timer is turned on. Then an external interrupt eint1 is set to connect to the echo port of the ultrasonic sensor and set to falling edge trigger. When the falling edge comes, the timer is turned off and the read value is the pulse width. Then the distance is obtained according to the distance of the obstacle = (ECHO high level time) * sonar speed/2. The relationship between v and temperature in air: v=331.5√1+T/273 m/s, T is Celsius temperature. In general, the ultrasonic velocity is close to the speed of sound, which is about 343.2m/s under the influence of indoor temperature.
3.2 Implementation of Ultrasonic Triggering
A software timing function usdelay() is accurately designed using a digital oscilloscope. The specific implementation is as follows.
Then usdelay(1) is 10us. This function is used to extend the pulse for 10us after giving the excitation high pulse and then turn off the pulse.
A msdelay() function is also designed to control the time value of the entire ranging cycle.
msdelay(1000) is used in the main function to delay by 1s, so that the timer can have enough time to detect the echo without interfering with the other three ultrasonic signals.
As follows.
3.3 Implementation of ultrasonic echo detection
The timer and external interrupt are needed to calculate the pulse width of echo detection. The external interrupt is connected to the ultrasonic echo and set to the falling edge trigger. The timer is initialized as follows.
rTCFG0=0x9595; //Prescaler value is 95
rTCFG1=0x00000; //Split value 1/2
rTCNTB0=10000; /
According to T = [TCNTB0 * (TCFG0 + 1) * (1 / TCFG1)] / 50MHZ, the period of the timer is 60ms, which is enough to calculate the echo time.
External interrupt 1 is initialized as follows
rGPFCON=0xaa; //GPF1 is set to EINT1
rINTMOD=0x0; //Set to normal interrupt
rGPFUP=0xf; //Disable GPF0 pull-up resistor
pISR_EINT1=(unsigned)Eint1Handler; //Create interrupt vector
EnableIrq(BIT_EINT1); //Enable interrupt
rEXTINT0 =0x492; // EINT1 falling edge trigger
According to T = [TCNTB0 * (TCFG0 + 1) * (1 / TCFG1)] / 50MHZ, the period of the timer is 60ms, which is enough to calculate the echo time.
3.4 Computer distance in external interrupt
3.5 Loop Control and Polling Ranging
Due to interference between ultrasonic waves, the ultrasonic waves are turned on in turn in a polling manner, and only one is measured at a time. This can effectively avoid interference. In order to improve real-time performance, the timer cycle can be controlled, for example, set to 35ms, so that the polling of four ultrasonic waves is about 140ms, which is enough to meet real-time requirements.
4 Implementation of robot control
Figure 3 is the overall structure diagram of the closed-loop system for controlling the robot's DC motor using ultrasonic feedback information.
The ultrasonic sensor in the Linux system is a read-only character device. The specific application is to open the ultrasonic device under the application, then measure the distance in the driver, and transmit the measured data to the application. The application has an ultrasonic obstacle avoidance algorithm. According to the algorithm, the position of the obstacle is determined and the DC motor control signal is given for obstacle avoidance navigation.
The graphical interface in the touch screen contains the robot's command settings, which can set the running speed, the opening and closing of image acquisition and ultrasonic modules, whether to turn on the robot's fuzzy algorithm running trajectory or use ordinary PID adjustment, which makes the robot have many options to choose from.
Each action of the robot is given the running time according to the value measured by the ultrasonic sensor and the current instantaneous speed of the robot. When encountering an obstacle (0 5 Conclusion This paper uses a new type of ultrasonic sensor to realize ultrasonic ranging on a mobile robot based on ARM9 and embedded Linux platform, and uses ultrasonic sensors to control the motion system and image acquisition system. The robot has been successfully applied to the development of this project and achieved good results. The innovation of this paper is to use a new type of high-precision ultrasonic sensor and use software methods to overcome the problem that it is not conducive to detecting echoes in ARM9. It is successfully applied to the trajectory control of the mobile robot, which greatly improves the robot's walking and image acquisition timeliness.
Previous article:ARM7 lpc2148 single-channel LED control experiment
Next article:ISP Design Based on ARM Embedded System
- 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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- 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
- How does AD software collect company information?
- [GD32L233C-START Review] 11. GD32 ISP software does not support GD32L233 yet
- Last day! Answer questions to win prizes! Practical sharing | Design a reliable switching power supply from scratch
- How to detect whether the switching power supply transformer is good or bad?
- micropython update: 2021.4
- The battery voltage is pulled down
- Is there any abnormal sound from the common mode inductor?
- There's a problem with the project
- bq27411-g1 (single-cell fuel gauge) bq27541 (single-cell fuel gauge) bq27546-g1 (single-cell fuel gauge)
- Playing with circuits (2) - Killing LM5175