There are parameters for which it would be more convenient to provide objective information rather than just an indication. For example, the air temperature outside or the time on the alarm clock. Yes, all this could be done with glowing bulbs or LEDs. One degree – one burning LED or light bulb, etc. But counting these fireflies - well, no! But, as they say, the most simple solutions- the most reliable. Therefore, without thinking for a long time, the developers took simple LED strips and arranged them in the right order.

At the beginning of the twentieth century, with the advent of vacuum tubes, the first gas-discharge indicators appeared

With the help of such indicators it was possible to display digital information in Arabic numerals. Previously, it was on such lamps that various indications were made for devices and other electronic devices. Currently, gas-discharge elements are almost never used anywhere. But retro is always fashionable, therefore, many radio amateurs collect wonderful watches on gas-discharge indicators for themselves and their loved ones.


The disadvantage of gas discharge lamps is that they consume a lot of electricity. One can argue about durability. At our university, frequency meters using gas-discharge indicators are still used in laboratory rooms.

Seven-segment indicators

With the advent of LEDs, the situation has changed dramatically for the better. LEDs themselves consume little current. If you place them in the right position, you can display absolutely any information. In order to highlight all the Arabic numerals, only seven luminous LED strips are enough - segments, set in a certain way:

To almost all such seven-segment indicators, an eighth segment is also added - a dot, so that it is possible to show the integer and fractional value of any parameter

In theory, we get an eight-segment indicator, but in the old fashioned way it is also called a seven-segment indicator.

What is the result? Each strip on the seven-segment indicator is illuminated by an LED or group of LEDs. As a result, by highlighting certain segments, we can display numbers from 0 to 9, as well as letters and symbols.

Types and designation on the diagram

There are one-digit, two-digit, three-digit and four-digit seven-segment indicators. I have never seen more than four categories.

In the diagrams, the seven-segment indicator looks something like this:

In fact, in addition to the main terminals, each seven-segment indicator also has a common terminal with a common anode (OA) or a common cathode (OC)

The internal circuit of a seven-segment indicator with a common anode will look like this:


and with a common cathode like this:


If we have a seven-segment indicator with a common anode (OA), then in the circuit we must supply “plus” power to this pin, and if with a common cathode (OC), then “minus” or ground.

How to check a seven-segment indicator

We have the following indicators:


In order to check a modern seven-segment indicator, we only need a multimeter with a diode testing function. To begin with, we are looking for a general conclusion - it can be either OA or OK. Here only at random. Well, then we check the performance of the remaining segments of the indicator according to the diagrams above.

As you can see in the photo below, the segment being tested lights up. We check other segments in the same way. If all segments are lit, then such an indicator is intact and can be used in your developments.


Sometimes the voltage on the multimeter is not enough to test a segment. Therefore, we take a power supply and set it to 5 Volts. To limit the current through the segment, we check through a 1-2 Kilo-Ohm resistor.


In the same way we check the indicator from the Chinese receiver


In the circuits, seven-segment indicators are connected to resistors at each pin

In our modern world, seven-segment indicators are being replaced by liquid crystal indicators that can display absolutely any information.

but in order to use them, you need certain skills in the circuit design of such devices. Therefore, seven-segment indicators are still used today, due to their low cost and ease of use.

At the request of the workers, I decided to talk about a wonderful thing called a 7-segment LED indicator. First of all, what is it? Here's the thing. This is one digit, there are also two digits, three and four digits. I saw six more digits. After each digit there is a decimal point. If there are four digits, then most often after the second digit you can find a colon to indicate seconds when displaying the time. Having dealt with the glands, let's move on to studying the circuit. What is dynamic display anyway and why is it needed? Since the indicator is 7-segment, only 7 segments are used to display the number. They are always designated in Latin letters A, B, C, D, E, F, G and DP Let's look at the picture. There is an LED under each segment. All LEDs are connected at one end. Either anodes or cathodes, and the opposite ends are brought out. It is easy to notice that to display a number you need to use 8 pins. One general and seven for segments. If this concerns one category, then there is nothing to think about, we just hang everything on one port. What if there are four digits? Eight multiplied by four equals thirty-two. Oh... Yes, such a 32 mega indicator will be one to pore over. It won't work that way. There are two solutions. Ours is a dynamic display or static. To understand further, let's look at the diagram for turning on the indicator.

