Design of Robot Control System Based on arm9-and Linux
| [Date:] |
Source: single-chip microcomputer and Embedded System Application by Luo Lei Dai Xuefeng, Qiqihar University, Liu shudong |
[Font:Large Medium Small] |
Introduction
Existing smart robots generally use single-chip microcomputer or high-speed DSP to control the use of DC motors as drive wheels, and the same robot often needs multiple CPUs to implement their respective functions, however, with the increasing demand for Robot Intelligence, a new controller (using a processor) is required to meet various robot behavior requirements, such as video collection and wireless communication. The intelligent robot platform implemented by ARM provides a new method for the development of intelligent robots. The platform uses arm9-based on Samsung's S3C2410 processor, which features a clock speed of up to 200 MHz. It supports Bluetooth, touch screen, and USB host interfaces to transmit high-speed images. An embedded Linux system is a multi-user operating system that allows multiple users to access the system at the same time without mutual interference between users. In addition, the Linux system supports real multi-user programming. A single user can create multiple processes and enable various processes to work together to meet users' needs. The introduction of Linux allows other smart modules to exist in the form of devices. Users only need to call the drivers of related devices to make data integration more convenient and run multiple tasks more stable.
Using ARM and embedded Linux as an intelligent robot platform has great advantages, but it has not been found in China to use this platform to develop intelligent robot systems. This design has completed the preliminary preparation of the System driver, and through the actual verification, achieved good results.
1. Driving Circuit and Speed Measurement Method
1.1 overall structure and Driving Circuit
The overall structure of the system is shown in Figure l.
The LMD18200 truth table used in this design is shown in table 1. Use the arm I/0 port (such as DO ~ of the D port ~ 3) to control the running status of the motor.
1.2 Speed Measurement Method
ARM does not have a counter to capture external pulses. Its timer is used to calculate internal pulses. The code disk output signal is connected to the External Interrupt Processing Program (EINTl) and the upstream trigger variable is set. A global variable I is set in the interrupt and is accumulated with I ++. Set the timer timer0 so that O.36 s generates one Internal timer interruption. When a timer cycle is completed, the timer interrupt is triggered. Read the I value in the timer0 interrupt to obtain the number of pulses generated by the rotation of the code disk in O.36 s. Then, the I is cleared, prepare for capturing the pulse of the next timer cycle. At this time, timer0 is automatically reloaded, and the next time the code disk count starts.
1.3 Measurement Accuracy Analysis
The precision of the optical code disk selected by the intelligent robot is 256 lines, that is, 256 pulse/rotation. The motor speed-down ratio is 1: 71, the wheel radius R is 6 cm, and the wheel distance is 41.1. The number of pulses produced by turning a wheel in one ring n = 71 × 256 = 18 176, the distance between each pulse is d = 27 π R/n = 2 × 3.14 × 0.06/18 176 = 0.207 × 10-4 m, that is, the control precision of each pulse is 0.02mm. Considering the influence of load changes (such as load variation wheel deformation and other mechanical errors), the theoretical value and the actual value will have an error. Therefore, multiply the control precision d by a correction coefficient k. Table 2 shows the experiment data of the robot walking in a straight line. It can be seen that k has a small error of 1.10 and is closest to the actual value. Therefore, this value is the necessary proportional coefficient.
2. speed adjustment
Generally, when the deviation E is large (such as starting or greatly increasing speed), the System oscillates due to the role of the integral, therefore, the integral separation method is used to cancel the integral function at the beginning, and the integral function is not introduced until there are not many differences between the two. The procedure is as follows:
(1) set a value a> 0, E (m) a R (m) a M (m), where R (m) is the given value, M (m) is the measured value;
② When E (m) is greater than or equal to a, PD control can be used to avoid over-tuning and quickly respond to the system;
③ When E (m) is less than or equal to n, that is, the deviation value E (m) is relatively small, PID control is used to ensure the accuracy of the system.
After using the integral separation method, the amount of the controlled variables is significantly reduced, the transition time is shortened, and the adjustment performance is improved.
3 drive design
The drive design of the system is shown in figure 2, Figure 3, and figure 4.
The device driver is the interface between the operating system kernel and the machine hardware. It serves as the software layer between the application and the actual device, shielding the application from hardware details. For applications, the hardware device is only a device file, and the application can operate on the hardware device like a common file. The device driver is part of the Linux kernel. It implements the following functions: Initialize and release the device, transfer data from the kernel to the hardware, and read data from the hardware, read the data transmitted by the application to the device file and send back the data requested by the application, and detect and process device errors. The structure used is as follows:
When the device opens, it will call the dcmotor _ open function to apply for an interrupt number. Address ing of units with memory management, set the 2 and 3 pins of port B to PWM output, and Port D to enable the motor to brake the Brake pin.
All of the following functions are implemented in ioctl. Call timer0_2_3_start () in the Dcmo-tor_Start, set timer0 to receive the code disk signal of two-way motor, and detect the motor speed; timer2 and timer3 provide two-way PWM output, and set the timer to automatically load. The specific implementation is as follows:
Select_Speed can dynamically select the speed to run. It is a user interface. You can call this function to transmit the speed value to the drive to control the motor. For example, execute ioctl (fdl,
Timer0 interrupt is the core program, which can change the duty cycle according to the PID adjustment value. To change the duty cycle value at any time, you can define two global variables tmp2 and tmp3, and change the duty cycle by writing their values to TCMPB.
In All_Forward, All_Back, and All_Stop, DO ~ 3 levels to achieve forward, backward, and stop. In Left_Curve and Right_Curve, set the rotation direction of the left and right wheels to make the two wheels rotate in different directions, then, a predetermined time is specified in the application based on the differential speed to achieve the turning effect.
4 Conclusion
Using ARM and Linux operating systems to implement closed-loop control of intelligent robots is feasible, and the powerful functions of ARM can be used to expand other intelligent modules.