Realization of infrared obstacle avoidance automatic vehicle based on 51 single chip microcomputer

Publisher:qin199099Latest update time:2012-09-18 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Recently, the school was on holiday for three days, so I had a lot of time. I referred to the knowledge of single-chip microcomputers and analog electronics that I had learned, and decided to start my first formal electronic production - "Realization of infrared obstacle avoidance automatic car based on 51 single-chip microcomputer". In the end, it was successful, the whole car debugging achieved the ideal effect, and the infrared obstacle avoidance function was realized. The video has been uploaded to Youku.com, the video address is http://v.youku.com/v_show/id_XMTYzNDc4MjA4.html. Welcome everyone to watch, discuss, and put forward opinions and suggestions.

Here is some basic information:

———————————————————————Car parameters——————————————————————————

Obstacle detection method: infrared detection (detection module power consumption 7mA)

Car model geometry dimensions: 149 x 102 x 59 (mm)

Car model wheelbase: 120 (mm)

Obstacle detection accuracy: 75 cm

Power system: 4 x 1.5 v dry batteries/4 x 1.2 v rechargeable batteries and their regulated output

Motor: DC reduction motor, 1~12V working voltage, transmission ratio: 71.2:1

Main control chip: STC89C52MCU

Other chips: LM7806 LM7805 STC11F01, etc.

—————————————————————Group Information——————————————————————————

Panelists:

Wang Taijie: Class 0804211, good at hardware, strong welding technology, sufficient hardware knowledge, responsible for the construction and debugging of the motor drive part in this production.

Sun Xuejun: Class 0904211, is good at programming, has a solid foundation in C language, and has open-minded thinking. In this production, he is responsible for debugging the program driver part.

Li Xianghua: Class 0804211, responsible for the power supply part in this production.

Group advantages:

The hardware and program are coordinated, and each person is responsible for their own module. Only the final module interface is provided, so that teammates do not have to pay attention to the internal structure of the other party's module. They only need to complete the interface connection, which greatly reduces the content that each person is responsible for and improves efficiency.

———————————————————————Production process and time—————————————————————————

April 3, 2010 (Saturday):

The team members selected and optimized the circuits of each module, built and welded the circuits, debugged each module, and determined the module interaction interface; the main control program idea was formed, and the test program was written to test the software and hardware. Finally, the modules interacted, the overall debugging was carried out, the main program was determined, and the details were finalized.

April 4, 2010 (Sunday):

Module interaction, overall debugging, and modification of main control program details; after layout, each hardware module is transferred to the vehicle body, and finally welded to form the whole vehicle. The main control program is downloaded, debugged, and finally successful.

—————————————Technical Data———————————————————

Design ideas:

In order to save the number of motors and the complexity of the circuit, the infrared obstacle avoidance car (hereinafter referred to as the car) adopts the principle of active front wheels and passive rear wheels. The front wheels are driven by dual motors and the body steering is achieved by differential method.

The detection part uses an infrared transmitting tube to emit infrared light. After encountering an obstacle, it is reflected and received by the infrared receiving tube, generating a level conversion. The level output of the infrared detection module is detected by the microcontroller I/O port to determine whether there is an obstacle ahead. After detecting an obstacle, the motor drive circuit is controlled through the microcontroller I/O port, and different voltages are output through the motor drive circuit to generate differential speeds, realize steering, and ultimately achieve the goal of obstacle avoidance.

Power module:

Considering the flexibility of the car, we abandoned the solution of using AC power. During the production and debugging process, we used 4 1.5V No. 5 Nanfu batteries. After the battery box was connected in series, a stable voltage output of 5.9~6.5V was obtained, which directly powered the motor drive circuit. However, considering that the operating voltage of the 51 microcontroller is 4.5V~5.5V, and its requirements for the operating voltage are relatively strict. In this regard, we envisioned using a voltage regulator chip based on the LM7805 voltage regulator chip to output a constant voltage of 5V. See the attached power supply circuit diagram. Since there was only one LM7806 on hand during the production, we connected an IN4007 diode in series at the output end to generate a 0.7V voltage drop, and finally obtained a stable voltage output of 5.2V~5.3V to power the microcontroller. To improve the stability of the system.

