Design of educational robot based on single chip microcomputer

Publisher:温雅如风Latest update time:2013-02-05 Source: dzscKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    At present, many higher education institutions use educational robots for classroom teaching and cultivating students' innovative ability. The educational robot designed in this paper detects road information through an infrared photoelectric sensor array and uses a fuzzy self-tuning PID algorithm to process the collected road information and motor operation data in real time, realizing the intelligent cruising of the educational robot and displaying the status of the robot.

  1 Composition and working principle of the robot

  The robot consists of two parts: hardware and software. The STC12CSA60S2 single-chip microcomputer is used as the core component of the system control to complete functions such as road information detection, DC motor control, motor speed detection, digital tube display, buzzer alarm, and keyboard input. The hardware system block diagram is shown in Figure 1.

Hardware system block diagram

Figure 1 Hardware system block diagram

  The software part mainly completes road condition detection, PID motor control, input and output human-machine interface, and can realize various robot cruising actions, intelligent tracking and other functions.

  2 STC12 series microcontroller

  The STC12C5A60S2 microcontroller used in this article is a STC12 series microcontroller produced by Hongjing Technology. This microcontroller is a single clock/machine cycle (1T), with many advantages such as high speed, low power consumption, super strong anti-interference and inability to decrypt. The instruction code is fully compatible with the traditional 8051 and is 8-12 times faster. The operating voltage is 3.3 V ~ 5.5 V (5V microcontroller), there are 6 16-bit timers, compatible with ordinary 8051 timers or 4 external interrupts, with watchdog and EEPROM functions, and an internal integrated MAX810 dedicated reset circuit.

  3 Hardware Design

  3.1 System Power

  Since the motor has a large current at the moment of starting, the power supply must have sufficient driving capability, so the system uses dual power supply. The LM7805 is used to convert the 12 V lithium battery pack voltage into a 5 V regulated power supply to power the microcontroller minimum system circuit, road surface detection circuit, digital tube display circuit and motor speed measurement circuit. The motor drive circuit is directly powered by the 12 V voltage output by another group of lithium batteries.

  3.2 Motor drive circuit

  The DC motor used in this system has a rated voltage of 12 V and a rated speed of 300 rpm. The motor drive circuit uses a dedicated chip L298N as the motor drive chip. Using this chip as a motor drive not only has good stability and greatly simplifies the drive circuit, but also has a large driving capacity, which is conducive to the stability of the motor speed. The motor drive circuit is shown in Figure 2.

[page]

    3.3 Infrared photoelectric sensor tracking array module

  The working principle of the infrared photoelectric detection circuit is: infrared rays are emitted to the road surface and reflected. The infrared rays have different reflection coefficients on black and white lines. White reflects light, while black absorbs light. The circuit is designed with an infrared light emitter and an infrared photosensitive diode. When a black line is detected, the detection circuit sends a high-level signal to the microcontroller. When a white line is detected, the detection circuit sends a low-level signal to the microcontroller.

  An infrared photoelectric sensor array module is composed of 7 groups of infrared photoelectric detection circuits arranged in a row and placed at the front of the robot. In the process of tracking the black line, the infrared photoelectric sensor array module can obtain the displacement offset of the robot to the black line track. The signal of the infrared photoelectric sensor array module detected by the single chip and the displacement offset of the robot are shown in Table 1.

  When the robot is in different driving states, the output values ​​of the 7 sets of sensors are also different. From the table, we can get the offset between the robot's position and the black track during the cruising process.

  3.4 Vehicle speed detection module

  The educational robot system reads the current vehicle speed through the vehicle speed detection module. The method used is to paste a coding disk with evenly distributed black and white stripes on the rear left and right wheels respectively (see Figure 3 (a)), and use the detection circuit of Figure 3 (b) to detect the black and white stripes on the coding disk. When the wheel rotates, the intensity of the reflected light received by the infrared receiving tube will change, which will generate a pulse signal corresponding to the wheel speed. The pulse signal is amplified and shaped, and then input into the pins P3.4 and P3.5 of the microcontroller. The number of pulses obtained per unit time can be recorded to indicate the speed of the left and right wheels of the current vehicle. At the same time, the distance traveled by the vehicle can be calculated by accumulation.

  3.5 Other circuits

  The digital tube display circuit mainly displays the current walking speed of the robot. LED digital tubes are used for dynamic display, and the segment code is driven by PNP transistors. The system displays a distance range within 10 meters. A 4-bit LED common anode digital tube is selected, and dynamic scanning display is realized through single-chip microcomputer programming. The display characters are sent out by the single-chip microcomputer P0 port, and P1.6, P1.7, P3.0 and P3.1 control the dynamic display of each digital tube respectively.

  The alarm circuit is completed by controlling the buzzer through the single-chip microcomputer P3.7. When P3.7 outputs a low level, the buzzer alarms; when P3.7 outputs a high level, the buzzer does not alarm. The touch buttons are connected between the external interrupt input ports P3.2 and P3.3 of the single-chip microcomputer and the ground as the start and stop switches of the system, as a key input circuit.