This scheme implies dynamic indication. Yes, I’m all dynamic and static. What is the difference?. Static indication is when we give each digit its own number and it is constantly on, and dynamic indication is when we display the number in the first digit, then extinguish it and display it in the second digit, then extinguish it and display it in the third digit, and so on until the discharges will not end. After the last category we go again to the first and so on in a circle. If you do this slowly, you will be able to see a digital ticker, but if you increase the speed, for example, to 50 Hz, then your eyes will no longer see a flicker. This is how dynamic display works. Let's now look at the diagram. On the left is the ATmega8 MK behind it on port D there is a 74ALS373 chip. Why is it needed? The fact is that the indicator is simply 8 LEDs assembled in a kind of matrix. That is, the indicator can be represented as a line of 8 LEDs. And as you know, LEDs eat a lot in relation to MK. Of course, connecting directly is not prohibited, but it is better to place some kind of repeater between the MK and the indicator. For these purposes, I decided to use an 8-bit buffer with a latch. Why him? Taking into account the fact that I use the indicator with a common anode, that is, for the task of the digit the active level is 0, then I could safely use the ULN2003A microcircuit (7 transistor assemblies according to the Darlington circuit) and not bother with the buffer, but... But the fact is that ULN2003A has on board only NPN transistors and I can only use the indicator with a common anode, but what if I need to use it with a common cathode? This is where the buffer will help, since what I write there will be on the output. If you want 0, you want 1. The control legs are connected in translator mode. That is, the buffer outputs the same thing as the input. Aya pseudo galvanic isolation. The buffer is followed by current limiting resistors. Remember, these are LEDs and without resistors they will burn out. The resistor value should be selected slightly less than acceptable. The fact is that the dynamic display displays characters with a certain frequency and it is similar to PWM, that is, the higher the frequency, the higher the contrast, so to speak. And with the most comfortable contrast, the numbers will shine a little dimmer. Therefore, resistors need to be taken with a slightly lower nominal value. I used 360 Ohm only because I had some in stock. Next after the resistors is our indicator. On the other side, where the anodes are, I connected the first four digits of port C. So, we sort of figured out the circuit. Now let's discuss the program algorithm. In order to turn on the indicator digits one by one, we will write a separate function and call it endlessly in the main body of the program. More specifically, the function will receive a number from 0 to 9999, parse it into digits, and then output each digit in its place. If the number has less than 4 digits, then the blanks on the left will be filled with zeros. We align ourselves with the right edge. We will run through the categories from left to right. To make any actions visible, we will use interrupts from the counter to increase the output number by one once a second. So the task is set, for battle. #define F_CPU 7372800UL // Quartz frequency #include #include #include volatile unsigned int test = 9980; // Variable to display on the indicator ISR(TIMER1_COMPA_vect) // Interrupt handler for timer 1 match (test++; // Increase the output number if(test > 9999) test = 0; // If it goes beyond four digits, reset it to zero TCNT1H=0x00; //Reset register TCNT1L=0x00; // accounts ) void dig_out(int num); // Declaration of the function to display on the indicator int main(void) ( DDRC = 0x0F; // Configure ports DDRD = 0xFF; // for working with the indicator Port C for digits, Port D for numbers TCCR1A=0x00; // Setting the timer TCCR1B=0x04; TCNT1H=0x00; TCNT1L=0x00; OCR1AH=0x70; OCR1AL=0x80; TIMSK=0x10; sei(); // Enable interrupts while(1) ( dig_out(test); //Constantly call the function to display the current number ) ) void dig_out(int num) // Function for displaying 4 digits on the indicator ( unsigned char i = 0; // Counter variable unsigned char raz = 1; // Digit number unsigned char dig_num = (0x40, 0x79, 0x24, 0x30, 0x19, 0x12, 0x02, 0x78, 0x00, 0x10); // Number codes for an indicator with a common anode unsigned char dig = (0, 0, 0, 0); // Array for digit value if(num ( dig =0; dig =0; dig =0; ) if(num // To fill the left bits with zeros ( dig =0; dig =0; ) if(num // To fill the left bits with zeros ( dig =0; ) while(num > 999) // Get the number of thousands ( dig++; num -= 1000; ) while(num > 99) // Get the number of hundreds ( dig++; num -= 100; ) while(num > 9) // Get the tens number ( dig++; num -= 10; ) dig = num; // Get the number of units while(raz // Spin until we fill all 4 bits (PORTC = raz; // Select a rank PORTD = dig_num]; // Output the number raz = raz // Shift to the next digit i++; //Increase the index of the next digit _delay_ms(1); // Delay 1 ms } } That's all the code. I won’t describe it because it has comments for each line. Below you can download the archive with the project for AtmelStudio6.2. If you still have questions, you are welcome to the forum. Well, for the most fastidious, below is a video of all this balalaika))).

