Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

Click above
“China Command and Control Society”
to follow us!
Many friends who have just come into contact with robots or microcontrollers may be confused by the various types of microcontrollers. What are the differences between them? Which microcontroller is better for controlling robots? Once we choose a microcontroller, what shortcuts can we take to quickly master and apply it? This article attempts to interpret the above questions in a simple and understandable way, and designs an in-depth example of microcontroller-controlled robots, hoping to serve as a catalyst for further exploration. I would like to share some of my experiences with microcontrollers, hoping to reduce the confusion for beginners and broaden the perspectives of those who have already started.
1. The Differences and Relationships Between Microcontrollers, CPUs, and Personal Computers

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

This part is relatively basic, but many friends may not be very clear about the following questions when they first come into contact with microcontrollers.
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
1. What is a CPU?
The CPU, or Central Processing Unit, is typically represented by the Intel 8086 processor. The current Pentium X processors are direct descendants of the 8086. The function of a processor is to process data. For a central processing unit, it is the core processor in data processing. It sounds complicated, but the core is just an ALU (Arithmetic Logic Unit). This unit consists of some digital gate circuits and can only perform basic arithmetic operations such as addition, subtraction, multiplication, and division, as well as logical operations like AND, OR, NOT, XOR, and operations like shifting, comparing, and transferring. The CPU contains the ALU, and in addition, it has a clock circuit. The basic principle of CPU operation is that the clock circuit generates counting pulses, which control an accumulator. Every time a clock pulse is generated, the accumulator increments by 1. This accumulated value uniquely selects a storage unit in the program memory (external to the CPU) in hexadecimal format via the address bus. This unit sends the stored program command code through the data bus to the ALU. The ALU performs different operations based on different codes, such as adding the value of a certain register to a certain value, and then outputs the result to the IO port or various buses.
In summary, the CPU’s job is to translate the command codes in the program into different tasks, execute them, and output the results. The CPU plays a core role in all digital computers, meaning that every computer has a CPU.
2. What is a Personal Computer?
Since the CPU only has computing functions, the results of its calculations need to be output through a monitor or speakers, and the program commands it operates on are stored on the hard drive. The data dynamically accessed during task execution must be stored in memory, and users can control the execution process of the program commands through the keyboard. All these peripherals of the CPU combined together are called a “personal computer.”
3. What is a Microcontroller?
Personal computers are powerful and fast, making them ideal computing devices. However, when we need to control a microwave oven’s timer with a small device, personal computers become bulky and expensive. Therefore, people designed a compact computer, some as large as a few square centimeters, and some smaller than a grain of rice, called “microcontrollers”—single-chip microcomputers. The CPU is a chip, and the microcontroller is also a chip; they look similar, but what are the differences? The answer is that in addition to integrating the CPU, a microcontroller also integrates program memory ROM (which can be understood as a hard drive), data memory RAM (which can be understood as memory), and input/output interfaces (which can be understood as monitor and keyboard sockets). Some microcontrollers also integrate motor driver circuits, video decoding circuits, AD converters, wireless transmission circuits, etc., making microcontrollers very powerful. The specialty of microcontrollers lies in their ability to implement complex control operations with a single chip and simple external circuits, making them very suitable for robot control. In fact, most robots have traces of microcontrollers. Simple and moderately complex robots can be directly controlled by microcontrollers, while highly complex robots are commanded by “personal computers” or “supercomputers” to direct many microcontrollers in robot control.
4. What are the Shortcuts to Learning Microcontrollers?
The so-called shortcuts mean to avoid detours. When I first started learning microcontrollers, I took many detours, and many friends have similar experiences. When first touching microcontrollers, faced with a plethora of textbooks, it’s hard to know which one to choose; when wanting to practice, it’s unclear where to buy microcontrollers; and not knowing how to program and download programs…
  
A. For beginners, carefully reading this article is one of the shortcuts to learning microcontrollers.
  
B. Go to the library or bookstore and choose a microcontroller book among dozens that you can understand and find interesting, a “practical, vivid, and lively” microcontroller book as your introductory reading material.
  
C. It is recommended to start with the 8051 microcontroller. After mastering the 8051, then learn AVR, and then ARM, DSP, etc.
  
D. Practical experience is essential during the learning process. You need a computer. If it’s a desktop computer, you can buy a 25-pin parallel download cable for a few dollars; if it’s a laptop, you can only buy a USBISP programmer for dozens to hundreds of dollars.
  
E. You can solder a minimal system of the microcontroller on a universal board yourself or buy a development board. There’s no need to use expensive simulators. F. You need to download microcontroller programming software online, such as using Keil for 8051 programming, CVAVR for AVR programming. Write the program in the programming software, generate a HEX file, then download the parallel burning software or USBISP burning software online, load the HEX file with the burning software, and then connect the programming line to your microcontroller circuit board to burn the program into the microcontroller.
  
G. Disconnect the programming line, then power on the microcontroller board, and you will see the microcontroller system running.
  
H. If the system does not run properly, first check if the circuit is connected incorrectly, then check if the program is burned incorrectly. If neither is wrong, investigate whether the program is compiled incorrectly. Sometimes, the system not running does not mean something is wrong; it may just be that certain parameters are not set correctly. You need to keep running, modifying the program, debugging parameters, and running again until you are satisfied with the system operation. Sometimes this is a very arduous repetitive task, adjusting hundreds to thousands of times. You cannot avoid it; you can only hold firm beliefs and move forward bravely.
  
I. Buying things on Taobao is more convenient and cheaper.
2. What Did People Use to Control Robots Before Microcontrollers Were Born?

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

1. Analog Computers
Before digital computers were born, people built analog computers using vacuum tubes, capacitors, inductors, and resistors, capable of completing many simple calculations and control tasks. An analog computer uses signals that are not binary (1, 0) but rather continuously varying analog signals, similar to the operations used in various controllers in automatic control principles. Do not underestimate analog computers; during the Middle Eastern wars of the 1980s, the Arab countries used Soviet-made fully automatic self-defense artillery that employed analog computers to calculate aircraft trajectories and control artillery fire.
2. Controllers Composed of Gears and Cams
Before the birth of analog computers, during the steam engine era, some mechanical geniuses built mechanical computers using hundreds of gears and cams. People displayed the calculation results by turning gears marked with numbers. Mechanical computers were once high-tech products in human history. During World War II, Germany’s famous cipher machine was a type of electromechanical hybrid computer and was the most secure communication tool at the time.
3. Controllers Composed of Springs, Stopwatches, and Relays
At the beginning of the electrical era, people used the mechanical rotation of clocks to control some relays, thus controlling the operation of some machine tools and production lines. This device is similar to the timer in early washing machines.
3. Recommended Entry-Level Microcontroller: AT89S51 Series

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

1. Introduction
In 1980, Intel developed a simple 8031 CPU, which at the time had performance not much inferior to the 8086 but was cheaper, thus being chosen for many low-end applications. Due to market optimism, ATMEL acquired the 8031 core, integrating Flash memory and enhanced IO ports to develop the AT89 series microcontrollers. All microcontrollers compatible with the 8031 instruction set and similar cores are collectively referred to as 51 microcontrollers, which are among the most widely used 8-bit microcontrollers today. Because the 51 microcontroller has a simple structure, easy-to-learn instructions, and wide applications, it is the preferred model for beginners in microcontrollers. If someone wants to skip learning the 51 and directly learn AVR, that person will definitely encounter many difficulties, and confusion and frustration will accompany the learning process. If one learns 51 first and then learns AVR and other microcontrollers, they will find that “all microcontrollers are not that different.”
2. Performance
Choose the most suitable microcontroller based on specific task needs, fully utilize the resources of the microcontroller, achieve the highest cost-performance ratio for the system, and consider future expansion needs without blindly pursuing high-performance microcontrollers. This is the principle of selecting microcontrollers.
  
The AT89S51 has 4K of Flash program memory, 128 bytes of RAM, 32 IO ports, and an interrupt system with 6 interrupt sources, 5 terminal vectors, and 2 interrupt priorities; the serial port is a full-duplex serial communication port; the power supply voltage for the AT89S51 is 4.0-5.5V, and for the AT89LS51, it is 2.7-4.0V; the oscillator frequency is 0-33MHz (AT89S51) and 0-16MHz (AT89LS51); it has ISP online programming capability, which allows rewriting the program in the microcontroller’s memory without removing the chip from the working environment. This is a powerful and easy-to-use feature.
The AT89S52 has a program memory capacity of 8KB, and there are also AT89S55 with larger ROM capacity.
  
Many companies produce various extended 51 series microcontrollers, some with AD converters, some with comparators, and some with PWM. Readers can choose suitable 51 microcontrollers based on their needs, but they should be aware of their pin definitions and programming methods.
3. Usage Methods
The AT89S51 is suitable for making microcontroller learning boards, electronic clocks, ultrasonic distance measuring devices, etc., which do not require analog signal acquisition and control of high-power external components. The difference between S51 and the past C51 is that S51 supports ISP online programming, which means C51 required hundreds of dollars for a programmer, while S51 only requires a 25-pin parallel cable and a very simple conversion circuit to connect to the desktop computer’s printer port for programming. Programming the 51 microcontroller is generally done using Keil software, which can be done in C or assembly language. After programming, select to output the HEX file, then use the programming software to read the HEX file and write it to the microcontroller. 4. Practical Experience
  
A. When I first started reading, I would connect the circuit according to the schematic in the book and power it on for debugging, but it never worked. I carefully compared my circuit with the schematic in the book and found no issues. The reason is that many circuit diagrams in books are “simplified diagrams,” meaning they omit some circuits that are crucial for system operation. For example, when microcontroller books discuss AD conversion circuits, the circuit diagrams often omit the crystal oscillator and reset circuits, which naturally results in the system not functioning as expected.
  
B. The P0 port of the 51 microcontroller needs a pull-up resistor when outputting signals; I often forget to add the resistor, resulting in the circuit not working.
  
C. The 31 pin of the 51 microcontroller needs to be connected to the positive terminal to choose the internal program memory. If you forget to provide the correct voltage to this pin, your microcontroller may not execute the program.
4. Application Examples
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
4. Preferred Microcontroller for Hobbyists: AVR Series

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

1. Introduction
The AVR microcontroller was developed by ATMEL in 1997 as an enhanced version with built-in Flash and RISC (Reduced Instruction Set CPU) architecture, a high-speed 8-bit microcontroller. High reliability, strong functionality, high speed, low power consumption, and low price have always been important indicators of microcontroller performance, and the AVR microcontroller is a typical high-performance microcontroller.
  
Early microcontrollers, such as the 51 microcontroller, adopted a higher frequency division ratio for clock division to improve reliability (preventing data misreading or runaway), resulting in long instruction cycles and slow execution speeds. For example, the 51 microcontroller requires 12 crystal oscillator cycles to form 1 machine cycle, and many instructions require 2 machine cycles to execute. The introduction of the AVR microcontroller completely broke this old design pattern, abolishing machine cycles, adopting a reduced instruction set, shortening the instruction fetch cycle, and allowing pre-fetching of instructions for pipelined operation, thus enabling high-speed instruction execution. The AVR microcontroller 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.
  
The AVR series microcontrollers often integrate multiple AD converters, voltage comparators, ISP, I2C, JTAG bus circuits, UART serial ports, high-power IO ports, watchdogs, and other practical circuits, and many AVR microcontroller models have EEPROM, FLASH, and SRAM, enabling real-time modification of the contents in the program memory, meaning AVR microcontrollers can modify their own programs. Additionally, AVR generally operates within a wide voltage range (2.7-6.0V), with some capable of operating at 1.8V. These performances are just a part of the many capabilities of AVR, which already makes the 51 series microcontrollers look inferior.
  
Such high-performance microcontrollers are priced similarly to the 51 microcontrollers, for example, the ATmega8 costs around 8 yuan, and the ATmega16 around 13 yuan, reflecting the high cost-performance ratio of AVR.
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
2. Performance
The AVR family is thriving, including ATinyAVR (micro-sized), low-power types, and ATmegaAVR high, medium, and low-end microcontrollers. They all rely on the same core technology but differ in the number of integrated circuits. Whether you want to make an electronic watch or video processing, there is an AVR microcontroller that can meet your needs.
  
This article only lists the performance of the ATmega16 mid-range microcontroller:
  
16KB of FLASH program memory; 512B of EEPROM; 1KB of 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 comparators; watchdog; built-in clock oscillator; JTAG interface; ISP online programming; voltage range of 2.7V-5.5V; external clock crystal 0-16MHz; with PID and various chip packages.
  
