Performance characteristics and usage experience of single-chip microcomputers commonly used in making robots

Publisher:灵感发电站Latest update time:2016-03-09 Source: 21icKeywords:Robot Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Many friends who have just come into contact with robots or single-chip microcomputers are often confused by the wide variety of single-chip microcomputers. What are the differences between them? Which single-chip microcomputer is better for making robots? After we choose a single-chip microcomputer, what shortcuts can we quickly master and apply this single-chip microcomputer? This article attempts to interpret the above questions in an easy-to-understand way, and designs a deep single-chip microcomputer control robot example, hoping to play a role in starting a discussion. I share with you some of my experience in using single-chip microcomputers, hoping to make beginners less confused and open the minds of those who have already started.

When I wrote this article, I only had 3 years of practical experience in single-chip microcomputers. I was more familiar with 51 series and AVR series single-chip microcomputers, so I focused on discussing AVR single-chip microcomputers. My experience is limited, and mistakes are inevitable. I hope friends will criticize and correct me!

The difference and connection between a single-chip microcomputer, CPU and personal computer

This part of the content is relatively basic, but many friends may not be very clear about the following questions when they first come into contact with microcontrollers.

1 What is CPU?

The Chinese name of CPU is "central processing unit", and the typical representative is Intel's 8086 processor. The current Pentium X processor is the direct descendant of 8086. As the name suggests, the function of the processor is to process data. For the central processing unit, it is the processor that plays a core role in data processing. It sounds complicated, but in fact the core is an ALU "arithmetic logic unit". This unit is composed of some digital gate circuits and can only complete the four arithmetic operations of addition, subtraction, multiplication and division, logical operations such as AND, OR, NOT, XOR, and operations such as shift, comparison and transfer. The CPU contains an ALU, and in addition, the CPU also has a clock circuit. The basic principle of CPU operation is: the clock circuit generates a counting pulse, which controls an accumulator, that is, each time a clock pulse is generated, the accumulator increases by 1, and this accumulated value is in the form of a hexadecimal number through the address bus to uniquely select a storage unit in the program storage (outside the CPU). This unit sends the program command code stored internally to the ALU through the data bus. The ALU performs different operations according to different codes, such as adding a register value to a certain value, and then outputs the calculation result to the IO port or each bus.

In short, the job of the CPU is to translate the command code in the program into different tasks, then execute them and output the execution results. The CPU plays a core role in all digital computers, that is, all computers have CPUs.

2 What is a personal computer?

Since the CPU only has computing functions, the results of its calculations need to be output through the display and speakers, and the basis of its work, that is, the program commands, are stored on the hard disk. The data dynamically accessed when it performs tasks must be saved in the memory. People can control the execution process of program commands through the keyboard. Combining all these CPU peripherals together is called a "personal computer."

3 What is a microcontroller?

Personal computers are powerful and fast in computing, and are ideal computers. But when we need to use a small device to control the timer switch of a microwave oven, personal computers become bulky and expensive. Therefore, people have designed a concentrated computer, which is several square centimeters in size and smaller than a grain of rice. They are called "single-chip microcomputers" - single-chip microcomputers. CPU is a chip, and single-chip microcomputers are also a chip. They look similar in appearance. What is the difference between them? The answer is: in addition to the CPU, single-chip microcomputers also integrate program storage ROM (which can be understood as a hard disk), data storage RAM (which can be understood as memory), input and output interfaces (which can be understood as displays and keyboard sockets). Some single-chip microcomputers also integrate motor drive circuits, video decoding circuits, AD converters, wireless transmission circuits, etc., making single-chip microcomputers very powerful. The specialty of single-chip microcomputers is that they can use a single chip and simple external circuits to achieve complex control operations, so they are very suitable for robot control. In fact, there are shadows of single-chip microcomputers in most robots. Simple and medium-complex robots can be directly controlled by single-chip microcomputers, and highly complex robots use "personal computers" or "supercomputers" to command many single-chip microcomputers to complete robot control.