This time, the article will consider one of the most interesting modules, namely - multi-digit seven-segment indicator based on the MAX7219 chip. Why multi-bit? The answer is simple - the number of digits is the number of digits that the module can display. For example, in the photo below, three types of multi-digit indicators are shown, from left to right - 4-digit, 6-digit, 8-digit. Moreover, the first one is 4-digit dial indicator. The difference between a dial indicator and a regular one is that it has a sign colons, whereas in any regular indicator this sign is replaced by a dot at the bottom, next to the number.

In this article, the modules in question operate on the basis of a microcircuit MAX7219. This chip is a driver for seven-segment LED indicators, as well as 8x8 LED matrices, and we will not consider the circuit diagrams for connecting this driver. The ready-made module is simply taken as a basis; examples of connection to the board will be given Arduino UNO and worked with library functions LedControl. By the way, as already mentioned, 8x8 LED matrices also work based on a driver MAX7219, and if anyone is interested, welcome to the articles:

So, let's begin... I think that a good description was given about multi-bit, but here's why seven-segment? The answer is also not so complicated - because seven LEDs, indexed by letters, are used to form a symbol or display a number A, B, C, D, E, F, G, The table below shows how this is indicated:

As can be seen from the table, there is also an eighth LED - D.P. You can completely encode a character or digit in 1 byte by setting or clearing a specific bit, as shown with the character encoding example J. In the example the bits are set B, C, D, E, which allows you to display a specified character on a seven-segment indicator.

From theory to practice - let's connect an 8-bit module to the Arduino Uno board according to the diagram below:

To display symbols, several functions from the LedControl.h plug-in library are used. Let's look at each of these functions in order, starting with the setDigit() function.

The prototype of the function declaration for displaying the number and the arguments passed to the function:

setDigit(int addr, int digit, byte value, boolean dp);

Where -

int addr -module address on the busSPI 0 SPI starts from scratch)

int digit - 0 , 7

byte value -value (a number from 0 to 9) that needs to be displayed in the digit whose number is specified in the int digit parameter

boolean dp - int digit. If the parameter is true then the point will be displayed if false then the point will not be displayed.

The prototype of the function declaration for displaying the symbol and the arguments passed to the function:

setChar(int addr, int digit, char value, boolean dp);

int addr - module address on the busSPI for which the function is called, if there is only one module, then this parameter is equal to0 (default addressing of devices on the busSPI starts from scratch)

int digit - the serial number of the digit in the display module; by default, for multi-digit indicators, the numbering of digits begins with the rightmost digit, respectively, the number of the rightmost digit is equal to0 , and the number of the leftmost digit in our case is equal to7

