Microcontroller Design Appliance Status Detection Circuit

Microcontroller Definition

A microcontroller is a complete computer system integrated on a single chip. Although most of his functions are integrated on a small chip, it has most of the components needed for a complete computer: CPU, memory, internal and external bus systems, and now most of them will also have external memory. Also integrated peripherals such as communication interfaces, timers, real-time clocks. And now the most powerful microcontroller system can even be sound, image, network, complex input and output systems integrated into a chip.

A microcontroller is also known as a microcontroller because it was first used in the field of industrial control. Microcontrollers evolved from specialized processors that had only a CPU on a chip. The earliest design concept was to integrate a large number of peripherals and CPU in a chip, so that the computer system is smaller and easier to integrate into the complexity of the volume of strict requirements of the control equipment. INTEL's Z80 is the first processor designed according to this idea, and from then on, the development of microcontrollers and specialized processors will be separated.

Early microcontrollers were 8-bit or 4-bit. One of the most successful was INTEL's 8031, which received great acclaim for its simplicity, reliability, and good performance. Since then, the MCS51 series of microcontroller systems have been developed on the 8031. The microcontroller system based on this system is still widely used until now. With the improvement of the requirements of the industrial control field, 16-bit microcontroller began to appear, but because of the price-performance ratio is not ideal and has not been widely used. 90's with the development of consumer electronics products, microcontroller technology has been greatly improved. With the INTEL i960 series, especially the later ARM series of widely used, 32-bit microcontroller to rapidly replace the 16-bit microcontroller high-end status, and enter the mainstream market. The performance of the traditional 8-bit microcontroller has also been rapidly improved, and the processing power has been increased hundreds of times compared with that of the 80s. At present, the high-end 32-bit microcontroller main frequency has exceeded 300MHz, performance to catch up with the mid-90's dedicated processor, while the ordinary model factory price fell to 1 U.S. dollars, the highest-end model is only 10 U.S. dollars. Contemporary microcontroller systems are no longer developed and used only in bare-metal environments, and a large number of specialized embedded operating systems are widely used on a full range of microcontrollers. The high-end microcontrollers used as the core processing of PDAs and cell phones can even directly use dedicated Windows and Linux operating systems.

Microcontrollers are much better suited to embedded systems than dedicated processors, so they are the most widely used. In fact microcontrollers are the most numerous computers in the world. Microcontrollers are integrated into almost every electronic and mechanical product used in modern human life. Cell phones, telephones, calculators, household appliances, electronic toys, palmtop computers, and computer accessories such as mice are equipped with 1-2 microcontrollers. Personal computers also have a number of microcontrollers working in them. Automobiles are generally equipped with more than 40 microcontrollers, and complex industrial control systems may even have hundreds of microcontrollers working at the same time! The number of microcontrollers not only far exceeds the combined number of PCs and other computing, but is even greater than the number of humans.

[edit]Introduction of microcontroller

Microcontroller, also known as a single microcontroller, it is not the completion of a logical function of the chip, but a computer system integrated into a chip. To summarize: a chip becomes a computer. Its small size, light weight, inexpensive, for learning, application and development to provide a convenient condition. At the same time, learning to use a microcontroller is the best choice to understand the principles and structure of the computer.

Microcontroller internal and computer functions similar to the module, such as the CPU, memory, parallel bus, and hard disk role of the same memory components, the difference is that the performance of these components are relative to our home computer is much weaker, but the price is also low, generally no more than 10 yuan can be ...... Use it to do some control of electrical appliances of a class is not very complex work enough. We now use the automatic drum washing machine, smoke hood, VCD and other home appliances can be seen inside its figure! ...... It is mainly as the core component of the control part.

It is a kind of online real-time control computer, online is the field control, the need is to have a strong anti-interference ability, lower cost, which is also and offline computer (such as home PC) of the main difference.

The microcontroller is dependent on the program, and can be modified. Through different programs to achieve different functions, especially special unique features, which is other devices need to be very hard to do, and some are very difficult to spend a lot of effort to do. A not very complex function if the United States developed in the 1950s 74 series, or the 1960s CD4000 series of these pure hardware to deal with, the circuit must be a large PCB board! But if you use the series of microcontrollers that were successfully marketed in the 70's in the US, the results will be very different! Only because the microcontroller through your program can achieve high intelligence, high efficiency, and high reliability!