4 What is the shortcut to learn microcontroller?

The so-called shortcut is to avoid detours. I took a lot of detours when I first started learning MCU. Many friends and I have similar experiences. When I first came into contact with MCU, I didn’t know which book to choose from the dazzling array of books and teaching materials; I didn’t know where to buy MCU when I wanted to practice; I didn’t know how to program and download programs...

A For beginners, reading this article carefully is one of the shortcuts to learning microcontrollers.

B Go to the library or bookstore and choose a "real, vivid and lively" microcontroller book from dozens of microcontroller books that you can understand and find interesting cases as your introductory reading.

C It is recommended to start with the 51 single-chip microcomputer. After mastering 51, learn AVR, and then learn ARM, DSP, etc.

D Practice is very necessary in the learning process. You need a computer. If it is a desktop computer, you can spend more than ten yuan to buy a 25-pin parallel port download cable. If it is a laptop, you can only buy a USB ISP programmer for tens to hundreds of yuan.

E Use a universal board to solder a single-chip minimum system yourself, or buy a development board. There is no need to use an expensive emulator.

F You need to download the microcontroller programming software from the Internet, such as Keil programming for 51 and CVAVR programming for AVR. Write the program in the programming software, then generate a HEX file, and then download the parallel port burning software or USB ISP burning software from the Internet, use the burning software to load the HEX file, and then connect the programming line to your microcontroller circuit board to burn the program into the microcontroller.

G Unplug the programming cable, then turn on the power of the MCU board, you can see the MCU system is running.

H If the system does not run properly, first check whether the circuit is connected correctly, then check whether the program is burned incorrectly. If all of the above are OK, then study whether the program is programmed incorrectly. Sometimes the system does not run properly, which does not mean that there is something wrong, but that some parameters are not set properly. You need to keep running, modifying the program, debugging the parameters, and running again, until you are satisfied with the system operation. Sometimes this is a very hard and repetitive work, and you cannot avoid it, you can only be firm in your faith and move forward courageously.

I It is more convenient and cheaper to buy things on Taobao.

2. What did people use to control robots before the birth of single-chip microcomputers?

1 Analog Computer

Before the birth of digital computers, people used electron tubes, capacitors, inductors, and resistors to build analog computers, which could complete many simple calculation and control tasks. The so-called analog computer is an analog computer that uses analog signals with continuously changing voltages instead of 1 and 0 digital signals, similar to the calculations used by various controllers in the automatic control principle. Don't underestimate analog computers. During the Middle East War in the 1980s, the Soviet-made fully automatic self-propelled anti-aircraft guns used by Arab countries used analog computers to calculate aircraft trajectories and control the guns' firing targets.

2 Controller consisting of gears and cams

Before the birth of analog computers, that is, in the era of steam engines, some mechanical geniuses built mechanical computers with hundreds of gears and cams. People turned various gears with numbers printed on them, and other gears displayed the calculation results. Mechanical computers were once high-tech products in human history. During World War II, the famous German cipher machine was a hybrid electromechanical computer, which was the most confidential communication tool at the time.

3 Controller consisting of clockwork, stopwatch and relay

At the beginning of the electrical age, people used the mechanical rotation of clocks to control the on and off of some relays, thereby controlling the operation of some machine tools and production lines. This device is similar to the timer in early washing machines.

AT89S51 series microcontrollers are the first choice for beginners

1 Introduction

In 1980, Intel developed a simple 8031 ​​CPU. At that time, the performance of the CPU was not much worse than that of the 8086, but the price was relatively cheap, so it was selected by many low-end applications. As the market was optimistic, ATMEL purchased the 8031 ​​core, integrated the Flash memory and enhanced IO port into it, and developed the AT89 series of single-chip microcomputers. All single-chip microcomputers compatible with 8031 ​​instructions and similar cores are collectively called 51 single-chip microcomputers, which are currently one of the most widely used 8-bit single-chip microcomputers. Because the 51 single-chip microcomputer has a simple structure, easy-to-learn instructions, and a wide range of applications, it is the first choice for beginners of single-chip microcomputers. If someone wants to learn AVR directly without learning 51, then this person will definitely encounter many problems, and confusion and depression will accompany the learning process. If you learn 51 and then learn AVR and other single-chip microcomputers, people will find that "the so-called single-chip microcomputers are nothing more than that."

