Application of MAX7219 in PLC

Publisher:iota19Latest update time:2006-05-07 Source: 电子技术应用 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

    Abstract: This article introduces the working principle of the static display chip MAX7219, proposes a simple and practical static display system suitable for PLC, and discusses the hardware connection and software programming using SIEMENS' S7-200PLC as an example.

    Keywords: MAX7219 PLC static display system

       

    The latest small and highly integrated PLCs, such as the SIEMENS S7-200 series, have multiple switching input/output points on the main module, and have a 485 serial communication port that complies with industry standards, making it easy for users to configure stand-alone equipment. Independently controlled or connected into a fully distributed computer monitoring network, connected to remote control rooms. However, in actual applications, some stand-alone controllers or some equipment far away from the control room often need to be displayed locally to facilitate operator operation or inspection. SIEMENS PT200 monitor is developed for this purpose. However, its display screen is small and mostly liquid crystal display, which is not suitable for situations with strong light or extremely weak light. It also takes up serial port resources, is inconvenient to install, and is expensive. The usual solution is to make full use of the PLC switching output points and drive the LED display in parallel. Parallel display takes up a lot of resources, and there are not many switching output points on the general small PLC main module (S7212 has 6 output points, S7-214 has 10 output points), which makes it difficult to meet the needs of multi-digit display and multi-point control. Require. This article proposes a method of using the MAX7219 chip to cooperate with the PLC output point. Through simple hardware connection and the powerful programming ability of the PLC, it can be flexibly programmed according to the actual situation to realize LED display and function control.

    1 Introduction to MAX7219

    MAX7219 is a new type of serial interface 8-bit digital static display chip. It is a newly launched 24-pin dual in-line chip by MAXIM Company. Its pin diagram is shown in Figure 1.

   SEGA~SEGG and SEGDP are LED seven-segment driver lines and decimal point lines, supplying display source current; DIGO~DIG7 are 8-bit digital drive lines, outputting bit selection signals, and sinking current from the common cathode of each LED.

    Figure 2 is the working timing diagram of MAX7219. As can be seen from Figure 2, DIN is the serial data input terminal. On the rising edge of CLK, one bit of data is loaded into the internal 16-bit shift register. The maximum input frequency of the CLK terminal can reach 10MHz. On each rising edge of the input clock signal On the rising edge of LOAD, 1-bit data is moved from DIN into the internal register. LOAD is used to load data. On the rising edge of LOAD, 16-bit serial input data is latched into the digital or control register. LOAD must go high at the same time or after the rising edge of the 16th clock and before the rising edge of the next clock, otherwise the data will be lost.

    A set of data is specified as a 16-bit binary data packet with the following format:

 

    The bits are not used and are the addresses of the 5 internal control registers and 8 LED display data registers. The address codes are shown in Table 1. It is the data to be displayed by 5 control register command words or 8 LED digital tubes. Because the control registers and display data registers are independently addressed, each register can be operated independently through the program. Under normal circumstances, the program sends control commands first, and then sends data to the display register. However, it must be noted that each 16-bit group is sent starting from the highest bit of the high-order address byte until the last bit of the low-order data word.   

    2 Hardware connection between MAX7219 and PLC

    Now we will take the small PLC S7-214 of SIEMENS Company as an example to discuss the hardware connection and software programming of PLC and MAX7219. S7-214 has few output points (Q0.0~Q1.1, ten digits in total) and only one RS-485 communication port. The hardware connection between S7-214 and MAX7219 is shown in Figure 3 . Q0.0 of S7-214 is used for serial data output and is connected to the DIN pin of MAX7219. Q0.1 and Q0.2 simulate the clock pulse CLK and data loading LOAD signal of MAX7219 respectively through the program. The SEGA ~ SEGFGF and SEGDP terminals of MAX7219 are connected to the a ~ f and db terminals corresponding to each LED digital tube. DIG0 ~ 7 are respectively connected to the common cathode of the 8-bit LED digital tube to achieve bit selection.

    In fact, the number of digits of the digital tube can be selected arbitrarily between 1 and 8, which can be determined by the command word written to the scan boundary register. NOTE: A 9.6kΩ resistor between pins 18 and 19 is required, and to minimize the ripple caused by the peak digital driver current, an external 10μF electrolytic resistor needs to be connected between V+ and GND as close to the chip as possible capacitor and a 0.1μF ceramic capacitor. The MAX7219 should be placed close to the LED display and the connections should be as short as possible. Both GND pins must be connected to ground.

    3 Software programming

    Open a two-byte storage unit VW0 in the V storage area of ​​S7-214, which is specially used to store 16-bit binary data packets. The high-order byte VB1 specifies the high-order address byte, and the low-order byte VB0 specifies the low-order command word or The number to be displayed.

    Since the control registers and display registers of the MAX7219 are independently addressed, the display program is actually S7-214 continuously sending signals to the MAX7219 through Q0.0 (DIN) with the cooperation of Q0.1 (CLK) and Q0.2 (LOAD) timing. The process of writing a 16-bit binary data packet to the corresponding control register and data display register. So the key to the problem is to write a general write subroutine to move the contents of VW0 from high to low into the shift register under the action of Q0.1 (CLK), and finally by the rising edge of Q0.2 (LOAD signal) Latch into the corresponding internal control register and data display register. The program flow chart of writing subroutine is shown in Figure 4.

    Whether initializing the control register of the MAX7219 or displaying numbers on the corresponding digital tube, it can be completed by calling the above-mentioned general write subroutine. Note that before calling the subroutine, the correct 16-bit binary data must be moved into VW0 using the MOVW instruction.

    The MAX7219 automatically scans and displays the numbers to be displayed in the manner specified by the five control registers, so the five control registers must be initialized before the display program. The functions of each control register are described as follows:

    (1) The decoding mode register sets BCD code B (0~9, E, H, L, P and -) or non-code operation for each number. Each bit in the register corresponds to a number. A logic high selects Code B decoding, while a low selects the bypass decoder.

    (2) The bit position of the display brightness register can be arbitrary, and 0000~1111 can be selected. The larger the value of D3~D0, the brighter the LED display.   

    (3) Scan range register The scan range register sets the number of displayed data, which can be from 1 to 8. They are generally displayed with a scan rate of 1300Hz, 8-bit data, and multiplexing.

    (4) Close the registerThe position is optional. , turn off all displays; D0=1, allow display.

    (5) The D7~D1 bits in the display test register are optional; Do=0, LED is in normal working condition; Do=1, display is allowed. The LED is in display test status.

    After sending the control word, the display subroutine can be called according to actual needs to change the contents of 1 to 8 data registers to complete the display function.

    MAX7219 only needs a set of +5V power supply and three output ports of PLC, and no additional circuits. It can drive 1 to 8 LED displays, with adjustable display brightness and reliable operation.

Reference address:Application of MAX7219 in PLC

Previous article:Design of monitoring circuit and display software composed of PLC and dot matrix liquid crystal display module
Next article:Application of computer and PLC integrated control system in petrochemical industry

Latest Industrial Control 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号