When the vehicle was finally formed, we used a 5V voltage regulator diode to stabilize the voltage for two reasons: first, it reduced the power consumption of the power circuit, and second, it reduced the production cost. Considering the unavailability of disposable dry batteries, we used a solution of connecting 4 rechargeable batteries in series through a battery box when forming the vehicle to reduce subsequent production costs. Considering the singleness of the voltage output end, we considered using a 10V voltage regulator tube to make another power output to provide working voltage for the motor, which can increase the motor power to a certain extent and increase the running speed of the vehicle.

Motor drive module:

Considering the high price of motor driver integrated chip (18~30 yuan/chip), we abandoned the solution of using motor driver chip and turned to seek discrete component analog circuit drive. After the final choice, we adopted the dual triode control switch circuit, using the sensitivity of the triode, and connecting one end of it to the I/O port of the MCU. The triode switch can be controlled by controlling the ratio of the number of 0 and 1 pulses output by the I/O port to achieve the purpose of controlling the output voltage. The drive circuit diagram is attached.

Main control program:

In order to reduce the complexity of the program, we use three I/O ports, one I/O port is used to receive the infrared part of the level conversion and detect obstacles, and the other two I/O ports are connected to the motor drive circuit, and the program is used to generate the 0 and 1 pulse quantity ratio to control the drive circuit switch. Finally, the speed difference is achieved to achieve steering and obstacle avoidance.

The main control program is as follows:
/* *****************************
Program development environment Keil uVision3Language
: CWriter
: Sun Xuejun
Time: 2010/04/04
***************************** */



/* *****************************
Main program and comments are as follows:

***************************** */
#include //Add function library
#define uint unsigned int //Macro definition
#define uchar unsigned char //Macro
definitionsbit s=P3^5; //Define infrared obstacle avoidance detection portsbit
m1=P3^4; //Define motor M1 level output portsbit
m2=P3^6; //Define motor M2 level output portvoid
delay_ms(uint z); //Declare delay functionmain


() //Main function
{
uint i=0; //Initial value settingm1
=1;
m2=1;
while(1) //Infinite loop
{
if(s==0) ​​//S=0 means there is an obstacle ahead, turn
{
for(i=0;i<5;i++)
{
m1=0;
m2=1;
delay_ms(15); //The state is maintained for 15ms
m1=1;
m2=1;
delay_ms(5); //The state is maintained for 5ms
}
}
if(s==1) //S=1 means there is no obstacle ahead and driving in a straight line
{
m1=1;
m2=1;
delay_ms(10); //The state is maintained for 10ms
}
}
}



void delay_ms(uint z) //Delay function loop nesting principle
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}

/*****************************

The program is finished and after testing, it is confirmed that the program complies with the hardware and the functions achieve the expected goals.

******************************* */


————————————————————Function expansion————————————————————————————

1: The human-computer interaction of this vehicle is not strong, the vehicle speed is not displayed, the obstacle display is not obvious, and there is no turn signal prompt.
It is expected that speed measurement and LCD or digital tube display modules can be added. The display module can be attached to the vehicle body itself or be a separate module, and wireless transmission is used to send data from the vehicle body to the terminal display.

2: Add automatic tracking function

3: Add automatic braking function

4: Remote control function

--------------------complete----------------------------

Welcome to discuss, let’s learn and improve together, and welcome advice from experts!

Reference address:Realization of infrared obstacle avoidance automatic vehicle based on 51 single chip microcomputer

Previous article:Digital tube display of AD conversion
Next article:Summary of Design and Production of Electronic Temperature Alarm

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号