The IO ports of the AVR can output 20mA and absorb 40mA of current, which can directly drive LEDs and even small DC reduction motors. Moreover, the AVR IO ports can be programmed to be set as input, output, or high-impedance state, making them true three-state IO ports. Compared to using the 51, you will find unprecedented convenience and freedom when developing products with AVR.
  
AVR microcontrollers can run operating systems such as UCOS2, Linux, etc., and implementing operating system functions through self-programming is also very easy.
  
Choose the most suitable microcontroller based on specific task needs, fully utilize the resources of the microcontroller, achieve the highest cost-performance ratio for the system, and consider future expansion needs without blindly selecting high-performance microcontrollers. This is the principle of selecting microcontrollers.
  
Using ARM + operating systems for ultrasonic distance measuring devices is overkill. Using mid-range AVR microcontrollers for machine vision may be overwhelming. If you swap them around, everything will be just right.
3. Usage Methods
A good book for learning AVR microcontrollers is “Principles and Application Practice of AVR Microcontroller Embedded Systems,” as shown on the cover below.
  
AVR generally uses CVAVR programming software for programming, but GUNGCCAVR and AVRStudio software can also be used. It can be programmed in assembly or C language. Before burning the program, first output the HEX file, then use SLISP (Shuanglong ISP) software to load it, and then burn it into the AVR microcontroller through ISP programming lines or 25-pin parallel connection lines, supporting online programming. Since the minimal system for AVR microcontrollers is very simple, just power + oscillator (optional) + LED + ISP interface (runs on power, stops on power-off, no reset circuit needed), any beginner can build the minimal AVR system using a breadboard and practice programming.
4. Practical Experience
When using AVR microcontrollers, pay attention to correctly set the fuse bits, which can be set using SLISP software. The fuse bits determine whether the microcontroller uses an external crystal oscillator or an internal clock oscillator. If the fuse bits are set to use an external crystal oscillator and the circuit does not connect a crystal oscillator, the AVR program cannot run. Many beginners overlook this point, and their AVR systems cannot run without finding the reason. Additionally, the AVR IO ports must be programmed to set their states before use; otherwise, you will find that the program is running, but the IO ports have no signals.
5. Advanced Robot Controllers: ARM

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

1. Introduction
ARM is a company name; they have designed many high-performance processors based on the same core, all called ARM. This technology has been purchased by many companies, producing ARM chips that integrate many functional circuits, making ARM high-performance microcontrollers. ARM is generally a 32-bit microcontroller suitable for processing large amounts of complex data, many of which run UCOS2, Windows CE, Linux operating systems, and can run multiple programs simultaneously. ARM is widely used in products such as mobile phones, MP3 players, GPS navigation devices, and vacuum robots.
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
6. Preferred DSP for Audio and Video Processing

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

DSP, or Digital Signal Processing, is a unique microprocessor designed to process large amounts of information using digital signals. Its working principle involves receiving analog signals, converting them into digital signals of 0 or 1, modifying, deleting, or enhancing the digital signals, and then interpreting the digital data back into analog data or actual environmental formats in other system chips. It not only has programmability but also can run complex instruction programs at speeds of several tens of millions per second, far exceeding general-purpose microprocessors, making it an increasingly important computer chip in the digital electronic world. Its powerful data processing capabilities and high running speeds are its two most commendable features.
  
DSP is widely used in fields such as high-speed small vehicle line following and voice recognition. However, using DSP to detect a few collision switches and control a few motors seems like overkill.
7. Emerging Controllers: FPGA

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

FPGA, or Field-Programmable Gate Array, is a product that has further developed based on programmable devices such as PAL, GAL, and CPLD. It appears as a semi-custom circuit in the ASIC field, allowing system designers to connect the internal logic blocks of the FPGA according to their needs through editable connections, similar to putting a circuit test board on a chip. In simple terms, if a user wants to develop a small vehicle controlled by simple digital logic circuits but finds assembling circuits troublesome, they can program an FPGA with software to achieve the digital circuit functions to control the vehicle. In other words, FPGA can be used to simulate various circuits. Some FPGAs can even simulate the operation of the 51 microcontroller. Because FPGA can modify the simulated circuit structure through programming, it is very convenient for system experiments and debugging, and many hobbyists try to use FPGA as robot controllers.
8. More Microcontrollers to Choose From

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

