Design and implementation of low-cost photoelectric tracking intelligent vehicle

Publisher:BlissfulMomentsLatest update time:2012-04-26 Source: OFweek Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In smart car racing and various smart car applications, the smart car needs to move quickly along a certain track. Ordinary infrared sensors, laser sensors, and camera recognition can effectively extract road track information to solve this problem. Now 16-bit microcontrollers are commonly used as the control core. Ordinary infrared sensors are rarely used because of their shortcomings such as susceptibility to interference and short forward distance. Cameras have rich data information, but low-cost 8-bit microcontrollers cannot process this information well. Laser sensors have moderate costs, and the processed signals are easy to process by 8-bit microcontrollers, which can effectively save hardware costs. Software and hardware design was carried out for the track-finding smart car. The 3-bit freescale microcontroller MC9S08AC16 was used as the control core, laser sensors were used to extract track information, and a low-cost infrared speed measurement solution was used. The algorithm uses an enumeration table lookup method based on PID, which achieves fast and efficient processing. The entire design not only meets the requirements of the racing car's rapid response, but is also a low-cost design solution.

1 Car model installation

The control of the smart car adopts front-wheel steering. The B-type car model adopts the chassis of a 1:16 electric off-road remote control car produced by a domestic manufacturer. Its outstanding features are four-wheel drive and four-wheel independent suspension. Reflective photoelectric sensor is simply arranged in a straight line in front of the car, with 14 transmitters and 7 receivers, one transmitter with two receivers. The sensor's forward range can reach more than 40cm, and the distance between the two laser transmitters is 1.8cm. The sensor unit installation diagram is shown in Figure 1.

Figure 1: Modified smart car

The system uses an infrared sensor as a speed sensor. The infrared sensor is installed on the rear wheel, and black and white tape is pasted on the inner wall of the rear wheel. This installation makes full use of the space and meets the speed measurement requirements. The infrared sensor speed measurement installation diagram is shown in Figure 2. When the wheel rotates, the infrared sensor will output a pulse level, and the speed of the car will be obtained by detecting the pulse frequency. This speed measurement method cannot achieve the accuracy of the photoelectric decoder, but it does not have much effect on the speed processing of the car. The photoelectric decoder is expensive and installed on the gear. When the output of the same power supply and PWM is used, the speed of the car will slow down.

Figure 2 Installation of infrared sensor speed measurement

2 Hardware Design

The power management module uses a 7.2 V 2 000 mAh Ni-Cd battery as the system energy source, and separates 6 V and 5 V through a step-down voltage regulator circuit to power the servo and microcontroller respectively; the H-bridge and its related devices are used to make a DC motor drive module; the steering servo servo controls the steering of the smart car; the infrared sensor measurement module is used to measure the speed of the smart car in real time; the laser sensor is used as the track detection; the system fully utilizes the peripheral modules of the M9S8AC16CG microcontroller, including: timer module, PWM pulse width modulation module, interrupt module, I/O port and real-time clock module, etc.

2.1 Minimum system and motherboard

The system adopts the commonly used minimum system board. The minimum system of the single-chip microcomputer system with MC9S08AC16 as the core mainly includes the following parts: clock circuit (external 8 MHz quartz crystal oscillator), power supply circuit (provides 5 V DC power supply), reset circuit, BDM interface (download and debug programs to the single-chip microcomputer through the BDM head).

The main circuits that make up the system are located on the motherboard, including:

The 7.2 V battery power supply of the power supply voltage regulator circuit will be processed into two 5 V and one adjustable DC output of about 5~7.2 V through three integrated voltage regulator circuits. One 5 V DC power supply is used for the microcontroller and related peripherals , and the other 5V DC is used for the laser sensor alone. The adjustable DC output is used for the servo. This power supply design method can provide different sizes of power supply required, and will not affect the working power supply of the microcontroller when the servo and laser sensor are working.

The interface circuit includes the servo interface, motor drive interface, power supply interface, debugging human-machine interface circuit interface, and single-chip minimum system socket.

The motor driver board is made as a separate unit for the DC motor "H" type bipolar drive circuit.

2.2 Sensor Module

14 transmitters and 7 receivers are used, and two transmitters and one receiver are arranged in a row. Each time, two non-adjacent transmitters are selected for transmission, and two receivers receive them respectively. The IO port of the AC16 microcontroller is controlled, and the sensor to be transmitted is selected by the 74LD164 driver. A 555 chip sends out a 100 kHz frequency oscillation wave, and the laser tube emits light. The receiving part has a matching 100 kHz receiving tube to receive the returned light, and the receiving signals of the 7-way receiving tube are directly fed into the microcontroller. The principle of the sensor is shown in Figure 3.

Figure 3 Schematic diagram of laser sensor

3 Software Design

3.1 Software Design Overview

The main function of the system will execute the program corresponding to the flowchart shown in Figure 4. The debugging program can complete the following functions: checking sensor faults, debugging speed control parameters, setting the servo midpoint, controlling the servo angle parameters, etc. The reading of sensor data refers specifically to the reading of laser sensors. In the timer program, a new round of laser scanning starts every 5 ms, and a group of laser emission tubes are replaced every 125μs. Each group emits two non-adjacent laser signals. After all lasers are emitted 5 times, the track track signal is detected more than 3 times to confirm that it is valid. Only then will the sensor data reading completion flag be set, so the system enters the subsequent program execution every 5 ms. The steering control and speed control of the trolley servo will be discussed in detail later. For the trolley motor speed control, it is a closed-loop control, which combines bang-bang control with P algorithm control. The speed reading of the trolley is completed by the input capture function. When the car moves, the wheels rotate. Every 1/5 turn, the infrared sensor will output a complete pulse cycle. The speed of the trolley is determined by reading the output pulse frequency of the infrared sensor.

