Low-cost 8-bit single-chip controlled photoelectric tracking intelligent car

Publisher:ZhenxiangLatest update time:2012-05-30 Source: 21ic Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Smart car In racing competitions 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. The laser sensor has a moderate cost, and the processed signal is easy to process by an 8-bit microcontroller, which can effectively save hardware costs. The software and hardware design of the track-finding smart car was carried out. The 3-bit freescale microcontroller MC9S08AC16 was used as the control core, the laser sensor was used to extract the track information, and the low-cost infrared speed measurement solution was adopted. The algorithm uses the 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. The 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 vision 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.

Sensor unit installation diagram

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 at equal distances. 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 power supply and PWM output are the same, the speed of the car will slow down.

Infrared sensor speed measurement installation diagram

2 Hardware Design

The power management module uses a 7.2 V 2 000 mAh Ni-Cd battery as the system energy source, and uses a step-down voltage regulator circuit to separate 6 V and 5 V to power the servo and microcontroller respectively; an H-bridge and its related devices are used to make a 直流电\'); companyAdEvent.show(this,\'companyAdDiv\',[5,18])"> DC motor drive module; the steering servo servo controls the steering of the smart car; an infrared sensor measurement module is used to measure the speed of the smart car in real time; a laser sensor is used as a track detection; the system makes full use of 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.

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 to 7.2 V through three integrated voltage regulator circuits. One of the 5 V DC power supplies is for the microcontroller and related peripherals, and the other 5 V DC is for the laser sensor alone. The adjustable DC output is for the servo. This power supply design can provide the required power supply of different sizes, and at the same time, the working power of the microcontroller will not be affected when the servo and laser sensor are working.

The interface circuit includes a servo interface, a motor drive interface, a power supply interface, a human-machine interface circuit interface for debugging, and a single-chip microcomputer 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.

Sensor Principle [page]

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 of a circle, 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.

flow chart

3.2 Determination of the vehicle's driving state

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 may read 1 or 0 on the floor outside the track. The laser sensors are arranged in a straight line, with a distance of 20 mm between two adjacent sensors. The track is shown in Figure 5.

Track

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;

Sensor arrangement method

2) If more than 10 black dots are hit, it 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 off 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 in front should also be considered for judgment. 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 left or right turn angle 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.

3.3 Steering gear 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 iteration filtering should be performed :

PVal=((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, 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.

Keywords:MCU Reference address:Low-cost 8-bit single-chip controlled photoelectric tracking intelligent car

Previous article:Low-cost 8-bit single-chip controlled photoelectric tracking intelligent car
Next article:MCU and design solutions for car LCD TV/display

Recommended ReadingLatest update time:2024-11-16 17:50

Design and implementation of weighing liquid level meter based on MSP430 single chip microcomputer
  1 Introduction   The liquid level measurement and control instrument is a type of intelligent instrument (referring to instruments using microprocessors), and its development began in the 1970s . It is an intelligent product that integrates measurement and control, and is suitable for the liquid level measuremen
[Microcontroller]
Design and implementation of weighing liquid level meter based on MSP430 single chip microcomputer
Design of control terminal equipment for air conditioning network management system based on STC89C58RD+ single chip microcomputer
     In schools and other units, scattered air conditioners are randomly turned on and off, which causes energy waste. This not only increases the operating costs of the units, but also makes management more difficult. To solve this problem, a control terminal device for the air conditioner network management system i
[Microcontroller]
Design of control terminal equipment for air conditioning network management system based on STC89C58RD+ single chip microcomputer
51 MCU timer 0 interrupt to realize LED running light
Using 51 MCU timer 0 mode 1 to realize LED running water light Code: #include reg52.h typedef unsigned int u16;   void timer0init() { TMOD=0x01; ET0=1; EA=1; TR0=1; TH0=64736/256; TL0=64736%256; }   void main() { timer0init(); while(1); }   void timer0() interrupt 1 { u16 and;   TH0=64736/256;
[Microcontroller]
How to improve the 8051 microcontroller to create a high performance drop-in replacement that can perform up to 33MIP
This article describes how Dallas Semiconductor improved the legacy 8051 microcontroller to create a high-performance drop-in replacement that can perform up to 33MIP. Additional features such as multiple data pointers, extended memory addressing (up to 16MB) and flash memory increase the speed and usability of the de
[Microcontroller]
How to improve the 8051 microcontroller to create a high performance drop-in replacement that can perform up to 33MIP
What should I learn to get started with embedded? Start by learning about microcontrollers!
Maybe many people don't know about embedded and microcontrollers. But I said that everyone knows about the popular applications in recent years. 1. Drone 2. Shared bikes 3. Fengchao Express Cabinet 4. Charging pile 5. Smart home These products are internally implemented through embedded technology, and most of
[Microcontroller]
Simple electronic piano source code based on 51 single chip microcomputer
It uses digital tube display, matrix keyboard, and buzzer. It is suitable for friends who are new to 51. It is just a program. You can understand it at a glance.   The C language program microcontroller source program is as follows: /***********************************************************************************
[Microcontroller]
AT89C51 single-chip intelligent voice dialing alarm system
With the improvement of people's living standards and the enhancement of security awareness, it is urgent to develop an automatic alarm system that is affordable and reliable for the general public. In view of the popularity of residential telephones and mobile communication devices, as well as the advantages of tel
[Microcontroller]
AT89C51 single-chip intelligent voice dialing alarm system
Design of carbon monoxide monitoring alarm based on single chip microcomputer
Introduction With the rapid development of industry, there are more and more occasions where humans are exposed to harmful gases, which causes more and more harm to humans. In steel mills and iron mills, blast furnace gas (mainly CO), a byproduct of blast furnace production, is sent to the gas pipeline network
[Microcontroller]
Design of carbon monoxide monitoring alarm 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号