Share this

Development of PLC Execution System Based on DSP/BIOS

2026-04-06 01:56:15 · · #1

Currently, programmable logic controllers (PLCs) widely used in the industrial control field can be roughly divided into two categories: traditional PLCs and software PLCs. Traditional PLCs have some inherent shortcomings, such as a closed hardware architecture, and are mainly monopolized by a few manufacturers. In contrast, software PLCs have great potential in terms of openness and low cost. Currently, many Western countries, such as Europe and the United States, have made software PLCs a key area of ​​research and development.

Traditional PLCs possess hard real-time capabilities, which is why they can provide fast, deterministic, and repeatable responses. On the other hand, since soft PLCs are based on PCs and run on a specific operating system, such as Windows NT, which is not a hard real-time operating system, the real-time performance issue of PC-based control engines has become one of the main factors restricting the development of soft PLCs.

To address the shortcomings of soft PLCs in terms of real-time performance, this project adopts an embedded processor-based control scheme, with the soft PLC execution system running as a task within the controller firmware. The C6000 series Digital Signal Processors (DSPs) from Texas Instruments (TI) possess high processing power. In particular, the DSP/BIOS, a customizable real-time multitasking operating system kernel designed and developed for its TMS320C6000TM, TMS320C5000TM, and TMS320C28xTM series DSP platforms, provides preemptive multithreading, hardware abstraction, real-time analysis, and configuration tools. It enables real-time thread scheduling and synchronization, communication between the host and target DSPs, and real-time monitoring. DSPs are serially controlled and have high processing speeds. The PLC execution system based on the DSP/BIOS real-time kernel exhibits excellent real-time performance and stability. The design and implementation methods are described below.

1. Design and planning of soft PLC

1.1 Architecture Analysis of Soft PLC

The PLC program controlled by the PLC execution system is divided into a primary program and a secondary program, with different execution cycles. The primary program executes every 8ms, handling fast-responding short pulse signals, such as external operation panel signals and alarm signals, and automatically displays an end marker END1 at the end of the program. The secondary program consists of general PLC instructions, executed every 8nm, where n is the number of divisions in the secondary program. When the secondary program begins execution, the PLC execution system module automatically divides the secondary program into n blocks according to the execution time required. Only one block is executed every 8ms, and an end marker END2 is automatically displayed at the end of the secondary program.

1.2 Working principle of PLC execution system

The PLC operates in a cyclic scanning mode. First, the system is initialized, and then the cyclic operation process includes several stages such as input sampling, PLC instruction execution and output refresh. Its basic process is shown in Figure 1.

1) System Initialization: Before executing the PLC program in a loop, the execution system must be initialized, including parameter input and initial variable values. 2) Input Sampling: Each time the PLC program is executed, the external input status is read into the buffer for later program lookup. 3) Executing the User PLC Program: Executing the user program involves the CPU sequentially executing the compiled PLC instructions, starting from the first address of the PLC program. The results are temporarily stored in the corresponding registers. 4) Output Refreshing: 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 input scan and logic operation is very short, this PLC execution system is configured to refresh the output after each loop execution.

1.3 DSP/BIOS Thread Scheduling

The development of the PLC execution system described in this article was carried out in the integrated development environment CCS (CodeComposer 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 functionality. It provides preemptive multithreading, supports various priorities, and each thread has different execution and preemption characteristics: Hardware Interrupts (HWI) including Clock Functions (CLK), Software Interrupts (SWI) including Periodic Functions (PRD), Task Threads (TSK), and Background Threads (IDL). The selection principle for thread types is as follows: HWI is used only to handle time-critical tasks; SWI is used to handle relatively independent functions, and TSK is used if the algorithm requirements are complex. TSK provides many means of task communication and synchronization and has its own independent stack, making it more flexible than SWI. IDL is used to execute time-independent non-critical tasks.

In DSP/BIOS thread scheduling, high-priority threads (hardware interrupts and software interrupts) can pause running low-priority tasks, while high-priority task threads must use specific APIs to preempt currently running low-priority task threads, and only task threads can be paused. Since PLC execution is a cyclical process with complex communication interactions with other motion threads, this execution system establishes it as a task thread, scheduled by the DSP/BIOS real-time operating system. 2. Specific Implementation of the PLC Execution System

2.1 Data Structure Definition

1) Definition of PLC instruction code data structure. The PLC user program is stored in a certain binary format inside the system. The following instruction is used to allocate 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. The PLC instruction code mainly contains the instruction type and variable addresses. The PLC execution instruction structure is defined as follows:

struct plc_code_type // PLC instruction execution structure

