Micro Programmable Controller Based on AT89C51 Single Chip Microcomputer

Publisher:TechGuru123Latest update time:2011-05-17 Keywords:AT89C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Programmable Controller PC (Programmable Controller), to distinguish it from Personal Computer PC (Personal Computer), can be referred to as PLC. It is based on mature and effective relay control concepts and design ideas, using advanced single-chip microcomputer technology to achieve real-time detection and control of I/O. It has high reliability, simple programming and is easy to learn. Therefore, it is widely used.

Introducing PLC technology into electrical engineering and electric traction courses is an important measure to modernize the curriculum. Under the condition of relatively tight teaching funds, we did it ourselves, using AT89C51 single-chip microcomputer as the core, designed and developed LD type micro PLC, applied it to relay control experiments, and achieved good results.

The PLC composed of a single chip is actually a single chip measurement and control system. Using such a program-controlled computer system to execute the relay-controlled ladder program, since the controlled electrical appliances in the relay-controlled ladder diagram are in parallel, while in the computer program control, the controlled electrical appliances are in serial relationship in time, the two are obviously not coordinated. If it is simply like a general single chip measurement and control system, the input terminal status is collected in real time for each program line of the ladder diagram, and the real-time output is processed, it will not achieve the control purpose. For this reason, it is necessary to collect all input terminal status at one time and store it in the input buffer. Then, according to the logical relationship of the ladder program line, read the corresponding input terminal status from the input buffer, and store the result to be output in the output buffer after processing. Finally, after all the ladder program lines are executed, the value of the output buffer is output to the corresponding output terminal at one time, thus completing a program execution cycle. In this way, the next round of input terminal status collection is automatically carried out... This working mode is called scanning mode, which coordinates the relationship between serial program work and electrical parallel work. In addition, the time for a single-chip microcomputer to execute an instruction is in the μs level, and the time for executing a scan cycle is several ms or even tens of ms. Compared with the action time of the electrical appliance, the scan cycle is short. It can be considered that the state of the input terminal is unchanged within a scan cycle, and the collection and processing of its state changes are also real-time, thus meeting the requirements of real-time control.


The system hardware configuration is based on the AT89C51 (hereinafter referred to as 51) microcontroller as the core, as shown in Figure 1. The microcontroller has 4 KB flash memory, and there is no need to expand the program memory. Its 4 I/O ports have a total of 32 I/O pins, which are all available to users. Among them, P0.7~0.0, P2.4~2.0, a total of 13 pins, are connected to the corresponding input terminals X07~X00, X14~X10 after being isolated by optical couplers. Input can be made using travel switches, liquid level switches, Hall switches, and manual buttons. When the switch is turned on, the corresponding pin is "0", which is inverted and stored in the input buffer.

There are 8 pins from P1.7 to 1.0 for output control: when P1.i is "0", the corresponding PNP tube is turned on, the relay Ji coil is energized, and its contact Y5i is connected, which can drive a 220 V/3 A load. [page]

In order to communicate with the PC, the system has expanded the RS-232C interface circuit. The RXD and TXD signals of the 51 single-chip microcomputer are connected to the 9-pin socket after RS-232C level conversion. In this way, serial communication with the PC can be carried out. On the one hand, in the programming state, the OBJ instruction code of the ladder diagram assembler program compiled on the PC can be received and stored in the program memory; on the other hand, in the running state, the state of the I/O port and the processing results can be sent to the host computer in real time.

The program memory uses the X25045 chip with SPI interface. This is an E2PROM with programmable watchdog and power monitoring functions. It has 512 bytes, each byte can be erased and written 100,000 times, and the data can be stored for 100 years. It automatically provides a 200 ms high-level reset pulse when powered on; there are three programmable watchdog cycles; when the power supply is undervoltage and VCC drops to the turning point, it automatically provides a reset pulse. E2PROM uses a three-wire bus serial peripheral interface SPI, which not only saves I/O port lines and circuit board space, but also reduces system costs. Therefore, this chip is an extremely cost-effective combination chip.

The software design is divided into two parts: PC ladder diagram assembler software and 51 single-chip microcomputer software. The former is written in IBM-PC assembly language, which we call PLC compiler software. In this machine, we designed a set of TD-type PLC ladder diagram assembly language instruction system, including 16 basic instructions such as LD/LDI, AN/ANI, OR/ORI, TM/TMI, CN/CNI, MA/MAI, OUT, JP/JE and END, and devices such as X00~07, X10~14, Y00~07, CN0~1, TM00~07, MA00~07, 10~17. Use them to describe the relay ladder diagram, that is, design the ladder diagram assembler. Use full-screen editing software to input it into the PC, that is, establish the source program file. Then use PLC compiler software to compile it into a PLC target program file (OBJ file), and send it to the single-chip microcomputer through the serial communication port, and the single-chip microcomputer will write it into the E2PROM.

51 MCU software consists of programming software and running software. The programming software mainly has two modules: serial communication and writing E2PROM. At this time, the manual switch on the panel must be set to P2.7="0", and the MCU is in programming state. When P2.7="1", the MCU is in running state. The programs in running state mainly include:

(1) Input terminal acquisition module


The module collects the status of port P0 and port P1 twice. If the results are valid at the same time, they are stored in the input buffer, otherwise they are collected again. The software filtering method is used to improve the anti-interference ability.

(2) Instruction Analysis Module

The module starts from address 000H and reads the byte contents in E2PROM in sequence. It first reads the opcode, analyzes it and turns to the corresponding processing program; then reads the operand for the processing program to operate, thus completing the execution of a ladder diagram assembly instruction. Then read the opcode of the next instruction... When encountering the OUT instruction, the data to be output is stored in the corresponding output buffer.

(3) Output module

When the CPU reads the binary code of the END instruction from the E2PROM, it indicates that a scan cycle has ended, and the contents of the output buffer are output to the P1 port at one time, thereby completing the refresh of the output terminal.

The application of this PLC can be illustrated with the example of water tower water level control.



Figure 2(a) is the hardware wiring diagram, SB1/SB2 is the start/stop button; SAC is the pool level switch: it is connected when water is immersed and disconnected when there is no water; SAH and SAL are the high and low level switches of the water tower respectively; M is the water pump motor.

Figure 2(b) is the relay ladder diagram, and Figure 2(c) is the relay assembly program, i.e., the TD-type PLC source program. Among them, y50 is the PLC output terminal, and we use its software contact y50 as a sign of water level rise or fall: y50 = "0", indicating that the motor has stopped and the water level has dropped. At this time, although SAL is connected, the motor does not move; y50 = "1", indicating that the motor is pumping water and the water level is rising. At this time, SAL is connected, the motor is powered on, and continues to pump water until the high water level.

Keywords:AT89C51 Reference address:Micro Programmable Controller Based on AT89C51 Single Chip Microcomputer

Previous article:Design of a Lumbar Traction Apparatus Based on AT89C51
Next article:Design of variable frequency speed control system based on AT89C51 single chip microcomputer

Recommended ReadingLatest update time:2024-11-17 00:05

Design of RF card based on MCU AT89C51CC01 and FM1712 chip
Radio frequency card (contactless IC card) is a new technology developed in recent years. Compared with traditional contact IC card and magnetic card, the contactless IC card developed by radio frequency identification technology has successfully solved the problems of passive and contactless, which is a major break
[Microcontroller]
Design of RF card based on MCU AT89C51CC01 and FM1712 chip
Design of LED Chinese character scrolling display with AT89C51 microcontroller as the core
introduction LED display screen is a flat display screen composed of light-emitting diode dot matrix modules or pixel units. It has the advantages of high luminous rate, long service life, flexible configuration, rich colors and strong adaptability to indoor and outdoor environments. And it is widely used for informat
[Microcontroller]
Design of LED Chinese character scrolling display with AT89C51 microcontroller as the core
Design of a simple intelligent robot based on AT89C51 single chip microcomputer
Introduction: With the continuous development of microelectronics technology, the integration of microprocessor chips is getting higher and higher. Single-chip microcomputers can integrate CPU, memory, timer/counter, parallel and serial interface, watchdog, preamplifier, A/D converter, D/A converter and other circuits
[Microcontroller]
Design of a simple intelligent robot based on AT89C51 single chip microcomputer
Temperature automatic monitoring system based on AT89C51 single chip microcomputer
introduction     Chemical synthesis has high requirements for temperature detection and control, which is a key link in the chemical synthesis process. The temperature of the chemical synthesis device is detected, and the maximum heating temperature is controlled according to the process requirements; in the heating s
[Microcontroller]
Temperature automatic monitoring system based on AT89C51 single chip microcomputer
0.01℃ digital thermometer based on AT89C51 controlling ICL7135
    Temperature measurement is particularly important in the fields of physics experiments, medical care, food production, etc., especially in thermal experiments (such as teaching experiments on specific heat capacity, heat of vaporization, heat-work equivalent, pressure-temperature coefficient, etc.). Thermometers c
[Microcontroller]
0.01℃ digital thermometer based on AT89C51 controlling ICL7135
Temperature and humidity automatic detection system composed of AT89C51/55
0Introduction With the development of modern industry and the progress of society, people have higher and higher requirements for the continuity of power supply, such as requiring the power supply to adopt two or more than two channels, one for the common power supply (such as the external power s
[Microcontroller]
Temperature and humidity automatic detection system composed of AT89C51/55
Current source design based on AT89C51
introduction Constant current source is an important part of analog circuits, which can be used as bias, control or drive circuits. The traditional current mirror circuit changes the characteristics of the constant current source by adjusting the size of the bias resistor. Simply changing the size of the variable resi
[Microcontroller]
Current source design based on AT89C51
Temperature measurement method using AT89C51 and DS18B20
  Temperature measurement and control are widely used in the use of lasers, fiber gratings, and other industrial and agricultural production and scientific research. The traditional method of temperature detection is to use analog temperature sensors such as thermocouples, thermal resistors, and semiconductor PN junct
[Microcontroller]
Temperature measurement method using AT89C51 and DS18B20
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号