How to control the movement of the machine by computer

/I found a website for you, have a look!

/view/ 10 12.html? wtp=tt

Single chip microcomputer definition

Single chip microcomputer refers to a complete computer system integrated on one chip. Although most of its functions are integrated on a small chip, it has most of the components needed by a complete computer: CPU, memory, internal and external bus systems, and most of them will have external memory at present. At the same time, peripheral devices such as communication interface, timer and real-time clock are integrated. Nowadays, the most powerful single-chip microcomputer system can even integrate sound, image, network and complex input and output systems on one chip.

Single chip microcomputer is also called microcontroller, because it was first used in industrial control field. Single-chip microcomputer is developed from a special processor with only CPU in the chip. The earliest design concept was to integrate a large number of peripheral devices and CPU into one chip, making the computer system smaller and easier to integrate into complex control equipment with strict volume requirements. Intel's Z80 is the first processor designed according to this idea. Since then, the development of single chip microcomputer and special processor has gone their separate ways.

Early single-chip computers were all 8-bit or 4-bit. The most successful is INTEL's 803 1, which has won great praise because of its simplicity, reliability and good performance. Since then, MCS-51series single chip microcomputer system has been developed on 803 1. The single chip microcomputer system based on this system is still widely used. With the improvement of industrial control requirements, 16-bit single-chip microcomputer has appeared, but it has not been widely used because of its unsatisfactory cost performance. With the great development of consumer electronic products since 1990s, the technology of single chip microcomputer has been greatly improved. With the wide application of INTEL i960 series, especially the later ARM series, 32-bit single-chip microcomputer quickly replaced the high-end position of 16-bit single-chip microcomputer and entered the mainstream market. The performance of the traditional 8-bit single-chip microcomputer has also been improved rapidly, and its processing capacity has been improved by hundreds of times compared with that in the 1980s. At present, the main frequency of the high-end 32-bit single-chip microcomputer has exceeded 300MHz, and its performance is catching up with the special processor in the mid-1990s, while the ex-factory price of the ordinary model has been reduced to 1 USD, and the highest-end model is only1USD. Contemporary single-chip microcomputer system is no longer just developed and used in bare-metal environment, and a large number of dedicated embedded operating systems are widely used in all series of single-chip microcomputers. In the high-end single-chip microcomputer as the core processing of handheld computers and mobile phones, even special Windows and Linux operating systems can be directly used.

Single-chip microcomputer is more suitable for embedded system than special processor, so it has been used the most. In fact, single-chip microcomputer is the largest number of computers in the world. Almost every electronic and mechanical product used in modern human life will be integrated with a single microcomputer. Cell phones, telephones, calculators, household appliances, electronic toys, palmtop computers and mice are all equipped with 1-2 single-chip computers. And there will be many single-chip computers working in personal computers. Cars are generally equipped with more than 40 single-chip computers, and there may even be hundreds of single-chip computers working at the same time in complex industrial control systems! The number of single-chip computers not only far exceeds the sum of PC and other calculations, but also exceeds the number of human beings.

[Edit this paragraph] Introduction of Single Chip Microcomputer

Single-chip microcomputer, also known as single-chip microcontroller, is not a chip to complete a certain logical function, but to integrate a computer system into a chip. To sum up: the chip becomes a computer. It is small in size, light in weight and cheap, which provides convenient conditions for learning, application and development. At the same time, learning to use single chip microcomputer is the best choice to understand the principle and structure of computer.

Microcontrollers also use modules with similar functions to computers, such as CPU, memory, parallel bus and storage devices with the same functions as hard disks. The difference is that the performance of these components is much weaker than that of our computer, but the price is also low, generally less than 10 yuan ... it is enough to do some uncomplicated work such as controlling electrical appliances. We now use automatic drum washing machine, exhaust hood, VCD and other household appliances can see it! ..... is mainly used as the core component of the control part.

It is an online real-time control computer. Online control is field control, which requires strong anti-interference ability and low cost, which is also the main difference from offline computers (such as home PC).

Single-chip microcomputer depends on the program and can be modified. Different functions, especially some special and unique functions, are realized by different programs, which other devices need to make great efforts to do, while other devices are difficult to do. If a function that is not very complicated is solved by pure hardware such as 74 series developed by the United States in the 1950s or CD4000 series in the 1960s, the circuit must be a large PCB! But if you use a series of single-chip computers that were successfully put on the market in the United States in the 1970 s, the result will be very different! Just because the single chip microcomputer can realize high intelligence, high efficiency and high reliability through the program you wrote!