Before choosing to learn a microcontroller, we must first consider what performance is needed for the specific tasks we face, and then make a choice among the many microcontrollers that meet the requirements. At this time, we should also consider the “wide application degree” of different microcontrollers. For example, when we want to make an intelligent car for an electronic competition, both AVR microcontrollers and PIC microcontrollers can meet the task needs. How to choose between the two requires considering which microcontroller is easier to learn, which has easily accessible learning materials, and which has richer reference programs and cases, as well as which microcontroller is easier to obtain programming software and downloaders. I feel that for making intelligent cars, there is more abundant information available for AVR microcontrollers.
  
There are a wide variety of microcontrollers in the world, most of which can be used to control robots, but there is a question of suitability. For example, PLCs (Programmable Logic Controllers) can certainly be used to control robots in the hands of hobbyists, but PLCs are mostly used in the industrial control field, are large and expensive, and it is not easy to find materials for controlling small robots with PLCs. Before hobbyists choose to learn a microcontroller, they should first clarify what they want to do with the microcontroller and then select the most suitable microcontroller for learning. Learning microcontrollers should focus on mastering one or two types well. If someone learns all the famous microcontrollers like ARM, PLC, PIC, Lingyang, DSP, FPGA, etc., they will not have the true ability to develop deeply. The so-called deep development, taking the AVR microcontroller as an example, beginners can use it to achieve simple LED blinking, intermediate technicians can use it to control competition robots, while truly advanced developers can use AVR to achieve machine vision, drone autopilot, tank fire control systems…
Is the AVR Microcontroller Outdated?
Some beginners even intermediate developers believe that since ARM generally has better performance than AVR, ARM will replace AVR, and AVR will exit the historical stage, or MSP430 will replace the 51 series microcontrollers, or FPGA will replace all microcontrollers, etc. This view is incorrect because different microcontrollers have their own characteristics and advantages; there is no perfect microcontroller. The most suitable microcontroller should be used in different scenarios to leverage their respective strengths, and there is no possibility of ARM dominating and replacing all other microcontroller models. Just imagine, if an electronic watch originally costing a few dozen yuan was controlled by ARM and sold for several hundred yuan, who could afford it? Therefore, do not think that AVR is outdated; learning 51 and then directly learning ARM, or thinking that learning 51 is useless and directly learning ARM will lead to setbacks.
MSP430 series microcontrollers: More suitable for robot development, it is a 16-bit mixed-signal processor with a reduced instruction set launched by Texas Instruments. It features Flash memory, many interrupt sources, and flexible use with arbitrary nesting. The power supply voltage for the MSP430 series microcontrollers is 1.8-3.6V, allowing it to run at a current of 200-400uA under a 1MHz clock condition, with a minimum power consumption of only 0.1uA in clock shutdown mode. Each member of the MSP430 series microcontrollers is integrated with a rich variety of internal peripherals, including watchdogs, analog comparators, timers, serial ports, hardware multipliers, LCD drivers, 10-bit/12-bit ADCs, 16-bit Sigma-Delta AD, direct addressing modules (DMA), IO ports, and basic timers (Basic Timer), among other peripheral modules in different combinations.
PIC microcontrollers: Can be used for robot development, they are 8-bit microcontrollers with a rich variety of products, using a reduced instruction set, with good development environments and strong pin drive capabilities, allowing direct connection to relays for controlling high power. They come with watchdogs and have sleep and low-power modes. Many of their performance features are not as good as AVR and MSP430 series microcontrollers, but due to their special advantages, they are also widely used.
Lingyang microcontrollers: More suitable for robot development, based on 16-bit computing, integrating different scales of RAM, ROM, and other rich functional circuits, allowing users to select Lingyang microcontrollers with specific functional circuits based on their needs. The instruction system of Lingyang microcontrollers provides high-speed 16-bit calculations, including 16-bit multiplication and inner product instructions, adding DSP functionalities to their applications, thus Lingyang is suitable for voice recognition. In China, Lingyang microcontrollers are common in schools, with many application examples, making them suitable for robot enthusiasts to choose.
9. Example: Creating Machine Life with AVR Microcontroller

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

1. What is Machine Life?
Machine life refers to a machine that can survive autonomously, a machine that automatically strives for survival. For machine life, survival means continuous operation without power interruptions. Machine life has characteristics such as complete autonomous decision-making, autonomous action, operating in unknown environments, continuous operation without human involvement, and self-maintenance. The Skynet in the movie “Terminator” is a super machine life. The movie “Short Circuit 5” describes the process of a robot going from lifeless to having life.
  
Norbert Wiener (1894-1964) created the first machine life, the Wiener Turtle, while writing “Cybernetics.” This machine turtle consists of just two vacuum tubes forming an analog computer, yet it can perform true turtle behaviors like foraging, sleeping, exploring, and escaping, behaving like a living organism. The machine turtle has solar cells on it; before its battery runs low, it seeks a well-lit place to recharge. Once fully charged, it may find a place to take a nap or explore the unknown world. It has tendencies to avoid collisions and steep places, and we cannot predict its movements because it does not operate according to a program, just like ourselves. Later, Wiener added another vacuum tube to his machine turtle, connecting three vacuum tubes to form a simple neural network. By training the machine turtle, Wiener could control its behavior by ringing a bell, just like biologists train dogs to salivate upon hearing a bell.
2. We Can Make a Machine Pet Ourselves
Today, with advanced microcontrollers, making a better machine life is actually not difficult. Machine life is much more fun than robots that run according to fixed programs, just like a pet dog is more fun than a toy dog. We envision a machine life as a small tracked robot equipped with solar panels that can sense light intensity, obstacle distance, and collisions, and to achieve human-machine interaction, this machine life will have voice recognition capabilities. Imagine after a long day of study, you return to your dormitory, call out “TONY,” and your machine pet quickly turns and runs toward you; that feeling is something only the creator of the pet can understand…
3. How to Achieve It? How to Design the Circuit? How to Design the Structure?
This machine life plan uses the ATmega16 microcontroller as the controller, utilizing all 8 AD channels and the remaining 24 IO interfaces. The AVR microcontroller’s AD conversion frequency is higher than audio, allowing for simple voice capture. The program for machine life is relatively complex, and the AVR microcontroller is suitable for fast complex calculations. The circuit board designed includes the ATmega16 microcontroller, two LG9110 motor driver chips, two LM386 audio amplifier chips, and an LM393 voltage comparator chip, along with a few resistors, capacitors, and transistors, making the circuit simple and suitable for beginners and intermediate enthusiasts to create.
  
The LCD uses a universal 1602 module, supporting 3 control lines and 4 data lines. If you use IO port multiplexing technology, you can control the LCD module with 6 lines. This plan involves technologies such as photoelectric detection, automatic charging, voice recognition, ultrasonic distance measurement, keyboard (4 collision switches), LCD display, and motor driving. These are basic technologies for making simple robots. If enthusiasts can successfully create this machine life, their circuit design, debugging experience, and programming skills will greatly improve.
  
The technical content of this machine life is equivalent to the advanced level in the international robotics field of the 1970s. At that time, many very precise and complex industrial robots were applied, but how can this simple robot be considered advanced? Because the complexity of technology and the advancement of technology are not the same concept; complexity + precision does not necessarily equal advancement. Advanced things are not necessarily complex and precise.
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
A. Light Seeking
  
We can use a photodiode to detect light intensity. Of course, a photoresistor can also be used. Connect the photoresistor and a fixed resistor in series between the positive and negative terminals of the power supply, with the photoresistor close to the positive terminal. A lead from the connection point of the photoresistor and the fixed resistor goes to the AD conversion input of the ATmega16. When strong light shines on the photoresistor, its resistance decreases, thus its voltage drop decreases, while the fixed resistor’s voltage drop increases, raising the AD detection potential, which the microcontroller converts into a digital signal to determine that the light intensity has increased. The machine life has 5 photoelectric sensors, with 4 facing the front, back, left, and right of the robot, and the other pointing towards the direction the solar panel faces. By programming, the robot can autonomously move to the area with the strongest light.
  
B. Charging
  
This design uses a 4.8V nickel-hydrogen rechargeable battery for system power. The positive and negative terminals of the solar panel are connected to the positive and negative terminals of the battery through a transistor. A voltage comparator compares the battery voltage with the voltage difference from the solar panel; if the difference exceeds a certain value, the comparator controls the transistor to turn on, allowing the solar panel to charge the battery. When the charging battery voltage rises above a certain value, it controls the transistor to turn off, ending the charging process. To allow the solar panel to charge the battery pack, it is required that the solar panel outputs a voltage higher than 8V under direct sunlight.
Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics
C. Voice Recognition
  