2 Performance

Choose the most suitable MCU according to the specific needs of the task, make full use of the MCU resources, maximize the system cost performance, and take into account future expansion needs without blindly pursuing high-performance MCUs. This is the principle of selecting MCU.

AT89S51 has 4K Flash program memory, 128 bytes of RAM, 32 IO ports, and an interrupt system with 6 interrupt sources, 5 terminal vectors, and 2 interrupt priority levels; the serial port is a full-duplex serial communication port; the power supply voltage of AT89S51 is 4.0-5.5V, and the power supply voltage of AT89LS51 is 2.7-4.0V; the oscillator frequency is 0-33MHz (AT89S51), 0-16MHz (AT89LS51); it has ISP online programming function, the advantage of this function is that the program in the microcontroller memory does not need to be removed from the working environment. It is a powerful and easy-to-use function.

The AT89S52 has a program storage capacity of 8KB, and there is also an AT89S55 with a larger ROM capacity.

Many companies have produced many extended 51 series microcontrollers, some with AD converters, some with comparators, and some with PWM. Readers can choose the appropriate 51 microcontroller according to their own needs, but pay attention to their pin definitions and programming methods.

3 Usage

AT89S51 is suitable for circuits that do not need to collect analog quantities and control high-power external components, such as single-chip learning boards, electronic clocks, and ultrasonic rangefinders. The difference between S51 and the previous C51 is that S51 supports ISP online programming, that is, C51 requires a programmer worth hundreds of yuan to program, while S51 only needs a 25-pin parallel port line and a very simple conversion circuit to connect to the desktop computer printer interface to burn the program. Download the small software to burn the program to realize the programming of the S51 single-chip microcomputer. Keil software is generally used to program the 51 single-chip microcomputer. C language or assembly language can be used. After programming, choose to output the HEX file, and then use the small software to burn the program to read the HEX file, and then burn it into the single-chip microcomputer.

4 Practical Experience

A When I first started reading books, I connected the circuits according to the circuit diagrams in the books and powered on the circuits for debugging, but it was always unsuccessful. I carefully compared my own circuits with the circuits in the books, but I could not find any problems. The reason is that many circuit diagrams in books are "simplified diagrams", that is, some circuits are omitted, and these omitted circuits are related to the operation of the system. For example, when the microcontroller book talks about the AD conversion circuit, the circuit diagrams given often omit the crystal oscillator and reset circuit. Naturally, the system built according to the AD conversion circuit diagram cannot run.

B 51 single-chip microcomputer P0 port needs a pull-up resistor when outputting signals. I often forget to add the resistor, which causes the circuit to not work properly.

C 51 microcontroller pin 31 needs to be connected to the positive pole to select the internal program memory. If you forget to give this pin the correct voltage, your microcontroller may not be able to execute the program.

4 Application Examples

5.jpg
6.jpg
7.jpg

Four enthusiasts make robots first choice AVR series microcontroller

1 Introduction

AVR microcontroller is an enhanced RISC (Reduced Instruction Set CPU) high-speed 8-bit microcontroller with built-in Flash developed by ATMEL in 1997. High reliability, powerful functions, high speed, low power consumption and low price have always been important indicators for measuring the performance of microcontrollers, and AVR microcontrollers are typical high-performance microcontrollers.

