Smart car that can autonomously identify roads based on photoelectric sensors

Publisher:恬淡如云Latest update time:2012-08-09 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

introduction

This article mainly designs an intelligent car that can recognize roads autonomously. The whole system uses a 16-bit single-chip microcomputer mc9s12dg128. The model car itself has a differential and rear-wheel drive. It is necessary to design an automatic control system based on the single-chip microcomputer so that the model car can run autonomously on a closed track.

The car model and the controller form an automatic control system, as shown in Figure 1. The system hardware is based on a single-chip microcomputer, equipped with sensors, actuators and their drive circuits, while the information processing and control algorithms are completed by the single-chip microcomputer software. The system design requires the single-chip microcomputer to combine the rapid judgment of the path, the corresponding steering servo motor control and the control of the DC drive motor precisely.

The design of the smart car is based on the principle of simple circuit design and high flexibility of the car body, under the premise of ensuring the reliable operation of the model car. The two major focuses of the design are the layout and circuit design of the photoelectric sensor and the design of the line-following control algorithm.

The second section of this paper mainly introduces the circuit design and layout of the photoelectric sensor, which is the key to signal acquisition and is equivalent to the "eyes" of the smart car; the third section mainly introduces the line-following control algorithm, which is the core of control and is equivalent to the "brain" of the smart car; finally, the fourth section gives a general description of the hardware, software design and experimental conditions of the smart car.

1. Photoelectric sensor

Selection and circuit design of photoelectric sensors

The photoelectric sensor is located at the front of the smart car and plays the role of pre-judging the path. The light it emits has different reflectivity for white and black, so different voltage values ​​can be obtained. After being input into the single-chip computer, the voltage is compared through a certain algorithm to determine the position of the black line, thereby controlling the rotation of the servo. This method is easy to implement, has a fast response speed, good real-time performance, and low cost.

This paper selects the reflective infrared sensor TCR5000, which is basically suitable for cost performance. There are various designs of infrared photoelectric sensor circuits. Since the algorithm in this paper adopts the sensor array empirical judgment method, a digital output sensor circuit is used for easy control, as shown in Figure 2.

The photoelectric tube uses pulse modulation to emit light, that is, vo is the pulse voltage generated by the oscillation circuit, which is easy to filter out external interference. Although the circuit is relatively complex, it is enough to ensure the stable driving of the model car.

Research on the layout of photoelectric sensors

The layout of the photoelectric tube array directly affects the line-following effect of the smart car. Generally speaking, there are two typical layouts: a straight line layout and a W-shaped layout.

The so-called "straight" layout is to arrange multiple sensors in a straight line. This sensor layout is the most common, and the algorithm is easy to implement in theory. Its disadvantage is that it has almost no prediction function for the curvature of the track. Therefore, this layout is generally not used.

The "W" layout is to arrange multiple sensors in a "W" shape. Since the sensors are distributed in two rows, the "W" layout enables the smart car to have a certain prediction function for the curve, which is particularly reflected in the moment when the straight road enters the curve. When the rear row of sensors is still on the straight road, the front row of sensors has already entered the curve. The disadvantage is that it increases the complexity of the control algorithm. When judging the rotation direction of the servo, the previous detection data is often required. The possibility of empirical judgment also increases with the increase in the number of sensors.

Photoelectric Sensor Layout Simulation

After multiple simulation experiments, the layout and number of sensors were finally determined. A "W"-shaped layout was adopted as shown in Figure 3, with a total of 13 sensors, 8 in the front row and 5 in the back row, with a spacing of 3.5 cm between the front and back rows. This spacing was set to have a certain predictive function for the track. The specific layout and simulation results are shown in Figure 4.

[page]

2. Line-following control algorithm

This paper adopts empirical feedback control, that is, on the basis of ordinary empirical control, the idea of ​​PID control is added, three control constants of proportion, integration and differentiation are introduced, feedback is implemented, and the control method of integral separation is adopted.

The line-following control algorithm uses the comprehensive detection signals of the front and rear rows of sensors to infer the precise steering and specific speed of the model car. The method of direction judgment is as follows: as shown in Figure 3, first judge the situation of the 5 sensors in the lower row, assume that s3 is at the black line position, and then observe the 8 sensors in the upper row. At this time, s3 divides the upper row of sensors into left and right sides. Since the distance between two adjacent sensors is slightly larger than the width of the black line, only two sensors can detect the black line at any time. In this way, the steering situation of the model car can be basically judged by analyzing the upper and lower rows of sensor signals. For example, at a certain moment, s3 and s8 detect the black line, which can roughly determine that the model car should turn right, and the steering and approximate angle of the servo can be determined based on the angle between the connecting line of the two sensors and the vertical direction.

However, it should also be noted that when the car model enters the left curve, s3 and s8 may detect the black line together. In this case, the sensor signal at the previous moment should be checked, that is, the situation of detecting s4||s13. If the result of s4||s13 is 1, it is considered that the car model should turn left, and if the result of s4||s13 is 0, it should turn right. The process of a direction judgment is shown in Figure 5.

