Share this

Input method based on Siemens S7200 PLC external data BCD code

2026-04-06 03:31:40 · · #1

Abstract: In electrical control systems employing programmable control technology, control data can be set and input externally during system operation. This article introduces the programming ideas, techniques, and reference programs with simple examples, covering topics from external data BCD code dial address allocation to data processing and output control.

Keywords: Programmable Logic Controller ; External Input; BCD Digital Input; Data Processing; Real-Time Control

With the continuous improvement of industrial automation , Programmable Logic Controllers (PLCs) are entering every corner of industrial and mining enterprises. Wherever there is a control requirement, a PLC is used. PLCs are often called all-around "industrial computers," as they can easily perform real-time control of industrial sites. In industrial electrical control systems, the setting and modification of control constants are frequently encountered, such as the setting and changing of the heating time constant in a heating control system. There are two common methods for changing control constants in a PLC: first, modifying the control data in the original program through a host computer; second, using external devices to input data and control the system operation. That is, the external device sends data to the PLC for data processing, and then modifies the PLC's internal parameters to achieve real-time control of industrial equipment. The second data input method has advantages such as not modifying the original program, simple data input method, convenient operation, and the ability to achieve real-time control. It is suitable not only for computer designers but also for ordinary operators. PLCs have very wide applications in electrical control equipment, and many manufacturers' PLC products have external data input functions. Therefore, the programming and control method that utilizes PLC control technology to input external BCD code data and fully leverages the numerical calculation and processing capabilities of industrial control computers (PLCs) has significant practical application implications. Here, taking a heating system constructed with a SIEMENS PLC as an example, we will introduce in detail the method for inputting external data of the heating time constant and the user processing program.

1. Example of BCD code data external input application design

1.1 Design Concept

First, we introduce the physical memory structure of the SIEMENS S7-200 PLC. Generally, physical memory is measured in bytes, so the memory unit is a byte unit. When the operand length is a word or double word, the memory unit parameter given after the identifier is the lowest byte unit number within the word or double word. Figure 1(a) shows the relationship and representation of bytes, words, and double words. When using data widths of words or double words, it should be ensured that no overlapping memory byte allocations are generated. For example, word address encoding should use even-numbered addresses such as MW10, MW12, MW14, etc., or odd-numbered addresses such as MW11, MW13, MW15, etc. Since memory word MW10 occupies two bytes MB10 and MB11, while MW11 occupies two bytes MB11 and MB12, there is an overlapping byte address unit MB11. Therefore, odd and even numbers cannot be used interchangeably in word address encoding to avoid data read/write errors. Figure 1(b) shows the data storage structure, where the high-order bits of the data are represented by MSB and the low-order bits by LSB.

Figure 1(a) Memory cells labeled with byte units as the reference. Figure 1(b) Relationship between bytes, words, and double words in memory.

Secondly, taking the Siemens S7-200 PLC as an example, a heating control system is constructed. The heating time is input externally to the PLC using a three-digit decimal BCD code dial. The PLC input/output contact allocation is shown in the table below:

Appendix: PLC Input/Output Contact Address Allocation

The heating element of the heating system is controlled by the PLC output point Q0.0, the system start button is input by I1.4, and the reset button is input by I1.5.

Figure 2(a) Main program flow

Figure 2(b) Subroutine Flow

Here, two bytes of PLC input image registers IB0 and IB1 are selected as external data input terminals. Three BCD code dials are used to place external data into the two bytes of IB0 and IB1 respectively. Each BCD code dial requires four PLC input points. For example, the units digit BCD code 8421 terminal is connected to the PLC's I0.3, I0.2, I0.1, and I0.0 input contacts respectively. The lower 4 bits of the PLC input contact IB0 are assigned to the units digit of the BCD code, and the higher 4 bits are assigned to the tens digit of the BCD code. The lower 4 bits of IB1 are assigned to the hundreds digit of the BCD code, and the higher 4 bits are for invalid bits. The units, tens, and hundreds digits are sent to three internal flag registers (or internal variable registers) using transfer instructions. The tens and hundreds digits are then multiplied by weights of 10 and 100 respectively. Finally, the processed units, tens, and hundreds digits are added together. The result serves as the heating time constant for the heater. During user program initialization, the PLC sends this constant to the heating time timer for real-time control of the heater's heating time. The PLC reads BCD code dial data during each initialization run. By changing the data on the external dial, the heating time can be flexibly adjusted.

Finally, the basic idea of ​​the external data input processing process is introduced in the program flow diagram in Figure 2.

1.2 User Handling Procedure

The user program consists of a main program and an initialization subroutine. Based on the pulse signal given by the special flag bit SMO.1 during the first scan of the program, the initialization subroutine is called to realize the BCD code data input. In this way, the program will not be called in subsequent scan cycles, which reduces the scan time and makes the program more structured. User program description: (1) Program segment one realizes the subroutine call function; (2) Segment two and segment three realize the heater heating control function. The output relay Q0.0 is set by I1.4 and reset by timer T37 or I1.5. The timing constant of timer T37 is set by the internal flag register MW8; (3) Segment 5-9 are BCD code data input and processing subroutines. Segment six and seven send the units, tens, and hundreds digits to MW2, 6, and VW2 for storage, respectively. Segment eight realizes the function of multiplying the tens digit by 10 and the hundreds digit by 100, and sending the operation results to VD4 and VD8, respectively. The summation operation result of the units, tens, and hundreds digits is sent to MW8 as the heater heating time. (4) Segment nine is the subroutine return. The ladder diagram program for PLC S7-200 is shown in Figure 3.

Figure 3(a) Main Program

Figure 3(b) Subroutine

2 Key Design Techniques and Considerations

Design technique: Use a BCD code dial to set the heater's heating time value to a BCD code number, and use the PLC's data transmission instruction to read it into the input image register. After calculation, use it as the preset value for controlling the heating timer, thereby achieving real-time control.

Important Notes: First, you should be thoroughly familiar with the internal structure of the PLC's physical registers to correctly determine the relationship between the BCD code data input bits and the PLC input contacts, ensuring they correspond to the timer's time constant. Second, this reference program reads external data when the PLC transitions from STOP to RUN mode; therefore, BCD dial data can only be modified in STOP mode. If you need to change data during program execution, simply modify the subroutine call conditions slightly.

3. Conclusion

With the widespread application of PLC technology in modern industry, the use of external devices to input and modify control data is becoming increasingly common. Therefore, PLC application technologies and skills should be rapidly popularized to continuously improve industrial control technology, increase labor productivity, and enhance the living standards and overall national strength. The above discussion presents a simple and reliable method for inputting external data, which can serve as a reference for engineering and technical personnel specializing in PLC application technology research.

References

1. SIEMENS S7-200 User Guide. Beijing. 2002.

2 Zheng Sheng, Zhang Xue, et al., eds. *Principles and Applications of Modern Programmable Logic Controllers*. Beijing: Science Press, 1999.

3 Tian Ruiting. Programmable Logic Controller Application Technology. Beijing: Machinery Industry Press, 1994.

Read next

CATDOLL Himari Hybrid Silicone Head

The hybrid silicone head is crafted using a soft silicone base combined with a reinforced scalp section, allowing durab...

Articles 2026-02-22