In order to improve reliability (to prevent data misreading or running away), early single-chip microcomputers, such as the 51 single-chip microcomputer, used a higher frequency division coefficient to divide the clock, which made the instruction cycle long and the execution speed slow. For example, the 51 single-chip microcomputer requires 12 crystal oscillator cycles to form one machine cycle, and many instructions require 2 machine cycles to execute. The introduction of the AVR single-chip microcomputer completely broke this old design pattern, abolished the machine cycle, adopted a streamlined instruction set, had a short instruction fetch cycle, and could pre-fetch instructions to achieve pipeline operation, so it could execute instructions at high speed. The AVR single-chip microcomputer can execute 12 instructions in 12 crystal oscillator cycles. From this perspective, if the crystal oscillator frequency is the same, the speed of the AVR is 12 to 24 times that of the 51.

AVR has 32 general registers. When performing a large number of complex operations, the 32 registers of AVR can be equivalent to the 32 accumulators of 51, overcoming the bottleneck phenomenon caused by the 51 series microcontrollers having only a single accumulator for data processing. When performing complex operations, the speed is more than 5 times faster than 51. From this, we can see how slow 51 is compared with AVR, and how fast AVR is.

AVR series microcontrollers integrate multiple AD converters, voltage comparators, ISP, I2C, JTAG bus circuits, UART serial ports, high-power IO ports, watchdogs and other practical circuits. Many AVR microcontroller models have three types of memory: EEPROM, FLASH, and SRAM, which can modify the contents of the program memory in real time, that is, the AVR microcontroller can modify its own program. At the same time, AVR can generally work in a wide voltage range (2.7~6.0V), and some can even work at 1.8V. The above performance is only part of the many performances of AVR, but it has already made the 51 series microcontrollers far behind.

The price of such a high-performance microcontroller is almost the same as that of the 51 microcontroller. For example, the price of ATmega8 is about 8 yuan, and the price of ATmega16 is about 13 yuan. This is a true reflection of the extremely high cost-effectiveness of AVR.

8.jpg

2 Performance

The AVR family is very large, including 5 types of microcontrollers: ATinyAVR (micro), low-power, ATmegaAVR, high-end and low-end. They are all based on the same core technology, but they have different internal integrated circuits. Whether you want to make an electronic watch or video processing, there is a suitable AVR microcontroller to meet your needs.

This article only lists the performance of the ATmega16 mid-range microcontroller:

16KB FLASH program memory; 512B EEPROM; 1KB SRAM; 32 fast registers; 32 high-power IO ports; 20 interrupts; 2 external interrupt ports; SPI, SUART, I2C bus interfaces; 2 8-bit timers; 1 16-bit timer; 3 PWM channels; real-time clock RTC; 8 10-bit AD channels; voltage comparator; watchdog; built-in clock oscillator; JTAG interface; ISP online programming; voltage range is 2.7V-5.5V; external clock crystal oscillator 0-16MHz; PID and various SMD packages.

The IO port of AVR can output 20mA and absorb 40mA current, which can not only directly drive LED, but also directly drive micro DC reduction motor. Moreover, the IO port of AVR can be programmed to input, output, and high impedance state, which is a true 3-state IO port. Compared with 51, you will find unprecedented convenience and freedom when using AVR to develop products.

AVR microcontrollers can be installed with operating systems, such as UCOS2, Linux, etc. It is also easy to implement operating system functions through independent programming.

Choose the most suitable MCU according to the specific needs of the task, make full use of the MCU resources, maximize the system cost performance, and take into account future expansion needs. Do not blindly choose high-performance MCUs. This is the principle of selecting MCUs.

Using ARM + operating system to make ultrasonic rangefinder is an overkill. Using AVR mid-range microcontroller to make machine vision is a bit overwhelmed. If you swap them, everything will be just right.

3 Usage

A good book for learning AVR microcontrollers is "AVR Microcontroller Embedded System Principles and Application Practice", the cover of which is shown in the picture below.

AVR is generally programmed with CVAVR programming software, and can also be programmed with GUN GCC AVR and AVR Studio software. It can be programmed in assembly or C language. Before burning the program, output the HEX file first, then load it with SLISP (Shuanglong ISP) software, and then burn it into the AVR microcontroller through the ISP programming cable or 25-pin parallel port connection cable, supporting online programming.