Using the high-speed AD detection capabilities of the AVR microcontroller allows for simple voice recognition. The sound signal is received by an electret condenser microphone, amplified and filtered by the LM386 audio amplifier chip, and sent to the microcontroller’s AD conversion port. The microcontroller samples the amplitude of the audio signal, converting it into a set of numbers, then calculates the variance of this set to obtain a feature value, which can be used for simple voice recognition. For example, if you emit an “e,” the variance should be relatively small; if you emit a plosive sound like “p,” the variance should be larger. Of course, using more complex data processing will yield better recognition results. This design uses 2 sound signals, aiming to allow the microcontroller to determine the general direction of the sound source. D. Ultrasonic Distance Measurement
  
Using one IO port of the AVR to output a 40KHz signal to the ultrasonic transmission circuit, when the ultrasonic wave encounters an obstacle and returns, it is received by the ultrasonic receiver, and the signal is processed by the CX20106A decoding chip to obtain a low-level pulse, which triggers an interrupt in the AVR microcontroller. By checking the time difference between the emitted wave and the received echo, the AVR can calculate the distance to the obstacle.
  
E. Motor Driving
  
This design uses 2 LG9110 motor driver chips to drive two DC reduction motors. The LG9110 outputs a maximum current of 800mA and only requires 2 control lines to be directly connected to the microcontroller’s IO port to control a motor’s forward, reverse, or stop. The LG9110 only has 8 pins, making it very convenient to use.
  
F. Making Machine Life Smarter
  
The coolest effect that my machine life design can achieve is: during the day, when the sun is shining, the machine life runs to bask in the sun, and as the sunlight changes throughout the day, the machine life can automatically move to the most suitable position to enjoy sunbathing. At night, the machine life finds a quiet place to close its eyes and rest, waiting for the sun to rise tomorrow. You can train the machine life to recognize its name. For example, if you repeatedly call its name while standing in front of it and shining strong light on its solar panel, it will learn to run towards the sound source when it hears its name, stopping at a certain distance from the sound source because it has previously learned that this action allows it to enjoy strong light and recharge. This is just like a real pet dog; when you call its name, it runs to you, hoping to get food. All of this is completely achievable, and the key lies in programming to implement it.
  
G. Imagination Has No Limits; Your Machine Pet Will Be All-Powerful
  
In the above plan, the functions of the ATmega16 are utilized to the fullest, leaving no idle IO ports, and the system cannot be further expanded. If you use the ATmega128 microcontroller instead, it has 53 IO ports, over 30 interrupts, 128Kb of program memory, and 4Kb of RAM, allowing you to write more complex programs, store more dynamic data, and connect more peripherals, making your machine life very vibrant. For example, by adding a three-axis accelerometer, geomagnetic sensor, GPS positioning, rain sensor, or even a camera and wireless communication module, and redesigning a strong and robust chassis, your machine life can explore freely outdoors.
  
The source of the above chip peripherals is easy to find on Taobao.
  
Chassis: Advanced tracked 1:16 electric tank model for 340 yuan.
  
Accelerometer, geomagnetic sensor: AD company’s 40 yuan ADXL330 accelerometer.
  
GPS positioning: Car-mounted external GPS antenna for dozens of yuan.

Source: China Electric Network

C2

How to Join the Society

Register as a Society Member:

Individual Member:

Follow the Society’s WeChat: China Command and Control Society (c2_china), click on the CICC member – individual member below, enter the member system, and fill out the application form as required. If you have questions, you can read the “Read the Society Constitution” and “Read the Membership Guidelines” below. You can pay the membership fee online via Alipay after passing the society’s review.

Unit Member:

Follow the Society’s WeChat: China Command and Control Society (c2_china), click on the CICC member – unit member below, enter the member system, and fill out the application form as required. After passing the society’s review, please follow the payment information in the “Read the Membership Guidelines” to pay the membership fee.

Recent Activities of the Society

“Overcoming Obstacles 2016” Ground Unmanned System Equipment and Technology Development Forum:

Conference Date: September-October 2016

Long press the QR code below to follow the society’s WeChat

Performance Characteristics and Usage Experience of Microcontrollers Commonly Used in Robotics

Thank you for your attention

Leave a Comment