{

unsignedcharcode_type; // Instruction type

unsigned shortptaddr; // Variable address

:28px;background-color:rgb(255,255,255);">};

Therefore, during initialization, a pointer of type pk_code_type is defined to directly point to the PLC instruction code area. During PLC instruction parsing, this pointer can be moved directly to parse and output the instruction.

2.2 PLC Instruction Analysis

A key issue in PLC execution systems lies in the parsing of PLC instructions. This requires establishing a corresponding PLC instruction execution function library using the C language of the DSP. A PLC user program can be viewed as consisting of multiple execution blocks, each including conditional instructions and execution instructions. The following section describes the parsing of conditional instructions and execution instructions.

2.2.1 Conditional Instruction Parsing

First, define a variable to store the condition instruction parsing result, so that the execution instruction can be processed based on this condition instruction parsing result when parsing and executing the instruction.

For example, a normally open contact (LD) can be implemented using 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; // Set the closed state.

}

}

2.2.2 Execution Instruction Parsing

The execution instruction determines the appropriate processing of the component address based on the result of the conditional instruction in the current execution block. For example, the set instruction (SET) can be implemented using the following function:

void plcSET(plc_code_type&pc)

{if(plc_result&1)

// Conditional instruction, closed, outputs.

{

pc->pt_addr|=0xff; // Set the corresponding address

}

}

In this way, the PLC execution blocks are analyzed one by one, and the refresh of the input and output units is also implemented using functions. Finally, the control quantity is sent out through the output port to realize the execution control of the user PLC program.

2.3 PLC Execution System Operation Flow

First, create a task thread in the Scheduling project under the DSP/BIOS configuration tool, for example, named PLC_Deal_Task, and set the priority and other related settings for this task function. Then, PLC instruction parsing and processing can be performed directly in the PLC_Deal_Task thread, and the PLC's cyclic scanning function can be implemented.

The overall design concept is as follows: The execution cycle of the first-level program is set to execute once every m instructions, where m is related to the scan cycle. After entering the second-level loop, it is first determined whether the instruction count is greater than m. If it is less than m, the second-level program is executed. If the condition is met, the loop is exited, and one cycle is completed. The specific scheduling process is shown in Figure 2.

3. Test Analysis and Application

3.1 Test Analysis of Soft PLC Execution System

A PLC execution system was constructed based on the above design method. A practical PLC program was designed and tested on a test machine to observe the equipment's logic actions and the performance of the execution system. CCS provides a series of visualization tools to test the performance of the running system. The "CPU load graph" is used to analyze CPU utilization, and the "task execution graph" can detect whether the system meets real-time requirements. A PLC program was designed based on the process of the micro-drill face inspection machine, downloaded to this soft PLC execution system, and its operating performance was monitored using the CCS monitoring tool. Figure 3 shows the CPU load graph, with a peak load of around 25% and stable changes. Figure 4 shows the task execution graph. The Assertions item at the bottom of the left sidebar indicates that a real-time requirement has not been met or an invalid state has been detected. If no small square appears in the Assertions item, it means that the scheduling of the corresponding thread meets the real-time requirements. Furthermore, after debugging, the overall operating logic of the equipment runs completely according to the program requirements. This experiment shows that the DSP/BIOS-based soft PLC execution system can meet the requirements of real-time control and operates stably.

3.2 Application of Soft PLC Execution System

One drawback of traditional PLCs is their relatively closed hardware architecture and high cost. For example, the Mitsubishi FX2N series PLC controller does not integrate motion axis control functionality. Each additional motion axis requires an additional pulse generator unit (PGU), which can lead to excessive costs and insufficient flexibility in multi-axis applications. The motion controller IPMC8188 developed by our research group can independently control 8 axes, with the soft PLC execution system running as a task within the controller's firmware. Compared to traditional PLCs, motion controllers with stable and powerful PLC functions reduce the complexity of control system construction and improve control and development efficiency. Figure 5 shows the IPMC8188 motion controller with its embedded soft PLC execution system. Currently, this type of motion controller is being used and operating stably on automated equipment such as fully automatic edge inspection machines, automatic chip mounters, and fully automatic micro-drilling and grinding machines.

4. Conclusion

Embedded processor-based soft PLC execution systems can effectively compensate for the shortcomings of soft PLCs in terms of real-time performance and stability. Furthermore, due to their built-in operating system, they offer reliable data storage and self-recovery capabilities. The DSP/BIOS-based PLC execution system design discussed in this paper, combined with motion control, has wide applications in small and medium-sized automation equipment. It also shows great potential for development in realizing comprehensive automatic control of large-scale systems.

Read next

CATDOLL CATDOLL 115CM Shota Doll Kiki Male Doll

Height: 115cm Male Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: N/A ...

Articles 2026-02-22
CATDOLL 138CM Ya TPE

CATDOLL 138CM Ya TPE

Articles
2026-02-22
CATDOLL 139CM Lucy Silicone Doll

CATDOLL 139CM Lucy Silicone Doll

Articles
2026-02-22
CATDOLL Kara TPE Head

CATDOLL Kara TPE Head

Articles
2026-02-22