Since the minimum system of the AVR microcontroller is very simple, which is just power supply + crystal oscillator (optional) + LED + ISP interface (runs when power is on and stops when power is off, no reset circuit is required), any beginner can use a breadboard to build an AVR minimum system and practice programming.

4 Practical Experience

When using an AVR microcontroller, be sure to set the fuses correctly. The SLISP software can set them. The fuses determine whether the microcontroller uses an external crystal or an internal clock oscillator. If the fuses are set to use an external crystal, but the circuit is not connected to a crystal, the AVR program cannot run. Many beginners ignore this point, and their AVR systems cannot run without finding the reason. Another thing is that the IO port of the AVR needs to be programmed to set its status before use, otherwise you will find that the program is running, but there is no signal at the IO port.

9.jpg

4 Application Examples

10.jpg
11.jpg

 

5. Advanced Robot Controller ARM

1 Introduction

ARM is the name of a company. They designed many high-performance processors based on the same core. These processors are all called ARM. After the technology was purchased by many companies, ARM chips with many integrated functional circuits were produced, making ARM a high-performance single-chip microcomputer. ARM is generally a 32-bit single-chip microcomputer, suitable for processing large amounts of complex data. Many ARMs are equipped with UCOS2, Windows CE, and Linux operating systems, and can run multiple programs at the same time. ARM is widely used in mobile phones, MP3s, GPS navigators, vacuum cleaner robots and other products.

12.jpg

6. DSP of choice for audio and video processing

1 Introduction

DSP (Digital Signal Processing, referred to as DSP), is a unique microprocessor that uses digital signals to process large amounts of information. Its working principle is to receive analog signals, convert them into digital signals of 0 or 1, and then modify, delete, and enhance the digital signals, and interpret the digital data back to analog data or actual environment formats in other system chips. It is not only programmable, but also has a real-time running speed of tens of millions of complex instruction programs per second, far exceeding general-purpose microprocessors. It is an increasingly important computer chip in the digital electronic world. Its powerful data processing capabilities and high operating speed are the two most commendable features.

DSP is widely used in the fields of high-speed car patrol and voice recognition. However, it seems to be a waste of resources if DSP is only used to detect a few collision switches and control a few motors.

Seven emerging controller FPGA

1 Introduction

FPGA (Field-Programmable Gate Array) is a product that is further developed on the basis of programmable devices such as PAL, GAL, CPLD, etc. It appears as a semi-custom circuit in the field of application-specific integrated circuits (ASIC). System designers can connect the logic blocks inside the FPGA through editable connections as needed, just like a circuit test board is placed in a chip. Simply put, if the user wants to develop a car that can be controlled by a simple digital logic circuit, but finds it troublesome to build the circuit, he can use software to program an FPGA to realize the digital circuit function to control the car. That is, FPGA can be used to simulate various circuits. Some FPGAs can even simulate the operation of 51 single-chip microcomputers. Because FPGA can modify the circuit structure it simulates through programming, it is very convenient in system experiments and debugging. Many enthusiasts try to use FPGA as a robot controller.

8. More MCUs to choose from

Before we choose to learn a microcontroller, we must first consider what kind of microcontroller performance we need for the actual task we are facing, and then choose from the many microcontrollers that meet the performance requirements. At this time, we also need to consider the "wide application degree" of different microcontrollers. For example, when we want to make an electronic competition smart car, there are AVR microcontrollers and PIC microcontrollers that can meet the task needs. How to choose between the two requires considering which microcontroller is easier to learn, easy to obtain learning materials, more reference programs and cases, and which microcontroller is easier to obtain programming software and downloaders. The author feels that if you want to make a smart car, the information of AVR microcontrollers is relatively rich.

