The data display function of PLCs has always been a challenge for PLC users. In PLC applications, it's often necessary to monitor important data, but PLC data display usually relies on external display devices, such as monitors or touchscreens. These devices are generally expensive, and even more wasteful for smaller systems. Therefore, how to display PLC data efficiently, stably, with strong anti-interference capabilities, and with minimal hardware investment is a crucial design consideration. The Siemens S7-200 PLC I use has dedicated instructions for controlling LED digital tube displays. The SEGIN, OUT instruction automatically converts the lower 4 bits of the hexadecimal number determined by the IN input byte into the corresponding codes for each segment of the 7-segment LED digital tube and sends them to the OUT output byte for display. If a static LED digital display is used, 7 output points are needed to control the display of one decimal digit; to display n digits, 7n output points are required. Therefore, this method requires a large number of output points when displaying a large number of data bits. Since the price of a PLC is calculated based on the number of input/output points, this directly leads to increased hardware costs. For this reason, finding a low-cost display technology is particularly necessary. This paper proposes to borrow the dynamic scanning display principle of LED digital tubes from a microcontroller, combining it with the periodic scanning characteristics of a PLC. The method uses the PLC to directly output digital signals to drive the digital tubes, dividing the PLC's switching output into two parts: one part for data output and the other for outputting the common terminal signal of the digital tubes. Utilizing the persistence of vision, each digital tube is illuminated cyclically. This method is simple to operate and low in cost.
1 Design Implementation
Dynamic scanning utilizes the periodic scanning characteristic of PLCs. During programming, it is necessary to ensure that only one digital tube can form a power-on circuit in each cycle, thereby receiving power and lighting up. Because the time of a scanning cycle is too short, only tens of milliseconds, the human eye perceives that each digital tube is evenly powered and lit up, without any trailing phenomenon.
1.1 Hardware Design
The hardware circuit implementation of the design method consists of a start button SB1 and a stop button SB2. The a, b, c, d, e, f, and g segments of the two digital tubes are connected together and then connected to the output terminals Q0.0 to Q0.7 of the PLC through current-limiting resistors. The common terminals com1 and com2 of the two digital tubes are controlled by the output terminals Q1.0 and Q1.1 of the PLC through transistors, respectively. The wiring principle is shown in Figure 1.
Figure 1. PLC drive circuit for dual-segment scanning display.
The high and low levels of PLC outputs Q1.0 and Q1.1 control the transistors in switching mode, causing the COM1 and COM2 terminals of the digital tubes to cyclically conduct with the PLC's common terminal M, selecting different digital tubes in a time-division multiplexing manner. The corresponding data is output from PLC outputs Q0.0 to Q0.7, and then the corresponding digital tubes (a, b, c, d, e, f, g) are displayed according to the signal from the common terminal. Through software programming, a single set of start/stop buttons can control two sets of digital tubes to display the corresponding data.
1.2 Software Design
This paper illustrates the software implementation of a design by using two examples of implementing different functions of the same hardware circuit through two software designs.
1.2.1 Software Design Example 1
This program implements a 0-99s repeated counting function. Pressing SB1 starts the counting, pressing SB2 stops the counting at the set position, and pressing the start button again restarts the counting from 0. After counting to 99, the counting restarts from 0. The ladder diagram of this program is shown in Figure 2.
Figure 2 shows the ladder diagram program of Software Design Example 1.
The above software counts the 1-second clock pulses generated by the special memory bit SM0.5, uses PLC data calculation, transmission, and conversion function instructions to transmit and process the changing count data, and then uses the segment decoder SEG instruction to drive the 7-segment display. Two timers generate clock pulses with a period of 200ms and opposite phases to control the display of the changing count data.
1.2.2 Software Design Example 2
This program implements a 50-second countdown function. Press SB1 to start the countdown, press SB2 to stop the countdown, and the digital tube will turn off at the same time. Press the start button again to restart the 50-second countdown. When the countdown reaches 0 seconds, the digital tube will automatically turn off.
2. Conclusion
The design primarily involves dividing a two-digit number into two groups and displaying them on the tens and units digits of a digital tube. The program uses a cyclic control method, displaying one group of data per scan cycle, meaning the two groups are displayed cyclically. Assuming a program scan cycle of 100ms and a timer interval of 100ms, the update cycle for each group of data is 100 × 2 = 200ms. This display frequency is sufficient for general industrial control requirements and can be used for real-time display. Similarly, if multiple groups of data are displayed, the data line connection method remains the same; only the PLC output points for controlling the common terminal signal of the digital tubes need to be added. The number of PLC output points is 7 + n, where n is the number of digital tubes. The software requires only minor modifications. The method described in this paper has been successfully tested and debugged in the laboratory, fully meeting the design requirements, reducing hardware costs, and achieving good results.