char value - the character that should be displayed in the digit whose number is specified by the parameterint digit

boolean dp - this parameter is responsible for displaying a dot at the digit whose number is specified in the parameter int digit. If the parameter is true then the point will be displayed if false then the point will not be displayed.

A separate point worth mentioning is that the function setChar() can only display a limited set of characters, such as:

  • 0 1 2 3 4 5 6 7 8 9 the digit is displayed as a symbol
  • A a
  • B b
  • With with the character will be displayed in lower case
  • D d the character will be displayed in lower case
  • E e the character will appear in uppercase
  • F f the character will appear in uppercase
  • H h the character will be displayed in lower case
  • L l the character will appear in uppercase
  • P p the character will appear in uppercase
  • - minus sign"
  • . , point display
  • _ underscore
  • <Пробел> set space character

In a test sketch, you can set a task like this:

  1. Display numbers from 1 to 8 one by one without a dot
  2. Fill in all the digits of the display module with numbers from 1 to 8, plus display all the points of the indicated digits
  3. Draw a bitwise array with characters pre-encoded in binary code, the result should be “Arduino rules!!!”

Due to the limited character set, the function setChar() is not suitable for a test sketch, since it will not be able to normally draw the phrase specified in point 3. Instead of this function, we will use the function setRow(). So... function setRow() has already been tested by us in articles about studying 8x8 LED matrices, let's again describe the prototype of the call and the parameters of this function.

Function Declaration Prototype setRow() and the arguments passed to the function:

setRow(int addr, int row, byte value);

int addr - module address on the busSPI for which the function is called, if there is only one module, then this parameter is equal to0 (default addressing of devices on the busSPI starts from scratch)

int row - the serial number of the digit in the display module; by default, for multi-digit indicators, the numbering of digits begins with the rightmost digit, respectively, the number of the rightmost digit is equal to0 , and the number of the leftmost digit in our case is equal to7

byte value- a value in binary format (example B00000000, alternatives in decimal and hexadecimal are also possible), which encodes the required character. The character encoding table will help you correctly encode the desired character.

Well, at the end of the article, a test sketch and a video of how it works:

#include "LedControl.h" /* * We connect the LedControl.h library * and create an object of the LedControl class * in this case, a 7-segment display with a MAX72xx driver * must be connected to the Arduino board as follows: * Arduino -> Display Module MAX72xx * Arduino -> Display Module MAX72xx * Arduino -> Display Module MAX72xx * Arduino -> Display Module MAX72xx * Arduino -> Display Module MAX72xx * */ LedControl lc = LedControl(12, 11, 10, 1); //Array with encoded characters, //Phrase "Arduino ruLES!!!" byte ar = ( B01110111, //A B00000101, //r B00111101, //d B00011100, //u B00010000, //i B00010101, //n B00011101, //o B00000101, //r B00011100, //u B00001100 , //l B01001111, //E B01011011, //S B10110000, //! B10110000, //! B10110000 //! ); void setup() ( //The device (7-segment display) is brought out of sleep mode lc.shutdown(0, false); //Set the display brightness to 8 //Total possible brightness modes from 0 to 15 lc.setIntensity(0 ,8); //Clear the display lc.clearDisplay(0); ) void loop() ( //The simplest search of numbers from 1 to 8 by digits for(int i = 0, j = 7; i< 8, j >= 0; i++, j--) ( lc.setDigit(0, j, byte(i + 1), false); delay(400); lc.clearDisplay(0); ) //Iterate through numbers without clearing the screen for(int i = 0, j = 7; i< 8, j >= 0; i++, j--) ( lc.setDigit(0, j, byte(i + 1), true); delay(400); ) lc.clearDisplay(0); //Rendering the phrase "Arduino ruLES!!!" int n = 0; for(int i = 0; i< 2; i ++) { for(int j = 7; j >= 0; j --) ( if(n > 6 && !(i % 2)) ( continue; ) else ( lc.setRow(0, j, ar[n]); delay(400); n ++; ) ) lc .clearDisplay(0); ) delay(400); lc.clearDisplay(0); )