There are many kinds of single-chip microcomputers in the world, most of which can be used to control robots, but there is a question of whether they are suitable. For example, PLC is a programmable controller, which can certainly be used to control robots in the hands of enthusiasts, but PLC is mostly used in the field of industrial control, and the equipment is large and expensive. At the same time, it is not easy to obtain information on using PLC to control small robots. Before enthusiasts choose to learn a single-chip microcomputer, they must first clarify what they want to use the single-chip microcomputer for, and then choose the most suitable single-chip microcomputer to learn. Learning single-chip microcomputers focuses on mastering one or two single-chip microcomputers. If someone learns all the famous single-chip microcomputers such as ARM, PLC, PIC, Lingyang, DSP, FPGA, etc. in a general way, then he will not have real deep development capabilities. The so-called deep development, taking the AVR single-chip microcomputer as an example, beginners can use it to realize the alternating flashing of small lights, intermediate technicians can use it to control robots participating in the competition, and real advanced developers can use AVR to realize machine vision, drone automatic driving, tank fire control system...

Are AVR microcontrollers obsolete?

Some beginners and even intermediate developers think that because ARM generally has higher performance than AVR, ARM will replace AVR, AVR will exit the stage of history, or MSP430 will replace 51 series MCU, or FPGA will replace all MCUs, etc. This view is wrong, because different MCUs have their own characteristics and advantages, and no MCU is perfect. The most suitable MCU should be used in different occasions to give full play to their respective strengths, and there is no possibility that ARM will dominate the world and replace all other models of MCUs. Just imagine, an electronic watch that originally cost more than ten yuan is sold for hundreds of yuan because it uses ARM control. Who can bear it? Therefore, don't think that AVR is outdated and you will directly learn ARM after learning 51, or think that learning 51 is useless and you will directly learn ARM, otherwise you will hit a wall.

MSP430 series microcontrollers: more suitable for robot development, it is a 16-bit, ultra-low power mixed signal processor with a reduced instruction set launched by Texas Instruments in the United States . It has Flash memory, many interrupt sources, and can be nested arbitrarily, which is flexible and convenient to use. The power supply voltage of the MSP430 series microcontrollers uses a voltage of 1.8~3.6V. Therefore, when it runs under the clock condition of 1MHz, the current of the chip will be around 200~400uA, and the minimum power consumption in the clock shutdown mode is only 0.1uA. Each member of the MSP430 series microcontrollers integrates a rich set of on-chip peripherals. They are different combinations of some peripheral modules such as watchdog, analog comparator, timer, serial port 0, 1, hardware multiplier, LCD driver, 10-bit/12-bit ADC, 16-bit Sigma-Delta AD, direct addressing module (DMA), IO port, basic timer (Basic Timer), etc. The MSP430 series of microcontrollers introduced JTAG technology, which not only makes the development tools simple, but also relatively inexpensive, and also allows online programming.

PIC microcontroller: It can be used for robot development. It is an 8-bit microcontroller with a wide range of products. It uses a reduced instruction set and has a good development environment. It has strong pin drive capabilities and can be directly connected to relays to control strong electricity. It has a built-in watchdog and has sleep and low power modes. Many of its performance is not as good as AVR and MSP430 series microcontrollers, but it is also widely used because of its special advantages.

Lingyang MCU: It is more suitable for robot development. It takes 16-bit computer as the core and integrates RAM, ROM and other rich functional circuits of different sizes. Users can choose Lingyang MCU with specific functional circuits according to their needs. Lingyang MCU instruction system provides 16-bit and 16-bit multiplication and inner product operation instructions with high computing speed, and adds DSP function to its application. Therefore, Lingyang is suitable for speech recognition. Lingyang MCU is more common in schools in my country, and there are many application examples. It can be used as a MCU for robot enthusiasts.

Nine examples: Using AVR microcontrollers to create machine life

1 What is machine life?

Machine life is a machine that can survive autonomously, a machine that automatically struggles to survive. For machine life, survival means continuing to run without power outages. Machine life has the characteristics of completely autonomous decision-making, autonomous actions, activities in the unknown world, continuous operation without human participation, and self-maintenance. Skynet in the movie "Terminator" is a super machine life. "Thunderbolt 5" describes the process of a robot from inanimate to alive.

