Abstract: This paper presents the concept of embedded PLC by analyzing the classic controller, focusing on the basic analysis of the core structure of the embedded PLC software of EASYV1.00 to guide the industrial control designers to establish a new embedded system design concept.


Keywords: Embedded PLC core CAN bus Abstract: By the analysis of the classical controller, the conception of embedded PLC is proposed. The emphases is to lead the designers of the controlling engineering to build a new notion of the design of embedded system by The basic analysis of the kernel configuration of the EASYV1.00 embedded PLC software.
Key word:Embeded PLC Kernel CAN bus
[CLC number] TP23 [Document code] A Article ID 1606-5123(2005)11-00


1 Introduction: Embedded PLC concept Embedded PLC refers to the realization and interpretation of a programmable logic controller (LTL) ladder programming language in a specific control device, which enables a specific device to have a basic PLC function on the basis of its own dedicated function.

Ladder diagram is a graphical PLC programming language for factory automation engineers. The ladder diagram has many advantages such as being concise, intuitive, and facing the process flow. The appearance of the PLC programming language separates the hardware and control-oriented processes in the control unit. PLC manufacturers focus on hardware and hardware management. Factory automation personnel use the ladder language for secondary development, making the same PLC suitable for different control systems. In addition, a programmable logic controller (PLC) is a platform-level product.

However, the design of control products has evolved to a stage where individualized and differentiated designs are pursued. Markets that cannot be accessed by conventional PLCs usually face more pressures for personalization and differentiation. Such as cost control, special functions, etc. There are control products such as Industrial Control Computers (IPCs), single-chip microcomputers, embedded boards, etc. that are more closely related to individual needs. IPC has obvious advantages in terms of interconnection, expression, and algorithms, and the SCM system is more flexible in cost control. IPC is often used for monitoring because it is loaded with an operating system (such as NT) and its real-time performance and stability are difficult to meet the stringent requirements of continuous control. The lower level is usually PLC. The SCM system mixes hardware management and user process control, which restricts its standardization and ultimately loses cost competitive advantage.

Embedded PLC is developed for IPC and SCM systems. It retains the advantages of PLC (by virtue of Ladder Diagram Language) hardware management and process control separation, combined with more personalized and differentiated design methods provided by IPC and MCU, forming a New controller design concept. When we embed the functions of the PLC in the IPC, we call it an embedded PLC based on the PC Base. When we embed the PLC function in the microcontroller, we call it the embedded PLC based on the All ON One (chip-level embedded PLC ). Unspecified, embedded PLC finger-level embedded PLC, which is the embedded PLC proposed in this article. The following describes an embedded PLC software architecture using Kewei's EASYV version 1.00 with 8-bit microcontroller C8051F040 as hardware.

At present, there are two kinds of special PLCs: soft PLC and custom PLC. Soft PLC refers to high-end embedded PLC software with a universal real-time operating system, and custom PLC refers to PLC designed in accordance with user's requirements. The related technologies have made breakthroughs in Germany, Taiwan, and South Korea, which belong to the category of embedded PLCs.


2 embedded PLC software architecture 2.1 overall structure EASY V1.00 embedded PLC is a very real-time operating system software, the overall structure includes three levels, as shown in Figure 1.
(1) Embedded PLC kernel It completes real-time task scheduling, basic functions such as ladder language interpretation, execution, and communication, and provides a secondary development driver interface;
(2) The secondary development program uses the kernel to provide external plug-in tasks and uses the kernel to develop various driver programs for individualized object-specific differentiation.
(3) The terminal application refers to ladder diagram language programming oriented to process flow control;

Figure 1 Overall structure of EASY V1.00


For secondary developers to develop driver programs for personalized objects, we must understand the embedded PLC kernel structure, especially the driver interface design method, the following block introduces the function of each block of the kernel.

2.2 Real-time OS
For small microcontrollers, the general real-time operating system can not be loaded, OS/II takes up too much resources, EASY V1.00 kernel has a dedicated real-time OS according to the task category, real-time requirements, it has no file system and memory management Two parts.

(1) Preemptive concurrent task management in the hard real-time state The EASY V1.00 kernel provides a 2.5 ms reference time base, which is used as an inalienable task cycle to perform monitoring and management for various tasks.
For asynchronous events in industrial applications, concurrent task management is used to suspend and execute tasks through various types of interrupts. Before each type of asynchronous task is executed, it is registered in the 2.5ms task, and is logged out after execution. The concurrent monitoring is performed through the 2.5ms timebase. The task flow and blocking status are reported to the upper level task scheduling.

(2) EASY V1.00 Asynchronous Tasks • Byte Stream in Communication Data Link Layer • Timers in Ladder Language • Real-Time Asynchronous Tasks in Secondary Development Drivers Concurrent Task Management is the lowest level in EASY V1.00 The task management achieves the real-time effect of ms, and the peak value when occupying the CPU in unit time (1ms) is:
T and =
Ni - the maximum number of executions of tasks within 1ms, ti - the maximum time for execution of tasks.
The real-time data of EASY V1.00 concurrent tasks is shown in Table 1 and Table 2.

