7 Segment Displays and MAX7219


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136

    Default 7 Segment Displays and MAX7219

    I'm using a PIC18F8722 at 40 MHz to display data on 7-Segment displays.
    There are 8 digits on each display
    Each display is driven by a MAX7219 driver.
    Initially, I had three displays, each on it's own port - all worked OK.
    Then, to save ports, I daisy-chained the displays (Data_out of one MAX7219 to Data_in of the next). Clock and Data in parallel to all three MAX7219
    Initially, all worked Ok with this chain and then:

    1. After a few minutes, the third display (last in the chain) went blank.
    2. Over the next half hour the second display dimmed and finally turned off.
    3. Then the first display froze on '88888888'


    The voltage without the displays connected in 4.97 and with all three displays connected it is 4.94, so i don't think suppy voltage is the problem?

    Too high a load for the port?
    Recompiling to run at 10 MHz makes no difference.
    The connections between the PIC and displays is via 10-way IDC and ribbon cable.

    Anyone experienced difficulties daisy-chaining displays/MAX7219?

    Code:
    ' *****************************************************************************
    ' *                                                                           *
    ' * File...... 8722 Segments  Daisey chained displays with MAX7219            *
    ' * Purpose... PIC18F8722 on BIGPIC5                                          *
    ' * Date...... July 2009                                                      *
    ' *                                                                           *
    ' *****************************************************************************
    
    ' 1. PIC18F8722 on BIGPIC5 @ 40 MHz
    ' 2. Three display boards each with 8 digits controlled by MAX7219 drivers
    ' 3. All displays daisy-chained (Data_out to Data_in) on PORTE
    
    define OSC 40	' Define Xtal as 20 MHz, use "HSPLL" for programming
    include "modedefs.bas"      ' Include serout defines
    
    Z		var	word
    I		var	byte
    
    DataPin     var PORTE.0		' For ETT display
    ClockPin    var PORTE.2		' For ETT display
    Load        var PORTE.1		' For ETT display
    
    ADCON1	= %00001111			' All ports digital
    CMCON	= $07     			' Comparators OFF
    INTCON	= $80            	' Turns off interrupts. See PBP page 187                  
    TRISA=0 : TRISB=0 : TRISC=0 : TRISD=0 : TRISE=0 : TRISF=0 : TRISG=0 : TRISH=0 : TRISJ=0
    PORTA=0 : PORTB=0 : PORTC=0 : PORTD=0 : PORTE=0 : PORTF=0 : PORTG=0 : PORTH=0 : PORTJ=0 
    
    ' Clear displays:
    
        low load    
        shiftout datapin,clockpin,1,[$0F, $00]	' 3rd Display	Test mode off
        shiftout datapin,clockpin,1,[$0F, $00]	' 2nd Display	Test mode off
        shiftout datapin,clockpin,1,[$0F, $00]	' 1st Display	Test mode off
        high load
        
        low load    
        shiftout datapin,clockpin,1,[$09, $FF]	' Decode register - decode all 8 digits
        shiftout datapin,clockpin,1,[$09, $FF]	' Decode register - decode all 8 digits
        shiftout datapin,clockpin,1,[$09, $FF]	' Decode register - decode all 8 digits    
        high load
        
        low load
        shiftout datapin,clockpin,1,[$0A, $0F]	' Intensity register - 32/32 brightness
        shiftout datapin,clockpin,1,[$0A, $0F]	' Intensity register - 32/32 brightness
        shiftout datapin,clockpin,1,[$0A, $0F]	' Intensity register - 32/32 brightness    
        high load
        
        low load
        shiftout datapin,clockpin,1,[$0B, $07]	' Scan limit register - display all digits
        shiftout datapin,clockpin,1,[$0B, $07]	' Scan limit register - display all digits
        shiftout datapin,clockpin,1,[$0B, $07]	' Scan limit register - display all digits    
        high load
        
        low load
        shiftout datapin,clockpin,1,[$0C, $01]	' Shutdown register - normal operation
        shiftout datapin,clockpin,1,[$0C, $01]	' Shutdown register - normal operation
        shiftout datapin,clockpin,1,[$0C, $01]	' Shutdown register - normal operation	    
        high load
        
        for i=1 to 8
        low load
        shiftout datapin,clockpin,1,[i,  $0F]	' Clear all digits
        shiftout datapin,clockpin,1,[i,  $0F]	' Clear all digits
        shiftout datapin,clockpin,1,[i,  $0F]	' Clear all digits    
        high load
        next I
    
    ' *****************************************************************************
    ' *                                                                           *
    ' *                                    MAIN                                   * 
    ' *                                                                           *
    ' *****************************************************************************
    
    Main:	
    	for Z= 0 to 64000
    		for I=0 to 4
    			low load
    			shiftout datapin,clockpin,1,[I+1,Z dig I]	' 3rd Display					
    			shiftout datapin,clockpin,1,[I+1,Z dig I]	' 2nd Display
    			shiftout datapin,clockpin,1,[I+1,Z DIG I]	' 1st Display
    			high load
    			next I
    		pause 300
    	next Z
    	
        for i=1 to 8
        low load
        shiftout datapin,clockpin,1,[i,$F]	' Clear all digits
        shiftout datapin,clockpin,1,[i,$F]	' Clear all digits
        shiftout datapin,clockpin,1,[i,$F]	' Clear all digits    
        high load
        next I	
    	
    	goto main
    	
    end

  2. #2
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Bill,

    I can't say I've cascaded the MAX7219, but I am using the MAX7221 IC on a project and am relatively familar with the datasheet. Some very silly questions, but important none the less.

    You say you paralleled the clock and data lines. I presume by data you mean the LOAD (CS) pin? Is your setup close to that as shown on page 13 of the datasheet?

    Are the ISET resistors in place on each IC and appropriately sized for the 7-segments you're using?

    Have you tried adding a couple capacitors for filtering?

    In a pinch, it sounds like a communication error - I haven't been through your code thoroughly - but when you say you see nothing but 8's in the first display, do the commas also light up? I'm wondering if the IC believes you sent a Display Test Register command.

    Again, I apologize if the questions seem silly, but no means am I questioning your abilities - I've just made so many simple mistakes with these things myself it's laughable. Oh, one last thing - are you using a breadboard? I found that when I used long wires for the comms from the PIC to the IC that sometimes the data became junk. When I shortened a wire or made a direct connection between the PIC's pin and the IC's pin, things cleared up.

    Do you have a schematic and/or picture of your layout?


    -Tony

  3. #3
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Cascading Displays

    Tony,

    Thanks for your interest, I was beginning to think this subject was a dead duck.

    I think you must be correct with the communications issue. A few facts about the displays:

    1. They are a commercially made item (not that this guarantees perfection, but it rules out obvious stuff-ups) from Futurlec.

    2. Each display board has 8 digits and the MAX7219 driver.

    3. The Iset resistors are 10k, not 'A maximum of 9.53k' as stated in the data sheet from MAXIM. Do you think the extra 470 Ohms matters?

    4. There are decoupling capacitors on the boards: value 47mF, not '0.1mF' as stated in the MAXIM data sheet.

    When the display fails it shows '88888888' without the decimal points.

    I have just had a thought!

    The supply voltages that I measured down the chain of three boards was OK - BUT this was whilst the displays were working OK.

    Suppose that the three displays are commanded to display (worst case)
    '88888888' '88888888' '88888888'
    then the current drain will be much higher than (best case)
    '-------1' '-------1' '-------1'
    And the 5 Volt supply will be pulled down to a level where the MAX7219 chips won't work?

    So it could be caused by an inability to suppy the current if all digits need to be on?

    Any ideas/comments

    Regards Bill Legge

  4. #4
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Cascading MAX7219

    Tony,

    Not much luck with my idea that the supply was being pulled down by the displays attempting to show '88888888' '88888888' '88888888'

    I did three tests:

    1. Bypassed the MCU/PIC 5Volt supply and provided 5V from my bench-top PSU. No luck - problem remains.

    2. Set the intensity register low to minimise current drawn by the displays - No luck.

    3. Measured the Vcc pins on the displays whilst showing '88888888' '88888888' '88888888' - and the voltages are 'healthy' i.e. about 4.8 Volts

    I think I'll just have to revert to one port per MAX7219?

    I also made an error in understanding the Iset resistance, it's a MINIMUM of 9.5k so 10k is OK. The circuit I am using is identical to the one in the MAX spec sheet for cascading devices but with the decoupling capacitor 47mF not 0.1mF

    Regards Bill Legge

  5. #5
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    955


    Did you find this post helpful? Yes | No

    Default

    Hi Bill

    This looks like a timing problem to me. The clock is getting skewed with time due to capacitive load changes due to temperature drift (maybe) A possible solution maybe to buffer your clock and Load lines which are common to all the 7219s.

    A couple of suggestions
    - try to use the internal oscillator @4MHz if available so that this might me ruled out.
    - rule out a ground problem by jumpering the grounds. This may be a cause for signal level deterioration at the last chip
    - Use standard decoupling of 0.1mfd. The 47mfd sounds generous but may not be good to filter the ripples caused due to the displays scanning.

  6. #6
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Cascading MAX7219

    Jerson,

    Thank's for your thoughts. I'll try:

    1. 0.1 mfd decouplers.
    2. Buffering the data and clock lines.

    I've got a storage scope so perhaps the answer is to grab the clock/data out of the MCU and compare it with the data out of the last display and - hopefully, spot some degredation?

    Regards Bill Legge

  7. #7
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Bill

    I have used these displays for a couple of years and also have made my own displays using the MAX7219. I can tell you they are sensitive at start up you need to ensure you have enough capacitance. For my home brew project I had to add a 100uf cap on the 5 volt lines. Got a lot of strange results without it' I have also included the setup I use with two chips daisey chained.

    Code:
    '###############################################################################    
     ' ====================== MAX7219 SETUP ==========================
    
    MAX_SET_UP:
    for a = 0 to 3
        For index = 0 to 7		' Retrieve 8 items from table. 
          LookUp index,[SCAN,7,BRITE,10,DECODE,%11111111,ON_OFF,1],max_dat
          ShiftOut DATA_n,CLK_n,1,[max_dat]
          IF odd = 0  Then noLoad	' If odd is 1, 
          PulsOut LOAD_n,1		' pulse LOAD line.
        NoLoad:				' Else, don't pulse. 
        Next index					' Get next item from table. 
    next a
    		
    return
    '' ===================== DISPLAY SUBROUTINE ========================
    
    Max1:
    
      ShiftOut DATA_n,CLK_n,1,[0,0] '
      ShiftOut DATA_n,CLK_n,1,[seg,dat]	' Send the digit. 
      PulsOut LOAD_n,1				' Load the display. 
      						' Repeat for all 4 digits. 
    return						' Done? Return. 
    
    Max2:
        ShiftOut DATA_n,CLK_n,1,[seg,dat]	' Send the digit. 
        ShiftOut DATA_n,CLK_n,1,[0,0]
        PulsOut LOAD_n,1	
    
    return

    Good luck

    Dave

  8. #8
    Join Date
    Nov 2007
    Location
    South-West of Australia. A small town called Denmark. 'Where the forest meets the sea.'
    Posts
    136


    Did you find this post helpful? Yes | No

    Default Cascading MAX7219

    Dave,

    Thanks for the tip, I'll try big caps.

    Prices are excellent at Futurlec but the support/documentation is sometimes lacking - still a bargain.

    I like your MAX set-up (mine is lots of lines of obvious code!) but cant quite follow it:

    1. The set-up generally is of the form [Register,Value]
    2. Where Register goes from 0 to F
    3. And value is byte sized

    4. What is your variable 'a' ?
    5. What size is the variable 'Max_dat' ?
    6. I can't see how you are writing 'Register' and 'Data' to the MAX?

    Regards Bill Legge

  9. #9
    Join Date
    Apr 2005
    Location
    Virginia
    Posts
    65


    Did you find this post helpful? Yes | No

    Default

    Bill,

    I don't know that I can offer much more help, but it looks like Jerson and Dave have some excellent leads. When you mentioned seven segment displays from Futurelec, it rang a bell. I had a project last year where I needed 3", dual color seven segment displays and I got in touch with the manufacturer in China. They have even more options than what Futurelec offers and you can buy from them directly if you wish - be warned they don't accept credit cards (at least last year), so you have to do a bank transfer, which somehow cost us ~$40 bucks and shipping was about ~$25, but for the quantities you're talking about, it might be worth it. Regardless, they try to be helpful so if you have questions on their units or need a datasheet you can e-mail them and they usually get back to you by the next day. Their website is: http://www.nb-flying.com/.

  10. #10
    Join Date
    Mar 2008
    Location
    Gerogetown, Texas
    Posts
    94


    Did you find this post helpful? Yes | No

    Default

    Bill

    Code:
    1. The set-up generally is of the form [Register,Value]
    2. Where Register goes from 0 to F
    3. And value is byte sized
    
    4. What is your variable 'a' ?
    5. What size is the variable 'Max_dat' ?
    6. I can't see how you are writing 'Register' and 'Data' to the MAX?
    "a" is just a byte used to count, in this case it runs through the setup four times, With two displays I wanted to make sure it was setup correctly. I most likely could have done it with two cycles. ( a little overkill)

    Max_Dat is a word

    The lookup table has the register followed by the value. The load only happens on an even number so first I shift the "register" then the "value" and load pulse.

    Works fine

    Here are the variables
    Code:
    DATA_n	var portC.2	' Bits are shifted out this pin # to 7219.
    CLK_n 	var portC.0	' Data valid on rising edge of this clock pin.
    LOAD_n	var portC.1	' Tells 7219 to transfer data to LEDs.
    DECODE 	CON	9	' Control register; a 1 turns on BCD decoding. 
    BRITE 	CON	10	' "       "   " intensity register.
    SCAN  	CON	11	' "       "   " highest # (0-7) of LED digit.
    ON_OFF	CON	12	' "       "   " on/off status of display (0=off).
    TEST  	CON	15	' Test mode (all digits/segment on, 100% bright)
    
    max_dat	VAR	WORD	' Word to be sent to MAX7219.
    Good luck

  11. #11


    Did you find this post helpful? Yes | No

    Default

    Hello friends,

    I've completed the test with the code and have not had any problems so far, will continue to test and if they notice something new.




    ------------------------------------------------------------------------------------------------------------------------------------------------
    [QUOTE=Bill Legge;76621]I'm using a PIC18F8722 at 40 MHz to display data on 7-Segment displays.
    There are 8 digits on each display
    Each display is driven by a MAX7219 driver.
    Initially, I had three displays, each on it's own port - all worked OK.
    Then, to save ports, I daisy-chained the displays (Data_out of one MAX7219 to Data_in of the next). Clock and Data in parallel to all three MAX7219
    Initially, all worked Ok with this chain and then:

    1. After a few minutes, the third display (last in the chain) went blank.
    2. Over the next half hour the second display dimmed and finally turned off.
    3. Then the first display froze on '88888888'


    The voltage without the displays connected in 4.97 and with all three displays connected it is 4.94, so i don't think suppy voltage is the problem?

    Too high a load for the port?
    Recompiling to run at 10 MHz makes no difference.
    The connections between the PIC and displays is via 10-way IDC and ribbon cable.

    Anyone experienced difficulties daisy-chaining displays/MAX7219?
    Last edited by Leonardo; - 8th September 2009 at 18:16.

  12. #12
    Join Date
    May 2004
    Posts
    81


    Did you find this post helpful? Yes | No

    Default

    Well, Since this is kind of what Im working with figure I will ask here. Im using the same MAX7219. I have a micro simply counting from 0 to 9999. So far no problems with the code or the MAX7219 IC. My problem is this: Im using displays LSD8151. Its spec sheet says I should be driving the segments at around 21mA, so looking at the handy dandy table in the 7219 spec sheet I chose a 28K resistor for Rset @ 20mA. Display works fine. Im using the internal osc on the pic, and just a small 10uf cap at the LM7805 5V reg IC. That is where my problem is: the LM7805 is getting quite toasty running this thing. I did put a heat sink on it and its down to the point where I can touch it now with out burning myself, but my question is this: Is there a more efficient way to supply the 7219 with its power needs? I just cant help thinking alot of power is being wasted being disipated by so much heat.. or is it just normal for this to run so hot in this configuration?

  13. #13


    Did you find this post helpful? Yes | No

    Default

    If it's a one off that you are making, you can purchase a buck controller. Basically it PWM's to a desired voltage output and has active feedback to maintain that voltage. You will need filtering at the output with some caps / inductors depending on the current draw you have.

    I have made my own using opamps (oscillator and feedback) to supply 5v. So I can run my motors from the main 12v battery and pwm down that voltage much more efficiently to my desired 5v for MCU, display...etc. Filtering caps and inductors are a must.

    Nick

  14. #14
    Join Date
    May 2004
    Posts
    81


    Did you find this post helpful? Yes | No

    Default

    I added an UDN2981 and I am now pulling the current from the 12V supply and using current limiting resistors on each segment. Works like a charm now.

Similar Threads

  1. MAX7219 Helping Hand Please
    By isaac in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 14th February 2014, 16:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts