Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] MAX7219 and Common Anode LED Display

Status
Not open for further replies.

speedEC

Full Member level 6
Joined
Apr 1, 2011
Messages
337
Helped
23
Reputation
46
Reaction score
21
Trophy points
1,298
Activity points
4,324
Dear friends,

MCU : PIC16F1938
LED DISPLAY (BIG SIZED): 6 DIGITS
VDD (LED DISPLAY) = +12V
LED DIGIT SIZE: 3.5" x 5"
DISPLAY: COMMON ANODE ***
POWER SUPPLY:
MAX7219 & PIC MCU = +5V
LED DISPLAY = +12V, 500mA POWER ADAPTER


I have to interface LED DISPLAY (6 Digits) from PIC MCU thru' MAX7219 IC. MAX7219 for common cathode display. I have used ULN2003 and PNP (BC557) transistors to make it work on MAX7219. I am using bitbanging (not SPI module) method (RA1 - SDO, RA2 - SS, RA3 - SCK).

Code works OK. But, if data sent to one digit, it writes on all digits. Also, when first data sent, it clears all other segments correctly and correct digit displayed on Digits. but after second data sent, it overlaps on earlier digit we have already written.


Code C - [expand]
1
2
3
4
5
6
MAX7219 DIG PIN -> 4K7 RESISTOR -> BASE PIN PNP.
BASE PIN OF PNP -> 47K -> +12V
+12V -> 300R RESISTOR -> EMITTER PIN OF PNP
COLLECTOR PIN OF PNP -> VDD PINS of INDIVIDUAL LED DIGIT
 
MAX7219 SEG PINS -> ULN2003 -> LED SEGMENT PINS.



sample picture attached FYR.

what could be the problem?

thanks in advance.
 

Attachments

  • PNP_MAX7219.JPG
    PNP_MAX7219.JPG
    11.6 KB · Views: 263

Follow Andre's advice.

The most likely reasons are:
1. You have an electrical fault and the digits that should be on are off and vice versa. This means one of the digits is probably slightly different to the others but they are all similar. You can check this by dimming them, if dimming works in reverse you have the digit drive signal inverted.

2. You have a software fault and the address bits in the SPI word are incorrect.

My guess is the electrical scenario, remember the outputs of the MAX7219 are expected to sink current or source current so you may need to add resistors appropriately to allow some current to flow instead of just assuming voltages are turning on or off.

Brian.
 

Whenever possible, take a time to make a movie of the problem; with the code and being able to see how the system behaves, one can have an insight and say exactly where the error lies at your code.
 

No schematic, no code...
Are you serious ?

Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
static void Send16bits (unsigned short output)
{
 
  unsigned char i;
 
  for (i=16; i>0; i--) 
  {
    unsigned short mask = 1 << (i - 1); // calculate bitmask
    
    SERCLK = LOW;
    
    // Send one bit on the data pin
    
    if (output & mask)
      LED_DATA = HIGH;
    else
      LED_DATA = LOW;
    
    SERCLK = HIGH;
    SERCLK = LOW;
  }
}
// Take a reg numer and data and send to the max7219
 
static void MAX7219Send (unsigned char reg_number, unsigned char dataout)
{
    LOAD_DATA = 1;
    Send16bits((reg_number << 8) + dataout);   // send 16 bits ( reg number + dataout )
    LOAD_DATA = 0;
    LOAD_DATA = 1;
}
void init_MAX7219_NEW(void){
    
    // set decode mode
    MAX7219Send(0x09, 0xFF);
    
    // set intensity
    MAX7219Send(0x0A, 0x0F);
    
    // set scan limit 0-7
    MAX7219Send(0x0B, 0x05); // 6 digits
    
    // set for normal operation
    MAX7219Send(0x0C, 0x01);
    
    // NO TEST
    MAX7219Send(0x0F, 0x00);
    
    // clear MAX7219 all zeros
    // BCD mode all off otherwise
    for(int i = 1; i <= 6; i++){
        MAX7219Send(i, 0x00);
    }
} 
 
int decToBcd(int val){
// Convert normal decimal numbers to binary coded decimal
  return ( (val/10*16) + (val%10) );
}
 
int bcdToDec(int val){
// Convert binary coded decimal to normal decimal numbers
  return ( (val/16*10) + (val%16) );
 
 
}