When Norbert Wiener (1894-1964) wrote Cybernetics, he created the first machine life, the Wiener turtle. This robot turtle is an analog computer composed of only two electron tubes, but it can realize the behaviors of a real turtle, such as foraging, sleeping, exploring, and escaping, and its performance is like a living creature. The robot turtle has solar cells on it. When its own battery is about to run out, the robot turtle is happy to find a place with sufficient light to charge. After it is fully charged, it may find a place to sleep late or explore the unknown world. It has a tendency to avoid collisions and avoid tilted places. We cannot predict its whereabouts because it does not run according to the program, just like ourselves. Later, Wiener added another electron tube to his robot turtle. The three electron tubes were connected into a simple neural network. By training the robot turtle, Wiener could control the behavior of the robot turtle by ringing a bell. Just like a biologist who trains a dog to drool when hearing the ringing bell.

13.jpg

2 We can make a robot pet by ourselves

Today we have advanced single-chip microcomputers, so it is not difficult to make a better machine life. Machine life is much more fun than a robot that runs according to a fixed program, just like a pet dog is more fun than a toy dog. The machine life we ​​envision can be a small tracked robot with solar panels that can sense light intensity, obstacle distance and collision. In order to achieve human-machine interaction, the machine life has voice recognition function. Imagine that you study for a day, return to the dormitory, call Tony, and your robot pet turns around and runs towards you quickly. Only the creator of the pet can experience that feeling...

14.jpg

3 How to achieve it? How to design the circuit? How to design the structure?

This machine life scheme uses ATmega16 microcontroller as the controller, and the 8 AD channels and the remaining 24 IO interfaces of the microcontroller are all used. The AD conversion frequency of the AVR microcontroller is higher than that of the audio, and it can be used for simple voice collection. The program of machine life is more complicated, and the AVR microcontroller is suitable for fast and complex calculations. In addition to the ATmega16 microcontroller, the circuit board of this design also has 2 LG9110 motor driver chips, 2 LM386 audio amplifier chips, and LM393 voltage comparator chips, plus a small amount of resistors, capacitors and transistors. The circuit is simple and suitable for beginners and intermediate enthusiasts to make.

The LCD uses a universal 1602 module, which supports 3-bit control lines and 4-bit data lines. If you use IO port multiplexing technology, you can use 6 lines to control the LCD module.

This solution involves technologies such as photoelectric detection, automatic charging, voice recognition, ultrasonic ranging, keyboard (4 collision switches), LCD display, and motor drive. These are the basic technologies for making simple robots. If enthusiasts can make this machine work well, then your circuit design, debugging experience, and programming skills will be greatly improved.

The technological content of this machine life is equivalent to the advanced level of the international robotics field in the 1970s. At that time, many very sophisticated and complex industrial robots were already in use, but how could such a simple robot be called advanced? Because the complexity of technology and the advancement of technology are not the same concept, and complexity + precision does not necessarily equal advancement. Advanced things are not necessarily complex and precise.

15.jpg

A Searching for Light

We can use photodiodes to detect the intensity of light. Of course, photoresistors can also be used. Connect a photoresistor and a fixed resistor in series between the positive and negative poles of the power supply, with the photoresistor close to the positive pole. Lead a wire from the connection point of the photoresistor and the fixed resistor to the AD conversion input port of ATmega16. When strong light shines on the photoresistor, the resistance of the photoresistor becomes smaller, so its voltage drop becomes smaller, and the fixed resistor voltage increases, and the AD detection potential leads to an increase, which is converted into a digital quantity by the microcontroller to determine that the light is enhanced. The robot life has 5 photoelectric sensors, 4 of which face the front, back, left, and right directions of the robot, and the other points to the direction facing the solar panel. Through programming, the robot can move autonomously to the place with the strongest light.

B Charging