Please enable javascript for comments to work.

New articles

● Project 7: 4-digit matrix of 7-segment indicators. Making a dynamic display

In this experiment we will look at the operation of Arduino with a 4-bit seven-segment matrix. Let's get an idea of ​​dynamic display, which allows you to use the same Arduino pins when displaying information on several seven-segment indicators.

Required components:

The 4-digit matrix of seven-segment indicators consists of four seven-segment indicators and is designed to simultaneously display 4 digits on the matrix; it is also possible to display a decimal point. The circuit of a 4-bit matrix on 7-segment indicators is shown in Fig. 7.1.

Rice. 7.1. Scheme of a 4-bit matrix on 7-segment indicators

To output a number, you need to light the necessary LEDs on pins A-G and DP and select the desired matrix by applying LOW to pin 6, 8, 9 or 12.
Let's connect the matrix contacts to the Arduino board and output numbers to various bits of the matrix. To connect we need 12 Arduino pins. The connection diagram for connecting a 4-bit matrix to the Arduino board is shown in Fig. 7.2. When connecting contacts, 510 Ohm limiting resistors are used.

Rice. 7.2. Connection diagram for 4-bit matrix to Arduino

Let's write a sketch of sequential output of numbers (0-9) to an arbitrary register of the matrix. To select a random value from the range, we will use the random() function. The numbers array stores values ​​corresponding to the data for displaying digits 0-9 (the most significant bit of the byte corresponds to the label of segment A of the indicator, and the low-order one to segment G), the pins array contains the contact values ​​for segments A-G and DP, the pindigits array contains the contact values ​​for selecting a matrix digit. The contents of the sketch are shown in Listing 7.1.

// variable to store the value of the current digit int number=0 ; // seven-segment indicator int digit=0 ; void setup()( for (int i=0 ;i<8 ;i++) pinMode(pins[i],OUTPUT); for (int i=0 ;i<4 ;i++) {pinMode(pindigits[i],OUTPUT); digitalWrite(pindigits[i],HIGH); } } void loop()( number=(number+1 )%10 ; showNumber(number); // DS for (int i=0 ;i<4 ;i++) digitalWrite(pindigits[i],HIGH); digit=random(0 ,4 ); digitalWrite(pindigits,LOW); delay(3000 ); } void showNumber( int num)( for (int i=0 ;i<7 ;i++) { if (bitRead(numbers,7 -i)==HIGH) // light up the segment // extinguish the segment digitalWrite(pins[i],LOW); ) )
Connection order:

1. Connect a seven-segment indicator according to the diagram in Fig. 7.3.
2. Load the sketch from Listing 7.2 onto the Arduino board.