When running "for" loop, instead of clear the LED digits, it shows the numbers that we supplied.


Code C - [expand]
1
2
3
4
5
6
main(){
    unsigned char bcd; 
    bcd = decToBcd(1);
    MAX7219Send(0x01, bcd);
 while(1);
}


When this code runs, it overlaps on previously written digits. i.e. not clear the previous digits.

You have an electrical fault and the digits that should be on are off and vice versa
LED DISPLAY (all LED Digits) randomly on/off (like glitching). It is not staying on or off for a long time. What could be the reason. Now I have bought separate LED digits and combined myself to make LED DISPLAY. Earlier I have bought readymade LED Digit Panel (small 8 digits) from ebay. But that modules also showed same behaviour of glitching. But when we run the code, it displayed the result correct (SPI module used, NOT bitbanging).

This means one of the digits is probably slightly different to the others but they are all similar
One of 6 Digit is different from other 5 LED Digits. First I bought 1 LED for testing. After this, I bought 5 LED digits. Both are different make. I hope so. But all are common anode. One of the 6 digits luminosity intensity is different (dull) from other 5 digits.

You have a software fault and the address bits in the SPI word are incorrect.
The code is given above FYR. Pl check.


Code C - [expand]
1
My guess is the electrical scenario, remember the outputs of the MAX7219 are expected to sink current or source current so you may need to add resistors appropriately to allow some current to flow instead of just assuming voltages are turning on or off.


I have used 300R to give 40mA to each Digit. Is that not enough?

any suggestions?
thanks in advance.

- - - Updated - - -

+12V -> 300R -> PNP -> LED DIGIT VDD PIN when MAX7219 sink the DIG pin.
Picture attached FYR.

- - - Updated - - -

10K RESISTOR USED AS Rset of MAX7219.
 

Attachments

  • LED_VDD_MAX7219.JPG
    LED_VDD_MAX7219.JPG
    16.5 KB · Views: 200

This cirtuit will not work. Voltage level not alligned. You should add one more npn transistor to convert 5v pin voltage to 12v driving Q6 voltage.
 

You (and Easyrider83) are confirming what I thought. It's an electrical issue. Consider how the MAX7219 works internally, it basically has switches from the supply to the LED anodes and switches from the LED common cathodes to ground. When the switches are 'on' in the correct combination, the appropriate segment or LED lights up. When the switch is 'off' it doesn't remove the voltage, it just isolates it and effectively leaves the current path open circuit. Your driver circuit expect to be turned on or turned off by the voltage applied to it but what you actually have is current turned on or your circuit input disconnected. It isn't able to turn the unwanted digits off so they all show the same pattern.

You can try adding resistors to mimic the normal LED operation, add resistors (guess ~1K) from the cathode drive to +Ve and from the anode drives to GND so the output voltage go to the opposite logic state when NOT being driven.

Brian.
 
You should add one more npn transistor to convert 5v pin voltage to 12v driving Q6 voltage.
If MAX sinks the DIG pin, the current should flow and vice-versa. If we add npn transistor, the signal could be inverted. How can we solve this issue? Any suggestion?
You (and Easyrider83) are confirming what I thought. It's an electrical issue
Yes. I have tested the code with +5V COMMON CATHODE LED 8 digits(as I already told you that bought from ebay). It works fine. So code is not a problem.
add resistors (guess ~1K) from the cathode drive to +Ve and from the anode drives to GND
You mean, cathode drive to +Ve -> DIG PIN and from the anode drives to GND -> SEG PIN?

thank you
 

From the data sheet Easyrider83 mentions:
Digit Drivers
The digit drive outputs of the MAX7219/7221 are power switches which go active low one at a time to turn a digit on, and high impedance when off.
That isn't the same as going active low and active high. By adding your own external driver circuit you are no longer using the drive capability of the MAX7219, instead you are using it to create logic levels which your own driver can use. While the MAX7219 can sink or source current, it has no way to produce a high or low voltage (logic levels) at it's pins unless you actively pull them to the 'off' state with external resistors.

Brian.
 

I have implemented the circuit referred by Easyrider83. It works fine now. Thank you andre_teprom, Brian and Easyrider83. Circuit attached.

Thank you.
 

Attachments

  • EXT_DRIVER_MAX7219.JPG
    EXT_DRIVER_MAX7219.JPG
    23.7 KB · Views: 239

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top