Because single-chip microcomputer is sensitive to cost, the dominant software at present is the lowest assembly language, which is the lowest language except binary machine code. Since it's so low, why use it? Many advanced languages have reached the level of visual programming. Why not use them? The reason is very simple, that is, the single chip microcomputer does not have the CPU like a home computer, and there is no mass storage device like a hard disk. Even if there is only one button, a small program written in a visual high-level language will reach the size of tens of K! It's nothing for the hard disk of home PC, but it's unacceptable for single chip microcomputer. Single-chip microcomputer must have a high utilization rate of hardware resources, so assembly is still widely used although it is primitive. Similarly, if the operating system and application software on the supercomputer are run on the home PC, the home PC can't bear it.

It can be said that the 20th century spanned three "electricity" eras, namely, the electrical era, the electronic era and the computer era. However, this kind of computer usually refers to a personal computer, or PC for short. It consists of a host, a keyboard, a display, etc. There is another kind of computer that most people are not familiar with. This kind of computer is a single chip microcomputer (also called microcontroller) that gives intelligence to various machines. As the name implies, the smallest system of this computer can complete simple operation and control with only one integrated circuit. Because of its small size, it is usually hidden in the "belly" of the controlled machine. It acts like a human brain in the whole device. If something goes wrong with it, the whole equipment will be paralyzed. Now, this single-chip microcomputer has been widely used, such as intelligent instruments, real-time industrial control, communication equipment, navigation systems, household appliances and so on. Once the single-chip microcomputer is used in various products, the products can be upgraded. The adjective "smart" is often used before the product name, such as smart washing machine. At present, the products made by technicians or other amateur electronic developers in some factories are either too complicated in circuit or too simple in function and easy to be copied. The reason may be that the product does not use single chip microcomputer or other programmable logic devices.

Single chip microcomputer history

Single-chip microcomputer was born in the late 1970s and has gone through three stages: SCM, MCU and SoC.

1.SCM is the stage of single chip microcomputer, which mainly seeks the best architecture of embedded system in the form of single chip microcomputer. The success of "innovation mode" has laid a completely different development path between single chip microcomputer and general computer. Intel has made great contributions to the independent development of embedded systems.

2.MCU is the stage of microcontroller unit, and its main technical development direction is to continuously expand various peripheral circuits and interface circuits that meet the requirements of the target system and highlight its intelligent control ability in embedded applications. The fields it involves are all related to the object system, so the important task of developing MCU inevitably falls on the electrical and electronic technology manufacturers. From this point of view, Intel's gradual fading out of MCU also has its objective factors. In the development of MCU, the most famous manufacturer is Philips.

By virtue of its great advantages in embedded applications, Philips has rapidly developed MCS-5 1 from single chip microcomputer to microcontroller. Therefore, when we review the development path of embedded systems, don't forget the historical achievements of Intel and Philips.

3. Single-chip microcomputer is the independent development path of embedded system, and the important factor to develop to MCU stage is to seek the biggest solution of application system on chip; Therefore, the development of dedicated single-chip microcomputer naturally forms the trend of SoC. With the development of microelectronic technology, ic design and EDA tools, the design of single chip microcomputer application system based on SoC will have great development. Therefore, the understanding of MCU can be extended from MCU and MCU to MCU application system.

[Edit this paragraph] Application field of single chip microcomputer

At present, single-chip microcomputer has penetrated into every field of our lives, and it is almost difficult to find out which field has no trace of single-chip microcomputer. Missile navigation device, control of various instruments on the plane, computer network communication and data transmission, real-time control and data processing of industrial automation process, various intelligent IC cards widely used, safety guarantee system of luxury cars for civilian use, control of video recorders, video cameras and automatic washing machines, as well as program-controlled toys and electronic pets. , are inseparable from the single chip microcomputer. Not to mention robots, intelligent instruments and medical devices in the field of automatic control. Therefore, the research, development and application of single chip microcomputer will bring up a group of scientists and engineers in computer application and intelligent control.

Microcontrollers are widely used in the fields of intelligent management and process control of instruments, household appliances, medical equipment, aerospace and special equipment, which can be roughly divided into the following categories:

The Application of 1. in Intelligent Instruments

Single-chip microcomputer has the advantages of small size, low power consumption, strong control function, flexible expansion, miniaturization and convenient use, and is widely used in instruments and meters. Combined with different types of sensors, physical quantities such as voltage, power, frequency, humidity, temperature, flow, speed, thickness, angle, length, hardness, elements, pressure and so on can be measured. The use of single-chip microcomputer control makes the instrument digital, intelligent and miniaturized, and its function is more powerful than that of electronic or digital circuits. Such as precision measuring equipment (power meter, oscilloscope, various analyzers).

2. Application in industrial control

Single chip microcomputer can form a variety of control systems and data acquisition systems. For example, intelligent management of factory assembly lines, intelligent control of elevators, various alarm systems and computer networking form a secondary control system.

3. Application in household appliances

It can be said that the current household appliances are basically controlled by single chip microcomputer, ranging from rice cookers, washing machines, refrigerators, air conditioners, color TVs and other audio-visual equipment to electronic scales.

4. Application in computer network and communication field.

Modern single-chip computers generally have communication interfaces, which can communicate with computers conveniently, providing excellent material conditions for the application between computer networks and communication equipment. Now the communication equipment has basically realized the intelligent control of single chip microcomputer, from mobile phones, telephones, small program-controlled exchanges, building automatic communication call systems, train wireless communication, to mobile phones, trunking mobile communication, radios, etc., which can be seen everywhere in daily work.

5. The application of single chip microcomputer in the field of medical equipment

Single-chip microcomputer is also widely used in medical equipment, such as medical ventilator, various analyzers, monitors, ultrasonic diagnostic equipment, sickbed call system and so on.

6. Modularization is applied to various large electrical appliances.

Some special single-chip microcomputers are designed to achieve specific functions, so that they can be used in various circuits in a modular way without the need for users to understand their internal structure. For example, music integrated single chip microcomputer, seemingly simple function, miniature in pure electronic chip (different from the principle of tape drive), needs complex computer-like principle. For example, music signals are stored in digital form in a memory (similar to a ROM), read by a microcontroller and converted into analog music electrical signals (similar to a sound card).

In large-scale circuits, this modular application greatly reduces the size, simplifies the circuit, reduces the damage and error rate, and is also convenient for replacement.

In addition, single-chip microcomputer is widely used in industry and commerce, finance, scientific research, education, national defense and aerospace.

[Edit this paragraph] Six important parts should be learned.

Six Important Links in Single Chip Microcomputer Learning

1. bus: As we all know, circuits are always composed of elements connected by wires. In analog circuits, wiring is not a problem, because devices are generally in serial relationship, and there are not many wiring between devices, but computer circuits are different. It is based on a microprocessor, and all devices must be connected to the microprocessor, so the work between devices must be coordinated, so many wires are needed. If it is still like an analog circuit. If the microprocessor and the equipment are connected separately, the number of wires will be amazing. Therefore, the concept of bus is introduced into microprocessor, and all devices share the same wire. All eight data lines of all devices are connected to eight common lines, which means that all devices are connected in parallel, but this is not enough. If two devices send data at the same time, one is 0 and the other is 1, then the receiver will receive it. This situation is not allowed, and it needs to be controlled by the control line to make the equipment work in time sharing. Only one equipment can send data at any time (multiple equipment can receive it at the same time). The data line of the equipment is also called data bus, and all the control lines of the equipment are called control bus. There are storage units in the internal or external memory of single chip microcomputer and other equipment, and these storage units can only be used if they are assigned addresses. Of course, the assigned address is also given in the form of electrical signals. Because there are many memory cells, there are also many lines for address allocation, which are called address buses.

2. Data, address and instruction: We put them together because they are essentially the same-numbers, or a string of' 0' and'1'. In other words, addresses and instructions are also data. Instruction: A number designated by the designer of single chip microcomputer, which has a strict one-to-one correspondence with our commonly used instruction mnemonics, and cannot be changed by the developer of single chip microcomputer. Address: it is the basis for finding the internal and external storage units and input and output ports of single chip microcomputer. The address value of the internal unit has been specified by the chip designer and cannot be changed. The external unit can be decided by the microcontroller developer, but some address units are necessary (see the execution process of the program for details). Data: This is the object to be processed by the microprocessor, which is different in various application circuits. Generally speaking, the data to be processed may have the following situations:

1? Address (such as MOV DPTR, # 1000H), that is, address 1000H, will be sent to DPTR.

2? Mode word or control word (such as MOV·TMOD, #3), 3 is the control word.

3? Constants (such as MOV TH0, # 10H) 10H are timing constants.

4? Actual output value (for example, P 1 is connected with colored lights, if the lights are all on, execute the instruction: MOV P 1, # 0fh, if the lights are all dark, execute the instruction: MOV P 1, #00H), where 0fh and 00H are the actual output values. Another example is the font code for LED, which is also the actual output value.

Understanding the essence of address and instruction, it is not difficult to understand why the program will deviate and execute the data as an instruction.

Third, the use of the second function of P0, P2 and P3: Beginners are often confused about the use of the second function of P0, P2 and P3. They think there should be a switching process, or an instruction, between the second function and the original function. In fact, the second function of each port is completely automatic and does not require instruction conversion. For example, P3.6 and P3.7 are WR and RD signals respectively. When microprocessors are externally connected to RAM or have external I/O ports, they are used as secondary functions and cannot be used as general I/O ports. As long as the microprocessor executes the MOVX instruction, it will send corresponding signals from P3.6 or P3.7 without prior instruction. In fact, "can't be used as a general I/O port" is not "can't" but "won't" use it as a general I/O port. You can arrange a SETB P3.7 instruction in the instruction. When the MCU executes this instruction, it will set P3.7 to a high level, but the user will not do so, because this will usually lead to system crash.

4. Program execution process: the value in the program counter (PC) in 805 1 is' 0000' after power-on reset, so the program always starts to execute from' 0000' unit, that is, there must be' 0000' unit in the rom of the system, and an instruction must be stored in' 0000' unit.

5. Stack: Stack is an area for storing data. This area itself is nothing special, but it is part of the internal RAM. What is special is the way it stores and accesses data, that is, the so-called' first in, last out, last in, first out'. The stack has special data transmission instructions, namely' push' and' pop', and a special unit dedicated to it, namely the stack pointer SP. SP automatically adds 1 (based on the original value), and automatically subtracts 1 (based on the original value) every time the POP instruction is executed. Because the value in SP can be changed by instruction, the stack can be set in the specified storage unit as long as the value of SP is changed at the beginning of the program. For example, at the beginning of a program, a stack can be set in a cell starting from the memory cell 60H by using the MOV SP #5FH instruction. Generally, there is always an instruction to set the stack pointer at the beginning of the program, because the initial value of SP is 07H at boot, which makes the stack start at 08H, and the area from 08H to 1FH is the second, third and fourth working register area of 803 1, which will cause data confusion if it is frequently used. When different authors write programs, the initialization stack instructions are not exactly the same, which is the habit of the authors. When the stack area is set, it doesn't mean that the area becomes a special memory. It can still be used like a normal memory area, but generally speaking, programmers will not use it as a normal memory.

6. The development process of single-chip microcomputer: The development process mentioned here does not start with task analysis as the general book says. We assume that the hardware has been designed and manufactured, and the following is the work of writing software. Before writing software, we must first determine some constants and addresses. In fact, these constants and addresses have been determined directly or indirectly in the design stage. For example, when the connection of a device is designed, its address is determined, and when the function of the device is determined, its control word is also determined. Then use a text EDITor (such as edit, CCED, etc. ) to write software. After writing, compile the source file with a compiler and check for errors until there are no grammatical errors. Except for very simple programs, the simulator is generally used to debug the software until the program runs correctly. After running correctly, you can write the film (solidify the program in EPROM). After the source program is compiled, the target file with the extension HEX is generated. Ordinary programmers can recognize this format file, and they can write films by calling this file. Here, in order to give you an understanding of the whole process, give an example:

Organization 0000H

LJMP start

ORG 040H

Start:

MOV SP, # 5FH setup stack

Cycle:

Nototherwiseprovided(for) unless otherwise specified.

LJMP cycle; spread

End; end

[Edit this paragraph] MCU learning

At present, many people do not recognize assembly language. It can be said that it is very important to master the programming of single chip microcomputer in C language, which can greatly improve the efficiency of development. But beginners can't understand the assembly language of single chip microcomputer, but they must know the specific performance and characteristics of single chip microcomputer, otherwise it will be fatal in the field of single chip microcomputer. If you don't consider the hardware resources of single chip microcomputer, you can only program in KEIL with C at will, and the result can only be an unsolvable problem! To be sure, the best single-chip engineers in C language are all assembled programmers. Although the C language of single chip microcomputer is a high-level language, it is different from VC++ on desktop personal computers. The hardware resources of single chip microcomputer are not very strong, which is different from writing programs on desktop PC with high-level languages such as VC and VB. After all, the hardware of desktop computers is very strong, so we can ignore the problem of hardware resources.

Take 805 1 single chip microcomputer as an example to explain the pins and related functions of single chip microcomputer;

Single chip microcomputer pin diagram

According to the pin function, these 40 pins can be roughly divided into four categories: power supply, clock, control and I/O pins.

1. Power supply:

(1) VCC chip power supply, connected to+5v;

(2)VSS- grounding terminal;

Note: Generally, the pin voltage of MCU tested by multimeter is 0v or 5v, which is the standard TTL level. But sometimes when the MCU program is working, the test result is not this value, but between 0v and 5v. In fact, this is because the response speed of the multimeter is not so fast, and the pin voltage of MCU is kept at 0 V or 5 V at a certain moment.

Clock: XTAL 1, xtal 2- the inverting input and output of the crystal oscillator circuit.

3. Control line: There are four control lines.

(1) ale/Prog: data latch enable/on-chip EPROM programming pulse.

① ALE function: used to latch the low-order 8-bit address sent by P0 port.

② PROG function: a chip with EPROM on the chip. During EPROM programming, this pin inputs programming pulses.

⑵ PSEN: external ROM read strobe signal.

⑶ RST/VPD: reset/standby power supply.

① RST (reset) function: reset signal input.

② VPD function: Connect the standby power supply when the Vcc power supply fails.

⑷ EA/Vpp: internal and external ROM selection/on-chip EPROM programming power supply.

① EA function: internal and external ROM selection terminals.

② Vpp function: In the process of programming EPROM, the programming power Vpp is added to the chip with EPROM.

Input-output line

80c51* * * has four 8-bit parallel I/O ports: P0, P 1, P2, P3 and ***32 pins.

The P3 port also has a second function, which is used for the input and output of special signals and control signals (belonging to the control bus).

[Edit this paragraph] Brief introduction of common single chip microcomputer chips

PIC microcontroller:

It's a product of microchip company. Its outstanding features are small size, low power consumption, simplified instruction set, good anti-interference, high reliability, strong analog interface and good code confidentiality. Most chips have their own compatible flash program storage chips.

EMC single chip microcomputer;

It is a product of Taiwan Province Yilong Company, a large part of which is compatible with PIC 8-bit single chip microcomputer, and the resources of compatible products are relatively more than PIC, and the price is cheaper. There are many series to choose from, but the anti-interference performance is poor.

ATMEL single chip microcomputer (5 1 single chip microcomputer);

ATMEl's 8-bit MCU has two series: AT89 and AT90. AT89 series is an 8-bit Flash single chip microcomputer, which is compatible with 805 1 series single chip microcomputer and has static clock mode. AT90 series MCU is a kind of MCU with enhanced RISC structure, fully static working mode and online programmable Flash, also called AVR MCU.

PHLIPIS 5 1PLC series single chip microcomputer (5 1 single chip microcomputer);

Philips MCU is based on 80C5 1 core, and embedded with power failure detection, simulation and on-chip RC oscillator, which makes 5 1LPC meet various performance requirements in application design with high integration, low cost and low power consumption.

HOLTEK microcontroller:

The single-chip microcomputer of Shengyang Semiconductor in Taiwan Province Province is cheap and has many kinds, but it has poor anti-interference and is suitable for consumer products.

Single chip microcomputer (5 1 single chip microcomputer) of TI company;

Texas Instruments provides TMS370 and MSP430 series of general-purpose single-chip computers. TMS370 is an 8-bit CMOS single chip microcomputer, which has multiple storage modes and multiple peripheral interface modes, and is suitable for complex real-time control occasions. MSP430 series single chip microcomputer is a 16-bit low-power single chip microcomputer, which has ultra-low power consumption and high functional integration, and is especially suitable for occasions requiring low power consumption.