// list of Arduino pins to connect to bits a-g // seven-segment indicator int pins=(9 ,13 ,4 ,6 ,7 ,10 ,3 ,5 ); // values ​​to display numbers 0-9 byte numbers = ( B11111100, B01100000, B11011010, B11110010, B01100110, B10110110, B10111110, B11100000, B11111110, B11110110); // variable for storing and processing the current value int number=0 ; int number1=0 ; int number2=0 ; // seven-segment indicator int pindigits=(2 ,8 ,11 ,12 ); // variable to store the current digit int digit=0 ; // to measure 100 ms unsigned long millis1=0 ; // mode 1 - stopwatch is running mode=0 ; const int BUTTON=14 ; // Pin 14(A0) for connecting the button int tekButton = LOW; // Variable to save the current state of the button int prevButton = LOW; // Variable to save the previous state// to the buttons boolean ledOn = false ; // Current state of the LED (on/off) void setup(){ // Configure the button pin as an input pinMode(BUTTON, INPUT); // Configure pins as outputs for (int i=0 ;i<8 ;i++) pinMode(pins[i],OUTPUT); for (int i=0 ;i<4 ;i++) {pinMode(pindigits[i],OUTPUT); digitalWrite(pindigits[i],HIGH); } } void loop()( tekButton = debounce(prevButton); if (prevButton == LOW && tekButton == HIGH) // if pressed... ( mode=1 -mode; // change mode if (mode==1 ) number=0 ; ) if (millis()-millis1>=100 && mode==1 ) (millis1=millis1+100 ; number=number+1 ; if (number==10000 ) number=0 ; ) number1=number; for (int i=0 ;i<4 ;i++) { number2=number1%10 ; number1=number1/10 ; showNumber(number2,i); for (int j=0 ;j<4 ;j++) digitalWrite(pindigits[j],HIGH); digitalWrite(pindigits[i],LOW); delay(1 ); } } // function for displaying numbers on a seven-segment indicator void showNumber( int num,int dig)( for (int i=0 ;i<8 ;i++) { if (bitRead(numbers,7 -i)==HIGH) // light up the segment digitalWrite(pins[i],HIGH); else // extinguish the segment digitalWrite(pins[i],LOW); ) if (dig==1 ) // decimal point for second digit digitalWrite(pins,HIGH); ) // Bounce smoothing function. Accepts as // argument the previous state of the button and returns the actual one. boolean debounce ( boolean last)( boolean current = digitalRead(BUTTON); // Read the state of the button, if (last != current) // if it has changed...( d elay ( 5 ) ; // let's dem 5 m s current = digitalRead(BUTTON); // read the button state return current; // return the button state } }

3. By pressing the button we start or stop the stopwatch.

Seven-segment LED indicators are very popular among digital value display devices and are used in the front panels of microwave ovens, washing machines, digital clocks, counters, timers, etc. Compared with LCD indicators, LED indicator segments glow brightly and are visible over long distances and in wide viewing angle. To connect a seven-segment 4-bit indicator to a microcontroller, at least 12 I/O lines will be required. Therefore, it is almost impossible to use these indicators with microcontrollers with a small number of pins, for example, series from the company. Of course, you can use different multiplexing methods (a description of which can be found on the website in the “Schemes” section), but even in this case there are certain limitations for each method, and they often use complex software algorithms.

We will look at the method of connecting an indicator via the SPI interface, which will require only 3 I/O lines of the microcontroller. At the same time, control of all indicator segments will remain.

To connect a 4-bit indicator to a microcontroller via the SPI bus, a specialized driver chip produced by the company is used. The microcircuit is capable of driving eight seven-segment indicators with a common cathode and includes a BCD decoder, segment drivers, a multiplexing circuit and static RAM for storing digit values.

The current through the indicator segments is set using only one external resistor. Additionally, the chip supports control of indicator brightness (16 brightness levels) using built-in PWM.

The circuit discussed in the article is a display module circuit with an SPI interface that can be used in amateur radio designs. And we are more interested not in the circuit itself, but in working with the microcircuit via the SPI interface. The +5 V module power is supplied to the Vcc pin, the MOSI, CLK and CS signal lines are intended for communication between the master device (microcontroller) and the slave (MAX7219 chip).

The microcircuit is used in a standard connection; the only external components needed are a resistor that sets the current through the segments, a protective diode for the power supply, and a filter capacitor for the power supply.

Data is transferred to the chip in 16-bit packets (two bytes), which are placed in the built-in 16-bit shift register on each rising edge of the CLK signal. We denote a 16-bit packet as D0-D15, where bits D0-D7 contain data, D8-D11 contain the register address, bits D12-D15 have no meaning. Bit D15 is the most significant bit and is the first bit received. Although the chip is capable of controlling eight indicators, we will consider working with only four. They are controlled by the outputs DIG0 - DIG3, located in sequence from right to left, the 4-bit addresses (D8-D11) that correspond to them are 0x01, 0x02, 0x03 and 0x04 (hexadecimal format). The digit register is implemented using on-chip RAM with an 8x8 organization and is directly addressable so that each individual digit on the display can be updated at any time. The following table shows the addressable digits and control registers of the MAX7219 chip.