Figure 4 Software design flow chart

3.2 Determining the driving state of the car

The track used by the system is 50 cm wide and 25 mm in center. The sensor reads 1 on black and 0 on white. The sensor used on the floor outside the track may read 1 or 0. The laser sensors are arranged in a "one" shape, and the distance between two adjacent sensors is 20 mm. The track is shown in Figure 5.

Figure 5: Track diagram

The possible states of the sensor on the track can be divided into: on the normal track, at the cross line, and out of the track. The system defines a variable Car_State to represent the current state of the car. The following situations may occur:

1) When the car is on the track, one or two sensors will output a high level. If two sensors hit the black spot at the same time, and the two sensors are not adjacent, it is considered an interference signal and no special processing is done. The other coordinates are calculated from -13 to 13 from left to right according to the sensor arrangement method shown in Figure 6. At this time, Car_State is counted as the coordinate hit by the sensor;

2) Hitting more than 10 black dots is counted as a cross line, and Car_State is counted as 20;

3) If the black spot is not hit, the car is considered to be about to run out of the track, and Car_State is counted as 30;

4) There is another situation where the sensor has hit the outside of the track. The sensor that hits the outside of the track may output a high level or a low level. At this time, the situation that may be read may be judged as the first situation, as shown in Figure 5. At this time, the car should continue to turn left, but the judgment is the first situation, so it may turn right. The judgment of this situation cannot be determined solely by reading the sensor, but the trend of the car's movement should also be considered. Because this situation generally only occurs when the car turns a big corner, because the turning angle is not enough, when the car's sensor will hit the outside of the track in the opposite direction, when the angle of turning left or right exceeds a certain value (such as 60°), the sensor on the other side should be shielded, and only the sensor on the side turned to is read. As shown in Figure 5, the car now turns a big left corner, and the right sensor detects an error black spot. At this time, just shield the 7 sensors on the right and read only the left sensor value. In this case, Car_State is counted as 40.

Figure 6 Sensor layout

3.3 Servo Control

The car is on the track: Car_State is an integer between -13 and 13. Due to the small number of photoelectric tubes, the discreteness of the sensor return value is too large, which is not suitable for feedback control. Therefore, the sampling rate should be increased, oversampling should be performed, and then first-order iterative filtering should be performed:

PV al=((Car_State×1 000)+(Pvalx10))/11;

The deviation of the position of the car after 5 ms is iteratively filtered:

Err = ((PVal-PVal1) + (Errx10)) / 11; // Position deviation between two times

P_Offset=Err/P_err; //Negative value is biased to the left and positive value is biased to the right

if (P_Offset<-5) P_Offset=-5; //The maximum left deviation is -5 units

if (P_Offset>5) P_Offset=5; //The maximum right deviation is 5 units

Err is sampled and divided to obtain the P_Offset variable. The value of P_Offset is an integer from -5 to 5. A negative number indicates a deviation to the left, and a positive number indicates a deviation to the right. The larger the absolute value, the larger the deflection angle. The sampling resolution is an adjustable parameter P_err. When P_err is too large, the car will react more slowly. When P_err is too small, the car will react more sensitively, and even a small deviation will easily cause the car to turn more sharply.

The data table Angle_Table[] is organized according to the current position of the car and P_Offset. The table has a total of 27 rows and 11 columns. The element j in the nth row and mth column indicates that when the car's position Car_State is n-13 and the deviation P_Offset is m-5, the value of j is between -10 and 10. A negative value represents a left turn, and a positive value represents a right turn. The angle that the car's servo should turn is jxAngle_C. The adjustable parameter Angle_C can be adjusted according to the track conditions, the servo's reaction sensitivity, etc. Its adjustment is completed in the debugging program. The larger its value, the greater the turning angle under the same conditions.

The control of the servo is achieved by looking up the data table Angle_Table instead of solving it through formulas. This method is more suitable for 8-bit microcontrollers. By looking up the table, the system speed can be achieved that cannot be achieved by calculation.

When the car is crossing the line, Car_State=20 does not change the control of the servo. When the car's sensor cannot hit the black spot and is about to run out of the track or has already hit the track, Car_State=30 or 40. At this time, according to the direction of the car's rotation, the servo is set to the maximum angle to achieve the purpose of finding the black line on the track as soon as possible.

The output PWM of the servo adopts a 5 ms period, which is consistent with the sampling frequency of the car sensor.

4 Experimental results and summary

Through the above method, the car has achieved relatively good test results. On a track with a minimum curvature radius of not less than 50 cm, the car can achieve a speed of more than 2 m per second. Its speed is not much different from that of a system using a 16-bit microcontroller. It should be noted that using variables of different data types during calculations will bring different effects. Experiments have shown that if variables of byte storage type can be used as double-byte variable storage, it will seriously affect the operation of the car. This is caused by the mathematical operations performed in the microcontroller compilation environment. Inappropriate variable definitions and arithmetic operations should be avoided as much as possible.

Compared with the currently popular dual-servo smart car controlled by a 16-bit single-chip microcomputer, this system has a lower hardware cost. The software also avoids more complex calculations based on the characteristics of the 8-bit single-chip microcomputer and adopts a table lookup method. Only a small amount of mathematical calculations are involved in the car position and deviation calculation and the speed P algorithm, so as to achieve a fast response of the system.

Reference address:Design and implementation of low-cost photoelectric tracking intelligent vehicle

Previous article:Design and implementation of interface between 8096 series single chip microcomputer and touch screen chip
Next article:Several SMT welding defects and their solutions

Latest Power Management Articles
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号