[page]

    System software design

  The realization of system control is completed by software. The software design is based on keilC51, adopts modular structure design, and each functional sub-block is independent. Structurally, it consists of 1 main program file main.c and 8 sub-program files (key.c, pid.c, detect.c, seg.c, speed.c and motor.c). The main.c main program file completes the initialization of a series of tasks and the coordination of processing each task. The key.c file completes the key interrupt detection and buzzer alarm tasks; the seg.c file completes the digital tube display; the sp∞dc file completes the motor speed detection; the motor.c completes the PWM configuration and motor control; the detect.c file completes the infrared photoelectric sensor array detection; the pid.c file implements the fuzzy parameter self-tuning PID operation processing. Among them, the timer TO generates a sampling period T second timing interrupt, interrupts once every T seconds, completes a PID control calculation, and calls the fuzzy parameter self-tuning PID operation subroutine to calculate the difference between the test speed and the set speed to obtain the output value, which is used to configure the PWM output and control the motor speed. The main program and timer TO interrupt processing flow chart is shown in Figure 4.

Main program and timer TO interrupt processing flow chart

Figure 4 Main program and timer TO interrupt processing flow chart

  4.1 Principle of Fuzzy PID Parameter Self-Tuning Controller

  PID parameter fuzzy self-tuning is to find out the fuzzy relationship between the three parameters in PID and e and ec. During operation, by continuously detecting e and ec, the three parameters are modified online according to the fuzzy control principle to meet the different requirements of e and ec for control parameters, so that the controlled object has good dynamic and steady-state performance. Considering the stability, response speed, overshoot and steady-state accuracy of the system, the functions of Kp, Ki and Kd are as follows: Kp is used to speed up the response speed of the system and improve the regulation accuracy of the system; Ki is used to eliminate the steady-state error of the system; Kd improves the dynamic performance of the system. Figure 5 is a schematic diagram of the design structure of the PID controller.

PID controller design structure schematic diagram

Figure 5 PID controller design structure schematic diagram

  The influence of various PID parameters on the system is as follows:

  (1) When the error |e| is large, it means that the absolute value of the error is large. Regardless of the error change trend, the controller Kp should be considered to take a larger value to improve the rapidity of response; and to prevent |ec| from being too large instantaneously, kd should take a smaller value; to control overshoot, ki should also take a very small value.

  (2) When the error |e| is of medium size, in order to ensure the response speed of the system and control overshoot, Kp should be reduced, Ki value should be increased, and Kd should be moderate.

  (3) When the error |e| is small, in order to ensure that the system has good steady-state characteristics, the values ​​of Kp and Ki should be increased. At the same time, in order to avoid oscillation, the value of Kd should be linked to |ec|.

  Educational robots are typical nonlinear, time-varying, and model-uncertain complex systems. In practice, the roads on which robots travel include straight roads, large curves, and "S"-shaped small curves. Taking advantage of the fact that the characteristics of educational robots remain basically unchanged under the same road conditions, the optimal PID parameters under these three road parameters can be determined respectively. The core idea is to regard the robot state within the control cycle as unchanged. As long as the control cycle is short, a good control effect can be achieved. In the actual operation of the robot, control is performed once every 10ms, which meets the requirements.

  4.2 PID parameter setting

  Fuzzy PID control considers the relationship between Kp, Ki and Kd according to different operating states of the system. Based on engineering experience and the role of each parameter, a large number of tests are conducted to obtain the PID parameters of this system under corresponding road conditions. The experimental data are as follows:

  (1) On the straight road, the system takes kp=3, Ki=5, kd=0, and the test environment is a long straight road with a length of 5 m;

  (2) On the large curve, the system takes kp=10, Ki=1, kd=1, and the test environment is a straight road entering a 3/4 circle with a radius of 100 cm;

  (3) On the "S"-shaped small curve, the system takes kp=7, Ki=4, kd=3, and the test environment is an "S"-shaped small curve composed of three 90-degree arcs.

  5 Conclusion

  The STC12C5A60S2 single-chip computer is used in conjunction with the infrared photoelectric array detection module to execute the parameter self-tuning fuzzy PID controller of the DC motor, which solves the control problem of the DC motor's jittering forward during cruising, making the educational robot more stable during walking, and the control method is simple and practical.

