Development of PLC Execution System Based on DSP/BIOS

Publisher:温馨的家庭Latest update time:2014-03-12 Source: 21ICKeywords:BIOS Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

   At present, the widely used programmable logic controllers (PLC) in the field of industrial control can be roughly divided into two categories: traditional PLC and soft PLC. Traditional PLC has some shortcomings, such as closed hardware architecture, and is mainly monopolized by several manufacturers. Soft PLC has great potential in openness and low cost. At present, many Western countries such as Europe and the United States have taken software PLC as a key object for research and development.
    Traditional PLC has hard real-time performance, which is why it can provide fast, deterministic and repeatable responses. On the other hand, since soft PLC is based on PC and built on a certain operating system, such as Windows NT, which is not a hard real-time operating system, the real-time problem of the PC-based control engine has become one of the main factors restricting the development of soft PLC. In view
    of the shortcomings of soft PLC in real-time performance, this project adopts a control solution based on embedded processors, and the soft PLC execution system is a task in the controller firmware. The C6000 series digital signal processor (Digital Signal Processor) launched by TI in the United States has high processing capabilities. In particular, a size-cuttable real-time multitasking operating system kernel DSP/BIOS designed and developed for its TMS320C6000TM, TMS320C5000TM and TMS320 C28xTM series DSP platforms provides preemptive multithreading, hardware abstraction, real-time analysis and configuration tools, and can realize real-time thread scheduling and synchronization, communication between the host and the target DSP, or real-time monitoring. DSP is serially controlled and has a fast computing speed. The PLC execution system based on the DSP/BIOS real-time kernel has quite good real-time performance and stability. The following focuses on its design and implementation methods.

1 Design planning of soft PLC
1.1 Analysis of the architecture of soft PLC
    
The PLC program controlled by the PLC execution system is divided into primary program and secondary program, and their execution cycles are inconsistent. The primary program is executed every 8 ms to process short pulse signals with fast response, such as external operation panel signals and alarm signals, and automatically gives the end mark END1 at the end of the program. The secondary program is a general PLC instruction, which is executed every 8n ms, where n is the number of divisions of the secondary program. When the secondary program starts to be executed, the PLC execution system module will automatically divide the secondary program into n blocks according to the time required to execute the program, and only execute one block every 8 ms, and automatically give the end mark END2 at the end of the secondary program.
1.2 Working principle of PLC execution system
    
PLC works in a cyclic scanning mode. First, the system is initialized, and then it enters the cyclic working process, including input sampling, PLC instruction execution and output refresh. Its basic process is shown in Figure 1.

a.JPG


    1) System initialization: Before executing the PLC program in a loop, the execution system must be initialized, including parameter input and variable initial value setting; 2) Input sampling: Each time the PLC program is executed, the external input status must be read into the buffer for subsequent program query; 3) Execution of user PLC program: Execution of the user program means that the CPU starts from the first address of the PLC program and executes the compiled PLC instructions one by one in sequence, and the process results are temporarily stored in the corresponding registers; 4) Output refresh: After executing the user program, the processed results need to be output externally. Since the objects controlled by the PLC are mostly slowly changing signals, and the time for each PLC input scan and logic operation is very short, this PLC execution system is set to refresh the output once every execution of a cycle.
1.3 Thread Scheduling of DSP/BIOS
    
The development of the PLC execution system in this article is carried out in the integrated development environment CCS (Code Composer Studio) provided by TI. CCS not only integrates conventional development tools, such as source code editors, code generation tools and debugging environments, but also provides DSP/BIOS development tools. DSP/BIOS is a streamlined real-time operating system kernel with real-time operating system functions. It provides preemptive multithreading and supports multiple priorities. Each thread has different execution and preemption characteristics, including hardware interrupt (HWI) including clock function (CLK), software interrupt (SWI) including periodic function (PRD), task thread (TSK), and background thread (IDL). The principle of thread type selection: HW1 is only used to handle critical tasks with strict time requirements; SWI is used to handle relatively independent functions. If the algorithm requirements are relatively complex, TSK is used. TSK provides many means of task communication and synchronization, and has its own independent stack, so it is more flexible than SWI. IDL is used to execute non-critical tasks that are not related to time.
    In DSP/BIOS thread scheduling, high-priority threads of hardware interrupts and software interrupts can suspend low-priority tasks in operation, while high-priority task threads must use specific APIs to preempt the currently running low-priority task threads, and only task threads can be suspended. Based on the fact that PLC execution is a cyclic execution process and has complex communication interactions with other motion threads, this execution system establishes it as a task thread and is scheduled by the DSP/BIOS real-time operating system. 2 Specific implementation of PLC execution system

2.1 Data structure definition
    
1) Definition of PLC instruction code data structure. PLC user program is stored in a certain binary format inside the system. The following instruction is used to open a memory area of ​​a bytes to store the compiled PLC instruction code. The size of the memory area a is set according to the actual situation.
    long*plc_pt;
    plc_pt=(long*)malloc(a);
    2) Definition of PLC execution instruction structure. PLC instruction code mainly includes instruction type and variable address. The following PLC execution instruction structure is defined:
    struct plc_code_type //PLC execution instruction structure
    {
    unsigned char code_type; //Instruction type
    unsigned short pt addr; //Variable address
    };
    Therefore, a pointer of type pk_code_type is defined during initialization to directly point to the PLC instruction code area. When parsing PLC instructions, the pointer can be directly moved to parse and output the instructions.