This design uses a 4.8V NiMH rechargeable battery to power the system. The positive and negative poles of the solar panel are connected to the positive and negative poles of the battery through a transistor. There is a voltage comparator that compares the voltage difference between the battery voltage and the solar panel. If the voltage difference is higher than a certain value, the comparator controls the transistor to turn on, and the solar panel charges the rechargeable battery. The rechargeable battery voltage rises, and when it is higher than a certain value, the transistor is controlled to turn off, ending the charging. In order for the solar panel to charge the battery pack, the output voltage of the solar panel is required to be higher than 8V under direct sunlight.

16.jpg

C. Speech Recognition

Simple speech recognition can be achieved using the high-speed AD detection function of the AVR microcontroller. After the sound signal is received by the electret condenser microphone, it is sent to the LM386 audio amplifier chip for amplification and filtering, and then sent to the AD conversion port of the microcontroller. The microcontroller samples the amplitude of the audio signal and converts it into a set of numbers. Then, the variance operation is performed on this set to obtain a characteristic value, which can be used for simple speech recognition. For example, if you make an "e", the variance should be relatively small. If you make a "p" plosive sound, the variance should be larger. Of course, if you use more complex data processing, you will get better recognition results. This design uses 2-channel sound signals in order to allow the microcontroller to determine the general direction of the sound source.

D Ultrasonic distance measurement

Use one IO port of AVR to output a 40KHz signal to the ultrasonic transmitting circuit. When the ultrasonic wave encounters an obstacle and returns, it is received by the ultrasonic receiving head. The signal is processed by the CX20106A decoding chip to obtain a low-level pulse, which triggers an AVR microcontroller interrupt. The AVR can calculate the obstacle distance by checking the time difference between the emitted wave and the received echo.

E Motor drive

This design uses two LG9110 motor driver chips to drive two DC reduction motors. The maximum output current of LG9110 is 800mA. Only two control lines are needed to be directly connected to the IO port of the microcontroller to control the forward, reverse or stop of a motor. LG9110 has only 8 pins and is very convenient to use.

F Make machine life smarter

The coolest effect that my design of machine life can achieve is: during the day, when the sun is shining, the machine life runs to the sun to bask in the sun. The sunlight will change with time, and the machine life can automatically run to the most suitable position to enjoy the sunbath. At night, the machine life will find a quiet place to close its eyes and wait for the sun to rise tomorrow. You can train the machine life to let it know what its name is. For example, you call its name and stand in front of it to shine a strong light on its solar panel. Repeated training will make the machine life run towards the sound source after hearing its name, and stop at a certain distance from the sound source, because it can enjoy the strong light and charge in the past. This is just like a real pet dog. When you call its name, it will run to you in the hope of getting food. All of this is completely achievable. The key is to program it to achieve it.

G Imagination has no limit, your robot pet will be able to do anything

In the above scheme, the function of ATmega16 is used to the extreme, so that there is no free IO port, and the system cannot be expanded. If you use ATmega128 microcontroller, it has 53 IO ports, more than 30 interrupts, 128Kb program memory, 4Kb RAM, so that you can write more complex programs, store more dynamic data, connect more peripherals, and your machine life will become very vital. For example, add a three-axis acceleration sensor, geomagnetic sensor, GPS positioning, rain sensor, and even a camera, wireless communication module, etc., redesign a solid and strong chassis, and your machine life can explore freely outdoors.

Source of the above chip peripherals: It is easy to buy on Taobao

Chassis: 340 yuan advanced tracked 1:16 electric tank model

Accelerometer, geomagnetic sensor: 40 yuan ADXL330 accelerometer from AD company in the United States

GPS positioning: a few dozen yuan for a car-mounted external GPS antenna

Finally, I want to say that robots are very fun. As long as you have imagination, perseverance, and hard work in research and practice, you can create miracles.

Keywords:Robot Reference address:Performance characteristics and usage experience of single-chip microcomputers commonly used in making robots

Previous article:The life of a single-chip microcomputer (I feel like I am talking about most people)
Next article:Talking about the advantages and disadvantages of various microcontrollers

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号