Register

Address

HEX value

No operation

Decoding Mode

Number of indicators

Shutdown

Indicator test

Control registers

The MAX1792 chip has 5 control registers: decoding mode (Decode-Mode), indicator brightness control (Intensity), register of the number of connected indicators (Scan Limit), on/off control (Shutdown), test mode (Display Test).

Turning the chip on and off

When power is applied to the chip, all registers are reset and it goes into Shutdown mode. In this mode the display is turned off. To switch to normal operation mode, bit D0 of the Shutdown register (address 0Сh) must be set. This bit can be cleared at any time to force the driver to turn off, leaving the contents of all registers unchanged. This mode can be used to save energy or in alarm mode by flashing the indicator (sequential activation and deactivation of the Shutdown mode).

The microcircuit is switched to Shutdown mode by sequentially transmitting the address (0Сh) and data (00h), and transferring 0Ch (address) and then 01h (data) returns to normal operation.

Decoding Mode

Using the decoding mode selection register (address 09h), you can use BCD code B decoding (display characters 0-9, E, H, L, P, -) or without decoding for each digit. Each bit in the register corresponds to one digit, setting a logical one corresponds to turning on the decoder for this bit, setting 0 means the decoder is disabled. If a BCD decoder is used, then only the lowest nibble of data in the digit registers (D3-D0) is taken into account, bits D4-D6 are ignored, bit D7 does not depend on the BCD decoder and is responsible for turning on the decimal point on the indicator if D7 = 1. For example, when bytes 02h and 05h are sent in sequence, the DIG1 indicator (second digit from the right) will display the number 5. Similarly, when sending 01h and 89h, the DIG0 indicator will display the number 9 with the decimal point included. The table below provides a complete list of characters displayed when using the IC's BCD decoder.

Symbol

Data in registers

Enabled segments = 1

Empty

*The decimal point is set by bit D7=1

When the BCD decoder is excluded from operation, data bits D7-D0 correspond to the segment lines (A-G and DP) of the indicator.

Indicator brightness control

The chip allows you to programmatically control the brightness of the indicators using the built-in PWM. The PWM output is controlled by the low-order nibble (D3-D0) of the Intensity register (address 0Ah), which allows you to set one of 16 brightness levels. When all bits of a nibble are set to 1, the maximum brightness of the indicator is selected.

Number of connected indicators

The Scan-Limit register (address 0Bh) sets the value of the number of bits serviced by the microcircuit (1 ... 8). For our 4-bit version, the value 03h should be written to the register.

Indicator test

The register responsible for this mode is located at address 0Fh. By setting the D0 bit in the register, the user turns on all indicator segments, while the contents of the control and data registers do not change. To disable Display-Test mode, bit D0 must be 0.

Interface with microcontroller

The indicator module can be connected to any microcontroller that has three free I/O lines. If the microcontroller has a built-in SPI hardware module, then the indicator module can be connected as a slave device on the bus. In this case, the SPI signal lines SDO (serial data out), SCLK (serial clock) and SS (slave select) of the microcontroller can be directly connected to the MOSI, CLK and CS pins of the MAX7219 chip (module), the CS signal is active low.

If the microcontroller does not have hardware SPI, the interface can be organized in software. Communication with the MAX7219 begins by pulling and holding the CS line low, then sending 16 bits of data sequentially (MSB first) on the MOSI line on the rising edge of the CLK signal. Upon completion of the transmission, the CS line goes high again.

In the downloads section, users can download the source text of the test program and the HEX file of the firmware, which implements a conventional 4-bit counter with display of values ​​on an indicator module with an SPI interface. The microcontroller used is an interface implemented in software, the signal lines CS, MOSI and CLK of the indicator module are connected to ports GP0, GP1 and GP2, respectively. The mikroC compiler for PIC microcontrollers is used (mikroElektronika

To comment on materials from the site and gain full access to our forum, you need register .