2.2 PLC instruction parsing
    
A key issue of PLC execution system is the parsing of PLC instructions. Using DSP's C language, a corresponding PLC instruction execution function library is established. PLC user program can be regarded as composed of multiple execution blocks, each of which includes conditional instructions and execution instructions. The following is divided into conditional instruction parsing and execution instruction parsing for description.
2.2.1 Conditional instruction parsing
    
First, define a variable to save the conditional instruction parsing result, so that the execution instruction can be processed according to the conditional instruction parsing result when parsing the execution instruction.
    For example, the normally open contact (LD) can be implemented with the following function:
    void plcLD(plc_code_type&pc)
    //pc represents the pointer position of the current instruction in the user program
    { if(1==pc->pt_addr) //the address obtained by the instruction is 1
    {
    plc_result&=0x01; //closed state is set
    }
    }
2.2.2 Execution instruction parsing The
    
execution instruction judges the component address according to the conditional instruction result of the current execution block and processes it accordingly. For example, the set instruction (SET) can be implemented by the following function:
    void plcSET(plc_code_type&pc)
    { if(plc_result&1)
    //Judge the condition instruction, closed, there is output
    {
    pc->pt_addr|=0xff; //Corresponding address is set
    }
    }
    In this way, the PLC execution blocks are parsed one by one, and the refresh of the input and output units is also implemented by using functions. Finally, the control quantity is sent out through the output port to realize the execution control of the user's PLC program.
2.3 PLC execution system operation process
    
First, create a task thread in the Scheduling project under the DSP/BIOS configuration tool, such as PLC_Deal_Task, and set the priority and other related contents of the task function. Then, the PLC instruction parsing process can be directly performed in the PLC_Deal_Task thread, and the PLC cyclic scanning function can be realized.
    The overall design idea is as follows: Set the execution cycle of the first-level program to execute once for m instruction counts, and m is related to the scanning cycle. After entering the second-level loop, first determine whether the instruction count is greater than m. If it is not m, enter the execution of the second-level program. If the condition is met, the loop is exited and one cycle is completed. The specific scheduling process is shown in Figure 2.

g.JPG

3 Test analysis and application
3.1 Test analysis of soft PLC execution system
    
According to the above design method, a PLC execution system is constructed, and the PLC program for actual application is designed and tested on the test machine to observe the logical action of the equipment and the performance of the execution system. CCS provides a series of visual tools to test the performance of the running system. The "CPU load chart" is used to analyze the CPU utilization rate, and the "task execution chart" can detect whether the system meets the real-time requirements. Now, according to the process of the micro-drill blade inspection machine, its PLC program is designed, downloaded to the soft PLC execution system for operation, and its operation performance is monitored by the CCS monitoring tool. Figure 3 is the CPU load chart, the load peak is about 25%, and the change is stable; Figure 4 is the task execution chart, the Assertions item at the bottom of the left column in the figure is used to indicate that a real-time requirement has not been met, or an invalid state has been detected. If there is no small square in the Assertions item, it means that the scheduling of the corresponding thread meets the real-time requirements. In addition, after debugging on the machine, the overall operation logic of the equipment also runs completely in accordance with the program requirements. This experiment shows that the soft PLC execution system based on DSP/BIOS can meet the requirements of real-time control and work stably.

h.JPG

i.JPG


3.2 Application of Soft PLC Execution System
    
One of the disadvantages of traditional PLC is that the hardware architecture is relatively closed and the cost is high. For example, the Japanese Mitsubishi PLC FX2N series controller does not integrate the motion axis control function. Each additional motion axis control requires an additional pulse generator unit (PGU). If it is applied to multi-axis equipment, it may be too costly and inflexible. The motion controller IPMC8188 developed by our research group can independently control 8 axes, and the soft PLC execution system runs as a task in the firmware of the controller. Compared with traditional PLC, the motion controller with stable and powerful PLC function can reduce the complexity of control system construction and improve control efficiency and development efficiency. Figure 5 shows the IMPC8188 motion controller with embedded soft PLC execution system. At present, this type of motion controller has been used and stably operated in automation equipment such as fully automatic blade inspection machine, automatic placement machine and fully automatic micro drill sharpening machine.

j.JPG



4 Conclusion
    
The soft PLC execution system based on embedded processor can effectively make up for the shortcomings of soft PLC in real-time and stability, and because of its own operating system, it has reliable data storage and self-recovery functions. The design of the PLC execution system based on DSP/BIOS discussed in this paper, combined with motion control, is widely used in small and medium-sized automation equipment, and also has great development potential in realizing comprehensive automatic control of large-scale systems.

Keywords:BIOS Reference address:Development of PLC Execution System Based on DSP/BIOS

Previous article:A fuzzy PID control of inverter power supply based on DSP
Next article:Automobile anti-collision high-speed data acquisition system based on DSP and FPGA

Latest Embedded 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号