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.
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
- Popular Resources
- Popular amplifiers
- 西门子S7-12001500 PLC SCL语言编程从入门到精通 (北岛李工)
- Siemens Motion Control Technology and Engineering Applications (Tongxue, edited by Wu Xiaojun)
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 6. System control scheme and algorithm design
- Considerations for selecting solid-state relays
- Design from 0_RC522 reader/writer based on STM32F1
- FPGA Advanced Timing Synthesis Tutorial
- 【TouchGFX Design】Use TouchGFX buttons and message responses
- Questions about ESD protection for the entire machine?
- [Sipeed LicheeRV 86 Panel Review] 6-Waft Graphical Interface Development Test (Part 1)
- [Bluesun AB32VG1 RISC-V development board] Evaluation environment construction
- Micropython Watchdog
- Why do we need dual register synchronization across clock domains?