Two arrays are created in the program, one to store the signal detected each time, and the other to store the current signal after control is implemented as historical data. After adding this idea of ​​historical record judgment, the control is more accurate.

In addition to the above judgment rules, there are two more situations that need to be considered. That is, the situation where only one sensor detects the black line and the situation where the track crosses. For the situation where only one sensor detects the black line, it is also necessary to check the sensor signal at the previous moment. For example, at a certain moment, only s6 detects the black line. If s5 detected the black line at the previous moment, the car model turns left. If s7 detected the black line at the previous moment, the car model turns right.

For the case of a cross track, a "filtering" idea is used to "filter" it out. When encountering a cross track, there will inevitably be a situation where several sensors in the same row detect black lines at the same time. At this time, a command is given to the model car to make it go straight and eliminate the cross track.

This is the line-following control algorithm of this system based on empirical logical judgment. On this basis, better control effects can be achieved by adjusting various parameters through continuous experiments.

3. Experimental Results

Hardware Design

Motor drive circuit

The motor driver uses mc33886 as the driver chip, and its principle is shown in Figure 6. The forward and reverse rotation of the motor is controlled by sending PWM waves to the in1 and in2 ports. Forward rotation accelerates the smart car, and reverse rotation decelerates. By changing the duty cycle of the PWM wave, the rotation rate of the motor can be controlled.

Speed ​​detection circuit

This paper uses an incremental photoelectric encoder to measure vehicle speed. The frequency of its output pulse is proportional to the speed. The frequency of the pulse can be obtained by measuring the number of pulses in a unit period or the pulse period, with high accuracy.

Power conversion circuit

The smart car system is equipped with a 7.2v battery that can directly power the DC motor. The voltage required by the microcontroller, photoelectric sensor and photoelectric encoder is 5v, and the servo steering engine is 6v. These voltages are regulated by the 7.2v battery.

The microcontroller and photoelectric encoder are powered by the 5V voltage output of the voltage regulator chip 7805. The number of photoelectric sensors is large, the power consumption is high, and the power supply stability is higher, so the high-efficiency chip LM2575 is used to power it. The chip used to power the servo is the low-voltage dropout adjustable output three-terminal linear regulator LM1117, which provides functions such as safe operation protection on the chip.

[page]

Software Design

The software design is implemented in modules, where the main program includes clock initialization, I/O port initialization, servo motor initialization, signal acquisition and control algorithm. The program flow is shown in Figure 7.

4. Experimental results and analysis

The S12 core development board provided by the organizing committee was fully used in the program development process. It is a minimum system composed of the MC9S12DG128 single-chip machine. The MC9S12DG128 belongs to the HCS12 series of single-chip microcomputers and is a high-performance 16-bit microcontroller launched by Motorola. It can provide 32-512KB of third-generation flash embedded memory, the bus speed can reach 50MHz, and the peripheral clock can reach 25MHz. It also has coding efficiency and on-chip error correction capabilities, and is upward compatible with the MC68HC11 and MC68HC12 structural coding. The MC9S12DG128 single-chip microcomputer has 112 pins, of which the pins related to the CPU are compatible.

The S12 development board has a reset circuit, crystal oscillator and clock circuit that constitute the minimum system, an RS-232 driver circuit for the serial interface, and a +5V power socket. The development monitoring program has been written into the microcontroller. 8 small lights are used to debug the application system. All I/O ports of the microcontroller are led out through two 64-pin European plugs.

During hardware debugging, the functions of each module are tested separately, with a focus on adjusting the photoelectric sensor. The output signal should be different when it senses the black and white lines. When sensing the white line, the comparator outputs a low level, and when sensing the black line, the output is a high level. During software debugging, the BDM development tool can be used to display the data in the internal memory of the microcontroller when it is running.

Through the joint debugging and experiment of hardware and software, some problems appeared, but the effect was greatly improved after the improvement of the program and the reassembly of the car model. Finally, the car model can run along the track, but there are still problems such as high power consumption and steering delay.

Conclusion

Based on the principle of automatic control, this paper uses the road deviation signal of the pathfinding module to enable the intelligent car to achieve track tracking, and uses PWM technology to control the speed of the motor and the steering of the servo.

This article focuses on the "W"-shaped layout of photoelectric sensors and the line-following control algorithm, which are the key to ensuring that the smart car can run along the line. The "W"-shaped layout enables the smart car to have the ability to predict the road, while the line-following control algorithm enables the car to turn quickly and correctly.

Through the simulation and experiment of intelligent car, it is shown that the whole system is feasible, and the control strategy and software and hardware of the system are basically reasonable. In terms of control, although the classic PID control has a good control effect in motor speed regulation, the PID control effect is affected because the dynamic model of the car model changes due to different vehicle conditions. In the future, fuzzy control can be considered to make the algorithm more intelligent and the system more adaptable.

Reference address:Smart car that can autonomously identify roads based on photoelectric sensors

Previous article:Tips for Automotive Embedded System Developers to Choose the Right MCU Architecture
Next article:CMOS automotive electronic regulator based on single chip microcomputer

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号