Smart Car --- use Linux2.6

Source: Internet
Author: User
Smart Car --- use Linux2.6 -- general Linux technology-Linux programming and kernel information. The following is a detailed description. Smart Car V0.1

Author: Sam Yamano, coolwyc@21cn.com



(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // www.roboticfan.com/blog/UploadFiles/2007-8/221435205355.jpg'); ">



(400) {this. resized = true; this. width = 400; this. alt = 'click here to open new window';} "onmouseover =" if (this. resized) this. style. cursor = 'hand'; "onclick =" window. open ('HTTP: // www.roboticfan.com/blog/UploadFiles/2007-8/221435770766.jpg'); ">

Hardware:

1. Car Body

2. S3C2410A Development Board

3. Infrared ranging sensor

4. Server (steering gear)

5. DC Motor

6. Motor Drive Board

7. Power supply

Software:

1. Linux 2.6.14 kernel, including: Nand Flash, USB, NET, PWM, ADC, and other drivers; Yaffs and other file systems.

2. VIVI

3. Busybox1.6

Main objectives:

This allows the vehicle to drive on the ground, avoiding obstacles of a certain height and size.

Next goal:

Optimize the walking algorithm, route prediction, and route selection.

Add the encoding wheel to implement the PID.

Development description:

1. PRJ1 has been completed in the past few months: the development of Smart car, PRJ2 hardware and PRJ1 are the same, the implementation function is also basically the same, the biggest difference is that PRJ1 uses ucoⅱ operating system, PRJ2 uses Linux, due to busy work, PRJ1 introduction will be written and released later.

2. the Development Board was bought more than a year ago. The built-in linux version is 2.4. Now many development boards have used 2.6. Of course, I want to use 2.6 as a platform, so it took about three weeks to start porting linux2.6.14, and I also tried 2.6.18 and 2.6.22, after the compilation, when running the program, there is always a visual address cutting word. Why are you kidding me? The migration of linux2.6.14 was also relatively smooth, and Nand Flash, USB, NET, and Yaffs were quickly completed. I am doing this in my spare time. I usually have to go to work. It took me three weeks to feel that it is not too slow.

3. after the kernel is transplanted, the next step is the file system. The first step is to port Busybox1.6, then create a directory structure, write linuxrc, hosts, passwd, and other configuration files, and draw a partition on mtd to create yaffs, copy the directory structure and Busybox, and use this yaffs partition as the root directory at startup. There are also a lot of articles on the Internet for reference, which is simplified here.

4. Three hardware must be controlled for the vehicle body:

A. infrared ranging sensor-the only sensor in the car body, with a maximum detection distance of 80 cm. It is responsible for detecting obstacles around the car body. There are no sensors such as contact switches on the car body, therefore, the security of the vehicle body depends on it.

B. the server is responsible for driving the rotation of the infrared ranging sensor so that it can detect distances from different angles. Here we design lang = "EN-US" style = "font-family: times New Roman "> 140 degrees of rotation, that is, the distance between 140 degrees of obstacle can be detected.

C. DC motor --- Responsible for car body movement. The PWM signal is used to drive the motor drive board to adjust the running speed of the car body. When the obstacle is far away, the running speed can be faster. When the obstacle is near, the running speed can be slower or stop.

5. the infrared ranging sensor outputs analog voltage signals (when the obstacle is far away from the output voltage is low, when the obstacle is near the output voltage is high), so you need to write the S3C2410_adc driver to use the ADC.

6. both the server and the DC motor need to use the PWM signal. The PWM signal is generated by the timer. the S3C2410 has a five-way timer, and linux occupies one. Check the linux kernel source code and check whether timer4 is used, the remaining four can be selected. The timer0 driver server and timer1 drive the DC motor. After the assignment, you can immediately write the S3C2410_pwm driver; in addition to controlling the speed, the vehicle body also needs to control the direction (forward, backward, left turn, right turn, etc.), and the motor drive board needs to be controlled through I/O, we should have written another driver to do this, but considering that the control object is the same (motor), and the control direction is closely related to the control speed, therefore, the code for controlling I/O is written into the S3C2410_pwm, which is convenient to use.

7. at this point, the kernel and driver are ready. The next step is to implement the application, including the walking mode, walking algorithm, and obstacle detection of the car, two threads are used to complete these tasks:

A. measureThread () --- probe thread: It mainly enables the server to rotate back and forth in the range of 140 degrees, which leads to the rotation of the infrared ranging sensor. The obstacle distance is measured every time a certain angle is turned; inform MotionThread () of the corresponding action based on the measurement result, for example, notifying MotionThread () to move forward when the obstacle distance is within the safe range; or notifying MotionThread () to turn right when there is obstacle in front of left; when the obstacle distance is relatively close, the MotionThread () is notified to slow down. The obstacle distance is relatively long, And MotionThread () is notified to accelerate. Use the global variable Motion_status to implement communication.

B. MotionThread () --- motion control thread: controls the motion of the vehicle body according to the state set by MeasureThread. When there is an obstacle, you need to turn left or right on the car body to avoid the obstacle. When the obstacle is near the safe distance threshold, there will be jitters (with obstacles-Left turn-Accessibility-stop-with obstacles-Left turn). Here we take at least a certain period of time (for example, 200 ms) for each rotation ), during this period, it is prohibited to change the motion of the vehicle body. mutex_turning is used to achieve this synchronization.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.