Because microcontrollers are cost-sensitive, the dominant software is still the lowest level of assembly language, which is in addition to the binary machine code above the lowest level of the language, since it is so low why use it? Many high-level language has reached the level of visual programming why not use it? The reason is very simple, is that the microcontroller does not have a home computer like the CPU, there is no hard disk like the mass storage device. A small program written in a visual high-level language, even if there is only one button, will reach the size of tens of K. For the hard disk of a home PC, it's nothing! This is nothing for the hard disk of a home PC, but it is unacceptable for a microcontroller. Microcontrollers have to be very efficient in the utilization of hardware resources, so assembly is used a lot, even though it is primitive. In the same way, if you take the operating system and application software from a giant computer and run it on a home PC, the home PC can't handle it.

It can be said that the twentieth century spanned three "electric" eras: the electrical era, the electronic era, and now the computer era. However, this computer, usually refers to a personal computer, or PC for short. It consists of a mainframe computer, a keyboard, a monitor, and so on. There is another type of computer that most people are not so familiar with. This type of computer is a microcontroller (also known as a microcontroller) that gives intelligence to various machines. As the name implies, the smallest system of this type of computer uses only a single integrated circuit for simple operations and control. Because of its small size, usually hidden in the controlled machinery "belly". It is in the whole device, plays a role as the role of the human mind, it went wrong, the whole device is paralyzed. Now, the use of this microcontroller has been a very wide range of areas, such as intelligent instrumentation, real-time industrial control, communications equipment, navigation systems, home appliances and so on. Once a variety of products with a microcontroller, you can play a role in upgrading the effectiveness of the product, often in the product name before the title of the adjective - "intelligent", such as intelligent washing machines and so on. Now some factory technicians or other amateur electronics developers to come up with certain products, either the circuit is too complex, or too simple and easy to imitate the function. The reason for this may be stuck in the product does not use a microcontroller or other programmable logic devices.

History of microcontrollers

Microcontrollers were born in the late 1970s, and have gone through three major phases: SCM, MCU, and SoC.

1. SCM that is, Single Chip Microcomputer (Single Chip Microcomputer) stage, mainly to seek the best monolithic form of the best embedded system architecture. The success of the "innovation model" has laid the foundation for the development of SCM and general-purpose computers completely different path. In the creation of embedded systems in the independent development of the road, Intel Corporation can not be credited.

2. MCU that is, microcontroller (Micro Controller Unit) stage, the main direction of technological development is: constantly expanding to meet the embedded applications, the object of the system requirements of a variety of peripheral circuits and interface circuits, highlighting the object of its intelligent control capabilities. It involves the fields related to the object system, therefore, the development of MCU's heavy responsibility inevitably falls on the electrical and electronic technology manufacturers. From this perspective, Intel's gradual fade out of MCU development also has its objective factors. In the development of MCU, the most famous manufacturers when the Philips Corporation.

Philips company with its great advantage in embedded applications, MCS-51 from a single microcomputer to microcontroller rapid development. Therefore, when we review the development path of embedded systems, do not forget the historical merits of Intel and Philips.

3. Microcontroller is the road to independent development of embedded systems, to the MCU stage of the development of important factors, is to seek the application of the system on a chip to maximize the solution; therefore, the development of dedicated microcontroller naturally formed the SoC trend. With the development of microelectronics technology, IC design, EDA tools, SoC-based microcontroller application system design will have greater development. Therefore, the understanding of microcontroller can be extended from single chip microcomputer, single chip microcontroller to single chip application system.

[edit]Application areas of microcontroller

At present, the microcontroller penetrates into all areas of our lives, it is almost difficult to find which field is not a trace of the microcontroller. Missile navigation devices, aircraft control of a variety of instruments, computer network communications and data transmission, industrial automation processes, real-time control and data processing, the widespread use of a variety of intelligent IC cards, civilian limousine safety systems, video recorders, camcorders, automatic washing machine control, as well as programmable toys, electronic pets and so on, all of these are inseparable from the microcontroller. Not to mention the automatic control field of robotics, intelligent meters, medical equipment. Therefore, the study, development and application of microcontroller will create a number of computer applications and intelligent control of scientists and engineers.

Microcontroller is widely used in the field of instrumentation, household appliances, medical equipment, aerospace, intelligent management of special equipment and process control, etc., which can be broadly divided into the following categories:

1. Widely used in instrumentation, combined with different types of sensors, can be realized such as voltage, power, frequency, humidity, temperature, flow, speed, thickness, angle, length, hardness, elements, pressure and other physical measurements. The use of microcontroller control makes instrumentation digital, intelligent, miniaturized and more powerful than with electronic or digital circuits. For example, precision measurement equipment (power meters, oscilloscopes, various analyzers).

2. Application in industrial control

With microcontroller can constitute a variety of control systems, data acquisition systems. For example, intelligent management of factory assembly lines, intelligent control of elevators, various alarm systems, and computer networking to form a secondary control system.

3. In the application of household appliances

It can be said that nowadays, basically all household appliances are controlled by microcontroller, from the rice cooker, washing machine, refrigerator, air-conditioning, color TV, other audio-video equipment, and then to the electronic weighing equipment, a variety of ubiquitous.

4. Application in the field of computer networks and communications

The modern microcontroller is generally equipped with a communication interface, can easily communicate with the computer data, for the application of computer networks and communications equipment provides excellent material conditions, now the communication equipment are basically realized in the intelligent control of the microcontroller from the cell phone, telephone, small program-controlled switches, building, automatic communication call system, train wireless communication system, and so on. Automatic communication call system, train wireless communication, and then to the daily work everywhere in the cell phone, trunking mobile communication, radio intercom and so on.

5. Application of microcontroller in the field of medical equipment

The use of microcontroller in medical equipment is also quite extensive, such as medical ventilators, various analyzers, monitors, ultrasound diagnostic equipment and bed call system and so on.

6. In a variety of large-scale appliances in the modular application

Some special microcontroller designed to achieve a specific function, so that in a variety of circuits in the modular application, without requiring users to understand the internal structure. Such as music integrated microcontroller, seemingly simple functions, microscopic in a purely electronic chip (as distinct from the principle of the tape machine), you need to be complex similar to the principle of the computer. Such as: music signals in the form of digital stored in memory (similar to ROM), read by the microcontroller, converted to analog music electrical signals (similar to the sound card).

In large circuits, this modular application greatly reduces the size, simplifies the circuit, reduces damage, error rate, and facilitates replacement.

In addition, microcontrollers have a very wide range of uses in industry and commerce, finance, scientific research, education, defense and aerospace fields.

[edit]Learning should be in the six important parts

Microcontroller learning should be in the six important parts

First, the bus: we know that a circuit is always connected by the components through the wire from the analog circuits, wires do not become a problem, because the devices are generally serial relationship between the devices are not a lot of wires, but computer Circuit is different, it is a microprocessor as the core, the devices are connected to the microprocessor, the work between the devices must be coordinated with each other, so the need for wiring is a lot of, if it is still the same as analog circuits, in the microprocessor and the devices individually wired, the number of wires will be amazingly high, so the microprocessor in the introduction of the concept of the bus, the various devices *** with the enjoyment of wires, all the devices of the eight data lines are all connected to a bus, and all the data lines are all connected to the bus. device's eight data lines all received eight common line, that is, the equivalent of each device is connected in parallel, but only this is not enough, if there are two devices at the same time to send out data, a 0, a 1, then, the receiver receives exactly what is it? This situation is not allowed, so it is necessary to control through the control line, so that the device time-sharing work, at any time there can only be a device to send data (there can be more than one device to receive at the same time). The data lines of the device are also known as the data bus, and all the control lines of the device are known as the control bus. In the microcontroller internal or external memory and other devices have storage units, these storage units to be assigned address, in order to use, assign the address is of course also given in the form of electrical signals, due to more storage units, so, for the address of the distribution of the line is also more, these lines are known as the address bus.

Second, data, address, instructions: the reason why these three together, because the essence of these three are the same - digital, or are a string of '0' and '1 ' sequence of '0's and '1's. In other words, addresses and instructions are also data. Instruction: a number specified by the designer of the microcontroller chip, which has a strict one-to-one correspondence with our commonly used instruction mnemonics and cannot be changed by the developer of the microcontroller. Address: is to find the microcontroller internal and external storage units, input and output ports based on the internal unit of the address value has been specified by the chip designer, can not be changed, the external unit can be decided by the developer of the microcontroller, but there are some of the address unit must be there (see the program execution process). Data: This is the object handled by the microprocessor, in a variety of different application circuits vary, in general, the data being processed may be so many kinds of cases:

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

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

