logo elektroda
logo elektroda
X
logo elektroda

Designing Custom Displays with PIC18F16Q40 and MAX7219 Modules: A Step-by-Step Guide

unikeyic 318 0
ADVERTISEMENT
  • #1 21312116
    unikeyic
    Level 2  
    Unleashing Creativity: Designing Custom Displays with PIC18F16Q40 and MAX7219 Modules


    The Max7219 is a shift and parallel conversion chip, hence it can effectively save I/O port resources. The digital tube module and the dot matrix display module made with this chip are two common functional modules.
    For small board cards like the PIC18F16Q40, choosing the Max7219 (Link) module as the display thing is super suitable. .
    To use the PIC18F16Q40 (Link) to drive the Max7219 module, the first thing to do is set up the pins with MCC (Microchip Configuration Compiler).

    The PIC18F16Q40 microcontroller, which works well with the Max7219, is also available at Unikeyic (Link). Unikeyic provides a wide range of quality components for your electronics projects.

    When establishing the following connections, the pin configuration is shown in Figure 1:
    DIN —— RC4
    CLK —— RC6
    CS —— RC7

    Where: DIN stands for serial data input, CLK stands for serial clock input, and CS is the chip select pin.
    Pin configuration diagram of the PIC18F16Q40 microcontroller.

    The corresponding pin names are shown , and all three pins are set to output mode.
    Pin configuration table for microcontroller.

    Additionally, to facilitate programming, the system's delay function was called.
    Screenshot of a software interface showing various project modules, including Pin Module and System Module.

    Due to the simulation of serial data transmission using I/O, the function for serial data sending is as follows:
    C code for byte writing function to MAX7219 chip

    The function for writing data to a register is:
    Screenshot of a C code snippet for writing data to the MAX7219 chip.

    Given that the two modules have different functionalities, their initialization functions and main programs are distinct. Below is a detailed introduction for each.

    Driving Serial Digit Display Module The serial digit display module is designed to control an 8-digit 7-segment digit tube using the MAX7219 chip. This chip integrates an internal B-type BCD code encoder with a multiplex scanning circuit and segment drivers. Additionally, it includes an 8x8 static RAM for storing display data, as well as an external register to set the segment current for each LED. Each datum can be individually addressed without rewriting when updated, and it also allows users to choose between encoding or not encoding for each datum. During the display process, there is no flickering or jitter, and the module supports cascading for expanding the number of digits displayed. The appearance of the module is shown in Figure 4:
    8-digit seven-segment display module.
    8-bit Serial Digital Tube Module


    The initialization function for this module is:
    Initialization code for MAX7219 module in C

    To achieve the display effect, the main program is as follows:
    C program code for initializing and controlling the MAX7219 module.

    Compared with conventional digital tube displays, this display method features fewer pin resources required and higher brightness, making it suitable for industrial control applications.
    Microcontroller chip connected to a 7-segment display showing numbers from 0 to 8.
    Display performance


    2.Driven Matrix Display Module
    Driving the Serial Digit Display Module. It uses the MAX7219 chip to control an 8-digit 7-segment digit tube. The chip has a B-type BCD code encoder, multiplex scanning circuit, segment drivers, 8x8 static RAM for data storage, and an external register for LED segment current. Data can be separately addressed and updated without rewrite. Users can choose encoding. It shows without flickering or jitter and can be cascaded. See Figure 4 for its appearance.
    8x8 dot matrix display module with labeled pins
    Dot Matrix Display Module Pin Layout

    Wiring diagram of the MAX7219 module with pin labels.
    Dot Matrix Module Schematic Diagram


    The initialization function for the MAX7219 is:
    Code snippet of the MAX7219 initialization function in C language.

    To achieve the display effects, the main program is:
    Program code snippet for the MAX7219 module

    In this context: The inner loop's job is to show a single character. And the outer loop is to go through and display what's in the character library. When showing, after each character is displayed, the state of the LEDs on the board is changed once.
    LED matrix module connected to a microcontroller with wires.
  • ADVERTISEMENT
ADVERTISEMENT