Table 1 EASY V1.00 concurrent task real-time data Task category Non-removable task Communication byte stream task Ladder timer Drive concurrent task 2.5ms time base Serial port 0 Serial port 1 CAN
Number of executions (N1) 1 1 1 1 1 ND
Execution time (T) 10μs + ΔT 25μs 25μs 50μs 40μs tD


Table 2 EASY V1.00 Concurrent Task Real-Time Data Task Type Ladder Diagram Communication Function Call User Soft Interrupt Task Number 1 3 1 m4
Mission Time 1-20μs 1-10μs 1-5μs t4
T piece = 3-45μs + t4
T4 is the user software interrupt task occupancy time and.
"Scan cycle" refers to the time taken to interpret, execute all ladder diagram instructions and perform scan end processing. Since there are concurrent tasks during this period, the "scan cycle" should include the concurrent task occupancy time.
Concurrent task occupation ratio:
X=T and / 1ms = (150μs+ΔT+)/1000μs =15%-100%
Let user ladder include M instructions T sweep = (M • T piece + ΔTend) / X
ΔTend is the time taken for the end of scan processing.
2.3 Memory Management The operating data space of the ESAYV1.00 includes 64K external RAM + 256 bytes of CPU RAM, which is divided into three parts: the system occupied area, the PLC resource area, and the user embedded data area.
(1) System-occupied area The system-occupied area is a domain area that is not opened to PLCs and users for data caching, status maintenance, and system stack when the EASYV1.00 is running. The monitoring of the initial running of this part of the data area is managed by the real-time OS. PLC and user embedded programs must not be hacked.
(2) PLC resource area The data area managed by the ladder diagram language includes two parts, the bit area and the word area. Usually reflected in the form of components.
·Input relay X: X0-X177 128-point type output relay Y: Y0-Y177 128-position type · Intermediate relay M: M0-M1535 1536 Point type · Special intermediate relay M8000-M8255 256-position type · State relay S: S0-S999 1000-point type time relay T: T0-T255 256-bit type + font · Counter C: C0-C255 256-bit type + font · General-purpose data register D: D0-D7999 8000 words Type-dedicated data registers D: D8000-D8255 256 bytes All PLC resources are the areas for data access during ladder operation. They are the terminal application layer visualization areas. The user-embedded drivers can use the absolute addresses of the corresponding components. Access, data exchange between the embedded program and the PLC ladder diagram.
(3) User-embedded data area When the user designs various embedded systems with EASYV1.00 kernel, it is necessary to make necessary drivers for specific hardware. The private data of this part of the program is stored in the user-embedded data area, and public data is stored in the PLC. In the resource area, the user's embedded data area is allocated as follows:
Internal CPU: Bit Area: 20H-23H 4bytes
Byte area (DRAM): 58H-67H 16bytes
External data accessor: byte area (XRAM): 3600H-3FFFH 2560bytes
2.4 Ladder Language The EASYV1.00 ladder language is an interpreted language. Each ladder statement corresponds to a fixed function call. Scans are performed step by step until END is a scan cycle. EASYV1.00 supports 86 ladder instructions.
(1) Basic instructions (27)
Mnemonic Name Mnemonic Name LD Read Normal Open Point LDF Read Falling Edge LDI Read Normal Close Point ANDP Consecutive rising edge AND String Normal Open Point ANDF Series Falling Edge ANDI String Normally Closed Point ORP Parallel Connection Rising edge OR Incorporation of a normally open point ORF Concatenation of a falling edge ORI Incorporation of a normally closed point INV Operational contact Inversion ANB Circuit block Inline MPS Operational contact push ORB circuit block parallel MRD Read push contact OUT Coil output MPP Pop-up Push Contact SET Coil Output Hold MC Master RST Clear Coil Output MCR Master End PLS Rising Edge Output Pulse NOP Null Operation PLF Falling Edge Output Pulse END Program End LDP Read Rising Edge

(2) Stepping command (2)
Mnemonic Name Mnemonic Name STL Step Ladder Start RET End of Step Ladder Note: Step state transition can only be set with SET, and when using OUT as normal relay.