References:

[1]. MAX810 datasheet http://www.dzsc.com/datasheet/MAX810_1019165.html.
[2]. LM7805 datasheet http://www.dzsc.com/datasheet/LM7805_843721.html.
[3]. L298N datasheet http://www.dzsc.com/datasheet/L298N_442931.html.

Keywords:MCU Reference address:Design of educational robot based on single chip microcomputer

Previous article:Basic knowledge of single chip microcomputer application programming
Next article:Features of MSP430 MCU and its application in receiver

Recommended ReadingLatest update time:2024-11-16 15:42

What does the microcontroller C program do before the main function?
When testing a C language microcontroller program, I found that there was a long delay before the execution of the main function. What was the microcontroller doing during this time? After some analysis, the following conclusions were drawn: C program #include reg51.h sbit p1_7=P1^7; void interrupt0() interrupt 0 usi
[Microcontroller]
[MCU framework][BSP layer][AT32F415][bsp_tim] TIM timer configuration and use
9 Timer 9.1 General purpose timer (TMR2 to TMR5) 9.1.1 Introduction to TMRx The general purpose timer is a 16-bit auto-reload counter driven by a programmable prescaler. It is suitable for a variety of applications, including measuring the pulse length of an input signal (input capture) or generating an output wavefor
[Microcontroller]
[MCU framework][BSP layer][AT32F415][bsp_tim] TIM timer configuration and use
Single chip microcomputer control of stepper motor
1. Scheme demonstration and comparison 1. The focus of this design is on the control and drive of the stepper motor. The controlled motor in the design is a four-phase six-wire stepper motor (internal resistance 33 ohms, step 1.8 degrees, rated voltage 12V) Scheme 1: Use multiple power amplifier dev
[Industrial Control]
Single chip microcomputer/intelligent instrument display and keyboard design
Experimental content: The keyboard uses a 4X4 keyboard, and each digital tube can display a total of 16 numbers from 0 to F. By pressing the key, the key value 0-F is obtained in the R5 register. By pressing the key, write a program to scan the keyboard input and send the scan result to the digital tube for display.
[Microcontroller]
Single chip microcomputer/intelligent instrument display and keyboard design
MSP430F149 microcontroller drives DS2762 to read and write C language program
Based on the MSP430F149 microcontroller driving the DS2762 read and write operation C language program, it can respond to keystrokes or other signals, read current and voltage, and perform corresponding processing. //#include msp430x14x.h #define uchar unsigned char #define uint unsigned int uint A,B,C,D,E,F,G,H
[Microcontroller]
Application principle of BOOT0 and BOOT1 of STM32 microcontroller
The storage media corresponding to the three boot modes of STM32 are all built-in to the chip, they are: 1) User Flash = Flash built into the chip. 2) SRAM = RAM area built into the chip, that is, memory. 3) System Memory = A specific area inside the chip. A Bootloader is preset in this area when the chip leaves the
[Microcontroller]
51 microcontroller ultrasonic ranging program code sharing
/Ultrasonic module ME007 display program //Crystal oscillator=8M //MCU=STC10F04XE //P0.0-P0.6 common anode digital tube pins //Trig = P1^0 //Echo = P3^2 #include //Include a header file for the 52 standard kernel #define uchar unsigned char //Define it for ease of use #define uint unsigned int #define ulong unsigned l
[Microcontroller]
Universal interface between rotary encoder and microcontroller in mechanical measurement
When we were preparing for the "Freescale" Cup National College Student Smart Car Competition, we initially used infrared sensors to measure speed. However, they were greatly affected by environmental interference and had a very low response frequency, which did not even reach 1K Hz. In order to improve the speed me
[Microcontroller]
Universal interface between rotary encoder and microcontroller in mechanical measurement
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
Guess you like

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号