Tips you should know: The difference between MCU and PLC programming

Publisher:美好回忆Latest update time:2014-01-16 Source: 电源网Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

There is a big difference between the programming of single-chip microcomputer and PLC. All programs of single-chip microcomputer are designed by users, while the programs of PLC include system programs (called operating system by Siemens) and user programs. The operating system is used to organize all CPU functions that are not related to specific control tasks. The tasks of the operating system include processing the startup process, refreshing the input/output process image, calling user programs, detecting interrupt events and calling interrupt organization blocks, detecting and handling errors, managing memory, and handling communication tasks. Many functions of PLC , such as scanning working mode, timer function and interrupt processing, are completed by the operating system. This issue should be considered when drawing a flow chart.

The program of the PLC switch control system is more concise to describe with a sequential function diagram. In principle, it is also possible to describe the PLC user program with a flow chart, but it should be distinguished which functions are completed by the operating system and which are implemented by the user program.

For example, someone asked if it is necessary to use a jump instruction to wait for the rising edge of a certain signal. This is a kind of thinking in single-chip computer programming. The scanning working mode of PLC reads all the switch inputs at the beginning of each scanning cycle, and judges whether there is a rising edge according to the change of the state of the same input point in the previous and next two scanning cycles. Therefore, there is no need to use a jump instruction to jump back to wait for the appearance of a certain input signal. If this method is used to query the state change of the signal, the PLC cannot do anything else because all its energy is used for querying! And this query is performed within a scanning cycle, which will make the scanning cycle very long, and it is easy to cause the error of the monitoring timer (watchdog) timeout.

In the PLC user program, only one rising edge detection instruction is needed to capture the rising edge of the pulse signal. If a quick response is required, an interrupt method can be used, and the system program calls the interrupt program written by the user on the rising edge of the pulse signal.

Keywords:MCU Reference address:Tips you should know: The difference between MCU and PLC programming

Previous article:Several data storage methods make the compact and flexible microcontroller have unlimited uses
Next article:0P7200 embedded multi-function controller: a complete analysis from principle to application

Latest Power Management Articles
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号