(3) Function instructions (56 items)
Mnemonic Name Mnemonic Name Program Flow CJ Conditional Jump Floating-Point Arithmetic ECMP Binary Float Comparison CALL Subroutine Call EZCP Binary Float Area Comparison SRET Subroutine Return EBCD Binary Float to Decimal FEND FEND Main program ends EBIN Decimal float to binary float FOR Loop range start EADD Binary float Addition NEXT Loop range end ESUB Binary float Subtraction Transmission and comparison CMP Comparison EMUL 2 float Point Multiplication ZCP Region Comparison EDIV Binary Division Floating Point Division MOV Transfer ESQR Binary Floating Point Square Algebra CML Inverted Transport INT 2 Binary Floating Point BIN Integer BCD BCD Conversion FLT BIN Integer to Binary Floating Point BIN BIN Conversion Contact operation LD= read "equivalent to compare node"
Four logical operations ADD BIN addition LD> Read "greater than comparison node"
SUB BIN subtraction LD< read "less than compare node"
MUL BIN multiplication LD<> read "not equal to comparison node"
DIV BIN division LD ≦ read "is less than equal to compare node"
INC BIN plus 1 LD≧ Read "greater than or equal to compare node"
DEC BIN minus 1 AND= series "equal to comparison node"
WAND logic word AND AND> in series "greater than comparison node"
WOR logical word or AND< concatenated less than comparison node
WXOR logical word XOR AND <> concatenation "is not equal to comparison node"
NEG Complementary Code AND ≦ Concatenation "Less than or equal to comparison node"
SQR BIN square root AND≧ Concatenation "greater than or equal to comparison node"
Cycle and shift ROR rotate right OR= parallel "is equal to compare node"
ROL loop left OR> parallel "greater than compare node"
RCR with Carry Rotate Shift Right OR< Parallel ” Less Than Compare Node”
RCL with Carry Loop Left OR<> Parallel "Not Equal to Compare Node"
OR≦ parallel "is less than equal to compare node"
OR≧ parallel "greater than or equal to comparison node"

(4) Expert instruction (1 item)
Mnemonic Name PID Expert Algorithm

2.5 EASYV1.00 Communication EASYV1.00 kernel includes serial port 0, serial port 1 and CANbus three communication interfaces. Each interface is customized with corresponding communication protocol, which is suitable for different applications.
(1) Serial port 0
l User embedded program download In the programming state, the user embed program is downloaded via serial port 0.
Embedded program download software for Kewei company software Downhex.
l Ladder Download In the setup state, download the ladder program via serial port 0.
The download tool software is Kewei company software EasyWin or Mitsubishi software FXGP_WIN-C.
l Ladder program monitoring In the running state, connect the man-machine interface (such as HITECH, EVIEW, DELTA, Mitsubishi, etc.) and the computer through the serial port 0, and monitor the ladder program and control parameters.
(2) Serial port 1
l Download CAN network configuration content In the SET state, download the CAN network configuration content.
Edit download CAN network configuration software for Kewei company software CANSET.
l RS485 network connection port In the RUN state, it is used as the data exchange interface of the RS485 master-slave network.
The interface network communication protocol is automatically loaded by the kernel, and the child nodes following the protocol can be automatically connected to the network. For example, the expansion controller of the motion controller is connected.
(3) CANbus communication EASYV1.00 kernel contains CANbus fieldbus communication protocol. Based on CAN2.0B, a high-level protocol of a dedicated master-slave structure is loaded, and the PLC resources occupied by CANbus are managed by means of a ladder diagram language (CANbus). The file register can implement CANbus interconnection.
2.6 function call EASYV1.00 system provides embedded driver function call, for the embedded program design system provides the EASYCORE.LIB function library, when the user embeds, as long as the included file (include EASYCORE.LIB) can call the system provides various types Application functions such as integers, floating-point operations, data transformations, and other functions.
2.7 User Interrupt System When EASYV1.00 is running on C8051F040CPU, it provides users with 13 kinds of interrupts, such as event interrupt, SPI, IIC, A/D, D/A, comparison, and capture.
System interrupt entry address is redirected to the area starting with E000H ADR=ADR0+E000H
ADR0---F040 interrupt entry address 3 Conclusion Embedded PLC proposes a new embedded system design concept with the core of process control language (ladder language). It can be used as a development platform for PLC products, and it can also be used as a design of a conventional single-chip microcomputer system. The controller design based on the embedded PLC method has improved the development speed and is more suitable for personalized and differentiated design requirements that are close to the customer's needs. In the face of an increasingly fragmented and complete system of industrial control markets, embedded PLCs have broad application prospects in the cross markets of DCS, IPC, PLC, and single chip microcomputers.

References [1] Min Kuanming. CAN bus principle and application system design. Beijing: Beijing University of Aeronautics and Astronautics Press, 1996
[2] Pan Yujin, Shi Guojun. Principles and Applications of C8051Fxxx High Speed ​​SOC Microcontroller. Beijing: Beijing University of Aeronautics and Astronautics Press, 2002
[3] C8051F040 Datasheet.SILICON LABORATORIES.2003
[4] Mitsubishi FX Series Programming Manual. Mitsubishi Electric [5] Embedded PLC Principles and Applications. Huangshi Kewei Automation Co., Ltd., 2004