3?Constant (e.g. MOV TH0, #10H) 10H is the timing constant.

4?The actual output value (such as P1 port connected to the colored lights, to light all bright, then the implementation of the instruction: MOV P1, #0FFH, to light all dark, then the implementation of the instruction: MOV P1, #00H) here 0FFH and 00H are the actual output value. Another example is the character code used for LEDs, which is also the actual output value.

Understanding the address, the nature of the instruction, it is not difficult to understand why the program will run in the process of flying, the data will be treated as instructions to execute.

Third, the P0 port, P2 port and P3 of the second function of the use: the beginning of the P0 port, P2 port and P3 port of the second function of the use of the port is often confused, that the second function and the original function of the second function and the original function of the process of switching between the process, or to have a directive, in fact, the second function of the ports are completely automatic, do not need to use the instruction to convert. Such as P3.6, P3.7 are WR, RD signals, when the microprocessor external RAM or have an external I/O port, they are used as the second function, can not be used as a general-purpose I/O port, as long as a microprocessor as soon as the execution of the MOVX instruction, there will be a corresponding signal from the P3.6 or P3.7 to send out, do not need to use the instruction in advance. The fact is that 'can't be used as a general-purpose I/O port' is not 'can't' but 'won't' be used as a general-purpose I/O port (by the user). It is perfectly possible to program a SETB P3.7 instruction into a command and have P3.7 go high when the microcontroller executes it, but the user would not do that because it would normally cause the system to crash.

Fourth, the program execution process: microcontroller in the power reset 8051 program counter (PC) in the value of '0000', so the program is always from the '0000' unit to start executing, that is to say: the system must be '0000' in the ROM. That is to say: in the system ROM must exist '0000' this unit, and in the '0000' unit must be stored in an instruction.

V. Stack: The stack is a region that is used to store data, the region itself does not have any special features, is a part of the internal RAM, special is the way it stores and accesses the data, that is, the so-called 'first in, last out, last in, first out,' and the stack has a special data transfer instructions, that is, 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', and so on. 'PUSH' and 'POP', there is a special unit dedicated to its service, i.e., the stack pointer SP, which is automatically added 1 (on top of the original value) whenever a PUSH instruction is executed, and is automatically added 1 (on top of the original value) whenever a POP instruction is executed, and is automatically added 1 (on top of the original value) whenever a POP instruction is executed. (Since the value of SP can be changed with an instruction, the stack can be set in a specified memory cell as long as the value of SP is changed at the beginning of the program, e.g., at the beginning of the program, the stack is set in the cell starting from memory cell 60H with a MOV SP, #5FH instruction. Generally the beginning of the program there is always such an instruction to set the stack pointer, because when the power on, the initial value of the SP is 07H, so that the stack from the 08H unit backward, and 08H to 1FH this area is the 8031's second, third, fourth working register area, often to be used, which will cause confusion in the data. Different authors write programs to initialize the stack instructions are not exactly the same, this is a matter of author's habits. When the stack area is set up, it does not mean that the area becomes a kind of specialized memory, it can still be used like ordinary memory areas, just generally programmers will not use it as ordinary memory.

Six, the development process of the microcontroller: The development process described here is not the general book from the beginning of the task analysis, we assume that the hardware has been designed and produced, the following is the work of writing software. Before writing software, the first to determine some constants, addresses, in fact, these constants, addresses in the design phase has been directly or indirectly determined. For example, when the connection of a device is designed, its address is also determined, when the function of the device is determined down, its control word is also determined. Then use a text editor (such as EDIT, CCED, etc.) to write the software, write a good, use the compiler to compile the source program file, check for errors, until there are no syntax errors, in addition to very simple programs, the general application of the software debugging emulator, until the program runs correctly. After running correctly, you can write the chip (solidify the program in EPROM). After the source program is compiled, a target file with the extension HEX is generated. Generally, the programmer is able to recognize the file in this format, and as long as the file is tuned in, the chip can be written. Here, in order to make you know the whole process, an example:

ORG 0000H

LJMP START

ORG 040H

START:

MOV SP, #5FH ;Set the stack

LOOP:

NOP

> LJMP LOOP ;Loop:

NOP

LJMP LOOP ;Loop:

NOP

LJMP LOOP ;Loop:

NOP

LJMP LOOP ; loop

END ; end

[edit]Microcontroller Learning

At present, many people do not recognize assembly language. It can be said that it is important to master the programming of microcontrollers in C language, which can greatly improve the efficiency of development. However, beginners can not understand the assembly language of the microcontroller, but must understand the specific performance and characteristics of the microcontroller, or in the field of microcontroller is more deadly. If you do not take into account the microcontroller hardware resources, in KEIL with C haphazard programming, the result can only be a problem can not be solved! It can be said with certainty that the best C language microcontroller engineers are from the assembly out of the programmer because the C language of the microcontroller although it is a high-level language, but it is different from the desktop personal computer VC + + + and what the hardware resources of the microcontroller is not very powerful, unlike us with VC, VB and other high-level language on the desktop PC to write a program on the desktop PC after all, desktop computers are very powerful hardware, so that you can not

This is the first time that a program has been written on a desktop PC.

The 8051 microcontroller as an example to explain the pins and related functions of the microcontroller;

"Microcontroller Pin Diagram"

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

⒈ power supply:

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

(2) VSS - ground terminal;

Note: Use a multimeter to test the microcontroller pin voltage is generally 0v or 5v, which is the standard TTL level. But sometimes in the microcontroller program is working when the test results are not this value but between 0v-5v, in fact, this is the multimeter's response speed is not so fast, in a moment the microcontroller pin voltage is still maintained at 0v or 5v.

⒉ Clock: XTAL1, XTAL2 - crystal oscillator inverted input and output.

?Control Lines:Control Lines*** There are 4 control lines,

(1) ALE/PROG: Address Latch Allowed/In-Chip EPROM Programming Pulse

① ALE Function: Used to latch the low 8-bit address sent by the P0 port

(2) PROG Function: Chips with on-chip EPROMs, during the EPROM programming period, this pin inputs a programming pulse.

⑵ PSEN: External ROM read select signal.

(3) RST/VPD: Reset/standby power.

① RST (Reset) function: reset signal input.

② VPD function: connect to backup power in case of Vcc power down.

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

① EA function: internal and external ROM select terminal.

② Vpp function: chip with on-chip EPROM, apply programming power Vpp during EPROM programming.

Singed I/O lines

The 80C51*** has four 8-bit parallel I/O ports: ports P0, P1, P2, and P3, and **** 32 pins.

P3 port also has a second function for special signal input and output and control signals (belonging to the control bus)

[Edit this paragraph]Commonly used microcontroller chip introduction

PIC microcontroller:

is a MICROCHIP company's products, which is characterized by a small size, low power consumption, streamlined instruction set, good anti-jamming, high reliability

EMC microcontroller:

Taiwan Yilong company's products, a large part of the PIC 8-bit microcontroller compatible, and compatible with the product's resources are relatively more than the PIC, cheaper, there are a lot of series to choose from, but the anti-jamming is poor.

ATMEL microcontroller (51 microcontroller):

ATMEl 8-bit microcontroller AT89, AT90 two series, AT89 series is an 8-bit Flash microcontroller, compatible with the 8051 series of microcontrollers, static clock mode; AT90 series of microcontrollers is to enhance the RISC structure, the full static mode of operation, the built-in online programmable Flash microcontroller. Programmable Flash microcontroller, also known as AVR microcontroller.

PHLIPIS 51PLC series microcontroller (51 microcontroller):

PHILIPS microcontroller is based on the 80C51 core microcontroller, embedded with power-down detection, analog, and on-chip RC oscillator functions, which allows the 51LPC to meet the multifaceted performance requirements in highly integrated, low-cost, low-power application designs.

HOLTEK microcontroller:

Taiwan Sheng Yang Semiconductor's microcontroller, cheaper, more varieties, but poor anti-interference, suitable for consumer products.

TI microcontroller (51 microcontroller):

Texas Instruments provides two series of general-purpose microcontroller TMS370 and MSP430. TMS370 series of microcontrollers is an 8-bit CMOS microcontroller, with a variety of storage modes, a variety of peripheral interface modes for complex real-time control occasions; MSP430 series of microcontrollers is an ultra-low-power, highly integrated 16-bit microcontroller with a high level of functionality. MSP430 series microcontroller is an ultra-low-power, high functionality integration of 16-bit low-power microcontroller, especially suitable for low-power occasions